]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/71573 (ICE on invalid C code on x86_64-linux-gnu (tree check: expected functi...
authorMarek Polacek <polacek@redhat.com>
Fri, 29 Jul 2016 17:36:46 +0000 (17:36 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 29 Jul 2016 17:36:46 +0000 (17:36 +0000)
PR c/71573
* c-decl.c (implicitly_declare): Return decl early not only for
error_mark_nodes, but for anything that is not a FUNCTION_DECL.

* gcc.dg/noncompile/pr71573.c: New test.

From-SVN: r238885

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/noncompile/pr71573.c [new file with mode: 0644]

index ec680d3cce6dc715d3d0f5bc6871d74a1fed2a62..06507581fad785558e8812bff1fc65fc1676298b 100644 (file)
@@ -7,6 +7,10 @@
        * c-parser.c (c_parser_switch_statement): Initialize ce.original_type
        to error node for invalid code.
 
+       PR c/71573
+       * c-decl.c (implicitly_declare): Return decl early not only for
+       error_mark_nodes, but for anything that is not a FUNCTION_DECL.
+
 2016-07-29  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/71969
index 9a922cc6f0645ab4c7621dea94b86da5bf12ab27..5f38985086cb38f16c151ac5d8caa39ad5837a20 100644 (file)
@@ -3327,7 +3327,7 @@ implicitly_declare (location_t loc, tree functionid)
 
   if (decl)
     {
-      if (decl == error_mark_node)
+      if (TREE_CODE (decl) != FUNCTION_DECL)
        return decl;
 
       /* FIXME: Objective-C has weird not-really-builtin functions
index dbe2a3ae08867687443427c86183b2e7b3425031..e29c07cb8b947a9679467b8fae25a0ac59c17ebd 100644 (file)
@@ -8,6 +8,9 @@
        PR c/71853
        * gcc.dg/noncompile/pr71853.c: New test.
 
+       PR c/71573
+       * gcc.dg/noncompile/pr71573.c: New test.
+
 2016-07-29  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.dg/pr59833.c: Use dg-add-options ieee.
diff --git a/gcc/testsuite/gcc.dg/noncompile/pr71573.c b/gcc/testsuite/gcc.dg/noncompile/pr71573.c
new file mode 100644 (file)
index 0000000..8ace94a
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR c/71573 */
+/* { dg-do compile } */
+
+void
+f1 (void)
+{
+  extern int t;
+}
+
+void
+f2 (void)
+{
+  t (0); /* { dg-error "called object .t. is not a function or function pointer" } */
+}