8sa1-gcc/gcc/testsuite/gcc.dg/qual-return-1.c
Joseph Myers e0c9fbb763 c-decl.c (grokdeclarator): Move warning for qualified void return types with -pedantic to when...
* c-decl.c (grokdeclarator): Move warning for qualified void
	return types with -pedantic to when the function type is
	constructed.  At -W, warn in general for qualified function return
	types, except for volatile void.
	* invoke.texi: Document this new warning at -W.

testsuite:
	* gcc.dg/qual-return-1.c, gcc.dg/qual-return-2.c: New tests.

From-SVN: r37056
2000-10-25 18:45:44 +01:00

25 lines
1.1 KiB
C

/* Test for warnings for qualified function return types. */
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -W" } */
/* Qualifying a function return type makes no sense. */
const int int_fn (void); /* { dg-warning "qualifiers" "int decl" } */
const int (*int_ptr) (void); /* { dg-warning "qualifiers" "int ptr" } */
const int int_fn2 (void) { return 0; } /* { dg-warning "qualifiers" "int defn" } */
const void void_fn (void); /* { dg-warning "qualifiers" "void decl" } */
const void (*void_ptr) (void); /* { dg-warning "qualifiers" "void ptr" } */
const void void_fn2 (void) { } /* { dg-warning "qualifiers" "void defn" } */
/* "volatile void" is a GNU extension, so only warn at -pedantic. */
volatile void vvoid_fn (void);
volatile void (*vvoid_ptr) (void);
volatile void vvoid_fn2 (void) { }
int *restrict ip_fn (void); /* { dg-warning "qualifiers" "restrict decl" } */
int *restrict (*ip_ptr) (void); /* { dg-warning "qualifiers" "restrict ptr" } */
int *restrict ip_fn2 (void) { return (int *)0; }; /* { dg-warning "qualifiers" "restrict defn" } */