re PR c/20368 (internal compiler error: tree check: expected function_type or method_...
authorJoseph Myers <joseph@codesourcery.com>
Wed, 30 Mar 2005 19:35:49 +0000 (20:35 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Wed, 30 Mar 2005 19:35:49 +0000 (20:35 +0100)
PR c/20368
* c-decl.c (start_function): Check for old_decl being
error_mark_node.

testsuite:
* gcc.dg/pr20368-1.c, gcc.dg/pr20368-2.c, gcc.dg/pr20368-3.c: New
tests.

From-SVN: r97270

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

index 0e5dea3c816e3450988650c4339f112bd2897ef5..285c5fb98b38572284a28c0dd7b60ae622ad73ea 100644 (file)
@@ -1,3 +1,9 @@
+2005-03-30  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/20368
+       * c-decl.c (start_function): Check for old_decl being
+       error_mark_node.
+
 2005-03-30  Ian Lance Taylor  <ian@airs.com>
 
        * final.c (final): Remove prescan parameter.  Change all callers.
index cc45e26c2fd586359880193d1cfd6c2b6981c17d..f333dade0b8e23c6f6da88a3cdc33930641207eb 100644 (file)
@@ -5691,11 +5691,13 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
 
   /* Optionally warn of old-fashioned def with no previous prototype.  */
   if (warn_strict_prototypes
+      && old_decl != error_mark_node
       && TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0
       && C_DECL_ISNT_PROTOTYPE (old_decl))
     warning ("function declaration isn%'t a prototype");
   /* Optionally warn of any global def with no previous prototype.  */
   else if (warn_missing_prototypes
+          && old_decl != error_mark_node
           && TREE_PUBLIC (decl1)
           && !MAIN_NAME_P (DECL_NAME (decl1))
           && C_DECL_ISNT_PROTOTYPE (old_decl))
@@ -5703,7 +5705,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
   /* Optionally warn of any def with no previous prototype
      if the function has already been used.  */
   else if (warn_missing_prototypes
-          && old_decl != 0 && TREE_USED (old_decl)
+          && old_decl != 0
+          && old_decl != error_mark_node
+          && TREE_USED (old_decl)
           && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) == 0)
     warning ("%J%qD was used with no prototype before its definition",
             decl1, decl1);
@@ -5716,7 +5720,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
   /* Optionally warn of any def with no previous declaration
      if the function has already been used.  */
   else if (warn_missing_declarations
-          && old_decl != 0 && TREE_USED (old_decl)
+          && old_decl != 0
+          && old_decl != error_mark_node
+          && TREE_USED (old_decl)
           && C_DECL_IMPLICIT (old_decl))
     warning ("%J%qD was used with no declaration before its definition",
             decl1, decl1);
index 991873cb8abc8f61adb99581fd04a208595a8072..be4633b2824775e7f108e9fe500d0f2ef1e45182 100644 (file)
@@ -1,3 +1,9 @@
+2005-03-30  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/20368
+       * gcc.dg/pr20368-1.c, gcc.dg/pr20368-2.c, gcc.dg/pr20368-3.c: New
+       tests.
+
 2005-03-30  Alan Modra  <amodra@bigpond.net.au>
 
        * gcc.c-torture/compile/pr20203.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr20368-1.c b/gcc/testsuite/gcc.dg/pr20368-1.c
new file mode 100644 (file)
index 0000000..a88c7f8
--- /dev/null
@@ -0,0 +1,12 @@
+/* ICE with -Wstrict-prototypes and typeof an undeclared function.
+   Bug 20368.  */
+/* { dg-do compile } */
+/* { dg-options "-Wstrict-prototypes" } */
+
+extern __typeof (f) g; /* { dg-error "error: 'f' undeclared here \\(not in a function\\)" } */
+
+int
+f (x)
+     float x;
+{
+}
diff --git a/gcc/testsuite/gcc.dg/pr20368-2.c b/gcc/testsuite/gcc.dg/pr20368-2.c
new file mode 100644 (file)
index 0000000..e3c8396
--- /dev/null
@@ -0,0 +1,12 @@
+/* ICE with -Wstrict-prototypes and typeof an undeclared function.
+   Bug 20368.  Test with -Wmissing-prototypes.  */
+/* { dg-do compile } */
+/* { dg-options "-Wmissing-prototypes" } */
+
+extern __typeof (f) g; /* { dg-error "error: 'f' undeclared here \\(not in a function\\)" } */
+
+int
+f (x)
+     float x;
+{
+}
diff --git a/gcc/testsuite/gcc.dg/pr20368-3.c b/gcc/testsuite/gcc.dg/pr20368-3.c
new file mode 100644 (file)
index 0000000..3209599
--- /dev/null
@@ -0,0 +1,12 @@
+/* ICE with -Wstrict-prototypes and typeof an undeclared function.
+   Bug 20368.  Test with -Wmissing-declarations.  */
+/* { dg-do compile } */
+/* { dg-options "-Wmissing-declarations" } */
+
+extern __typeof (f) g; /* { dg-error "error: 'f' undeclared here \\(not in a function\\)" } */
+
+int
+f (x)
+     float x;
+{
+}