summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-22 00:00:47 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-22 00:00:47 +0000
commit0bfe25798d1fa49fd6142742830ea694bade9db9 (patch)
tree1ac4fa272ceee88b2f67fe94a86bf5a4e1fb5d60 /gcc/testsuite/gcc.dg
parenta250ed2ee693d37316a0fef984e582b017c76fc6 (diff)
downloadgcc-0bfe25798d1fa49fd6142742830ea694bade9db9.tar.gz
PR c/15052
* c-decl.c (grokdeclarator): Only pedwarn for qualified void return type on function definitions. Move other warnings for qualified return type to -Wreturn-type. Do not condition any such warnings on -pedantic. Update comments. (start_function): Only copy function type from previous prototype declaration if return types are compatible. * c-typeck.c (function_types_compatible_p): Don't condition warning for incompatibility of volatile qualifiers on the return type on -pedantic. Update comment. * doc/invoke.texi (-Wreturn-type, -Wextra): Update. testsuite: * gcc.dg/noreturn-5.c: Test qualifiers on function type instead of on return type. * gcc.dg/qual-return-1.c: Use -Wreturn-type. Update expected messages. * gcc.dg/qual-return-2.c: Update expected messages. * gcc.dg/qual-return-3.c, gcc.dg/qual-return-4.c: New tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85024 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/noreturn-5.c3
-rw-r--r--gcc/testsuite/gcc.dg/qual-return-1.c12
-rw-r--r--gcc/testsuite/gcc.dg/qual-return-2.c9
-rw-r--r--gcc/testsuite/gcc.dg/qual-return-3.c16
-rw-r--r--gcc/testsuite/gcc.dg/qual-return-4.c10
5 files changed, 37 insertions, 13 deletions
diff --git a/gcc/testsuite/gcc.dg/noreturn-5.c b/gcc/testsuite/gcc.dg/noreturn-5.c
index 07381a66d24..e69087a4d74 100644
--- a/gcc/testsuite/gcc.dg/noreturn-5.c
+++ b/gcc/testsuite/gcc.dg/noreturn-5.c
@@ -4,4 +4,5 @@
The testsuite uses -ansi -pedantic-errors by default, so this has
to override. */
extern void xxx (int) __attribute__((noreturn));
-__volatile extern void xxx (int);
+typedef void voidfn (int);
+__volatile extern voidfn xxx;
diff --git a/gcc/testsuite/gcc.dg/qual-return-1.c b/gcc/testsuite/gcc.dg/qual-return-1.c
index 5cab75c93d7..ac94df6d2bb 100644
--- a/gcc/testsuite/gcc.dg/qual-return-1.c
+++ b/gcc/testsuite/gcc.dg/qual-return-1.c
@@ -1,7 +1,7 @@
/* Test for warnings for qualified function return types. */
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -W" } */
+/* { dg-options "-std=gnu99 -Wreturn-type" } */
/* Qualifying a function return type makes no sense. */
@@ -11,13 +11,11 @@ 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" } */
+const void void_fn2 (void) { } /* { dg-warning "qualified" "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) { }
+volatile void vvoid_fn (void); /* { dg-warning "qualifiers" "void decl" } */
+volatile void (*vvoid_ptr) (void); /* { dg-warning "qualifiers" "void ptr" } */
+volatile void vvoid_fn2 (void) { } /* { dg-warning "qualified" "void defn" } */
int *restrict ip_fn (void); /* { dg-warning "qualifiers" "restrict decl" } */
int *restrict (*ip_ptr) (void); /* { dg-warning "qualifiers" "restrict ptr" } */
diff --git a/gcc/testsuite/gcc.dg/qual-return-2.c b/gcc/testsuite/gcc.dg/qual-return-2.c
index 272787ee7c2..22a1946b03f 100644
--- a/gcc/testsuite/gcc.dg/qual-return-2.c
+++ b/gcc/testsuite/gcc.dg/qual-return-2.c
@@ -5,10 +5,9 @@
/* Qualifying a function return type makes no sense. */
-/* "volatile void" is a GNU extension, so only warn at -pedantic.
- Strictly, the first two of these should warn only if the function is
- somewhere used or defined. */
+/* The first two of these shouldn't warn (with just -pedantic) as long
+ as the function is not defined. */
-volatile void vvoid_fn (void); /* { dg-warning "qualified" "volatile decl" } */
-volatile void (*vvoid_ptr) (void); /* { dg-warning "qualified" "volatile ptr" } */
+volatile void vvoid_fn (void);
+volatile void (*vvoid_ptr) (void);
volatile void vvoid_fn2 (void) { } /* { dg-warning "qualified" "volatile defn" } */
diff --git a/gcc/testsuite/gcc.dg/qual-return-3.c b/gcc/testsuite/gcc.dg/qual-return-3.c
new file mode 100644
index 00000000000..7a92046da81
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/qual-return-3.c
@@ -0,0 +1,16 @@
+/* Test for warnings for qualified function return types. Bug 15052
+ from Olatunji Ruwase (tjruwase at stanfordalumni.org): qualifiers
+ should not be lost when merging declarations. */
+
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+int foo (); /* { dg-error "previous declaration" "different qualifiers" } */
+const int foo () { return 0; } /* { dg-error "conflicting types" "different qualifiers" } */
+
+void bar (void);
+volatile void bar () { } /* { dg-warning "qualified|volatile" "different qualifiers" } */
+
+volatile void baz (void);
+void baz () { } /* { dg-warning "not compatible" "different qualifiers" } */
diff --git a/gcc/testsuite/gcc.dg/qual-return-4.c b/gcc/testsuite/gcc.dg/qual-return-4.c
new file mode 100644
index 00000000000..9b61cfebf12
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/qual-return-4.c
@@ -0,0 +1,10 @@
+/* Test for warnings for qualified function return types. -pedantic
+ test. Only the definition gets a warning for qualified void return
+ types, not other such types within the definition. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "-pedantic" } */
+
+volatile void (*y)(int);
+
+volatile void (*vvf(int x))(int) { return y; }