From e00dceafd2de848a7735dbce48922aa2304a0f94 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 29 Jul 2016 17:36:46 +0000 Subject: [PATCH] re PR c/71573 (ICE on invalid C code on x86_64-linux-gnu (tree check: expected function_decl, have var_decl in implicitly_declare)) 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 | 4 ++++ gcc/c/c-decl.c | 2 +- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/noncompile/pr71573.c | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/noncompile/pr71573.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index ec680d3cce6..06507581fad 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -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 PR c/71969 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 9a922cc6f06..5f38985086c 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dbe2a3ae088..e29c07cb8b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 * 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 index 00000000000..8ace94a77ea --- /dev/null +++ b/gcc/testsuite/gcc.dg/noncompile/pr71573.c @@ -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" } */ +} -- 2.30.2