]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/28299 (ICE with -Wmissing-prototypes)
authorJoseph Myers <joseph@codesourcery.com>
Fri, 25 Aug 2006 21:11:46 +0000 (22:11 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Fri, 25 Aug 2006 21:11:46 +0000 (22:11 +0100)
PR c/28299
* c-decl.c (start_function): Don't try to process prototype
information from old declaration that isn't a function.

testsuite:
* gcc.dg/funcdef-var-1.c, gcc.dg/funcdef-var-2.c: New tests.
* gcc.dg/pr20368-1.c, gcc.dg/pr20368-2.c, gcc.dg/pr20368-3.c:
Expect extra diagnostics.

From-SVN: r116435

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/funcdef-var-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/funcdef-var-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr20368-1.c
gcc/testsuite/gcc.dg/pr20368-2.c
gcc/testsuite/gcc.dg/pr20368-3.c

index 865d0156f9ff6e1d6be6942fe11ac37424bec690..582ea4d8432dd96f5dbcee0785486c5e050b327b 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-25  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/28299
+       * c-decl.c (start_function): Don't try to process prototype
+       information from old declaration that isn't a function.
+
 2006-08-25  Jan Hubicka  <jh@suse.cz>
 
        PR target/28621
index 494c221f55527050d33a63159b72ea6b9bfa8394..cf89191ae2e29caf31ae7c4f07da75ca746ec523 100644 (file)
@@ -5991,6 +5991,8 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
   /* If this definition isn't a prototype and we had a prototype declaration
      before, copy the arg type info from that prototype.  */
   old_decl = lookup_name_in_scope (DECL_NAME (decl1), current_scope);
+  if (old_decl && TREE_CODE (old_decl) != FUNCTION_DECL)
+    old_decl = 0;
   current_function_prototype_locus = UNKNOWN_LOCATION;
   current_function_prototype_built_in = false;
   current_function_prototype_arg_types = NULL_TREE;
index 8b2850a34e009ddc93a3333cb7f16904a20f1d96..85df20fdf7f27ab8ae6545de7c0532bd7f4f6ccb 100644 (file)
@@ -1,3 +1,10 @@
+2006-08-25  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/28299
+       * gcc.dg/funcdef-var-1.c, gcc.dg/funcdef-var-2.c: New tests.
+       * gcc.dg/pr20368-1.c, gcc.dg/pr20368-2.c, gcc.dg/pr20368-3.c:
+       Expect extra diagnostics.
+
 2006-08-25  J"orn Rennecke  <joern.rennecke@st.com>
 
        gcc.dg/noncompile/pr16876.c: New test.
diff --git a/gcc/testsuite/gcc.dg/funcdef-var-1.c b/gcc/testsuite/gcc.dg/funcdef-var-1.c
new file mode 100644 (file)
index 0000000..a685af7
--- /dev/null
@@ -0,0 +1,10 @@
+/* Test ICE on defining function with a name previously declared as a
+   nonfunction.  Bug 28299 from Bernhard Fischer
+   <aldot@gcc.gnu.org>.  */
+/* { dg-do compile } */
+/* { dg-options "-Wmissing-prototypes" } */
+
+extern __typeof(foo) foo __asm__(""); /* { dg-error "undeclared" } */
+/* { dg-error "previous declaration" "previous declaration" { target *-*-* } 7 } */
+void *foo (void) {} /* { dg-error "redeclared as different kind of symbol" } */
+/* { dg-warning "no previous prototype" "no previous prototype" { target *-*-* } 9 } */
diff --git a/gcc/testsuite/gcc.dg/funcdef-var-2.c b/gcc/testsuite/gcc.dg/funcdef-var-2.c
new file mode 100644 (file)
index 0000000..744987e
--- /dev/null
@@ -0,0 +1,11 @@
+/* Test ICE on defining function with a name previously declared as a
+   nonfunction.  Bug 28299 from Bernhard Fischer <aldot@gcc.gnu.org>.
+   Reduced testcase from Volker Reichelt <reichelt@gcc.gnu.org>.  */
+
+/* { dg-do compile } */
+/* { dg-options "-Wmissing-prototypes" } */
+
+int foo;
+/* { dg-error "previous declaration" "previous declaration" { target *-*-* } 8 } */
+void foo () {} /* { dg-error "redeclared as different kind of symbol" } */
+/* { dg-warning "no previous prototype" "no previous prototype" { target *-*-* } 10 } */
index a88c7f803b76ef9ec0c4bab9998b9ac0226bf5c1..40ef9fe90be2e96c627feb120ff193932417ede6 100644 (file)
@@ -7,6 +7,6 @@ extern __typeof (f) g; /* { dg-error "error: 'f' undeclared here \\(not in a fun
 
 int
 f (x)
-     float x;
+     float x; /* { dg-warning "warning: function declaration isn't a prototype" } */
 {
 }
index e3c8396233ef8b44530c36605420c359d13bc531..07bcbcec16db570f517f703c1cf1551f8c884c91 100644 (file)
@@ -7,6 +7,6 @@ extern __typeof (f) g; /* { dg-error "error: 'f' undeclared here \\(not in a fun
 
 int
 f (x)
-     float x;
+     float x; /* { dg-warning "warning: no previous prototype for 'f'" } */
 {
 }
index 32095999676416652440eb2a31d6862ee1e42dd5..69c0bc81ce69d5c50417baf0d6c14d5a125c45c3 100644 (file)
@@ -7,6 +7,6 @@ extern __typeof (f) g; /* { dg-error "error: 'f' undeclared here \\(not in a fun
 
 int
 f (x)
-     float x;
+     float x; /* { dg-warning "warning: no previous declaration for 'f'" } */
 {
 }