On 7 February 2017 at 13:40, Richard Biener <richard.guent...@gmail.com> wrote: > On Mon, Feb 6, 2017 at 7:00 AM, Prasad Ghangal <prasad.ghan...@gmail.com> > wrote: >> On 4 January 2017 at 16:02, Richard Biener <richard.guent...@gmail.com> >> wrote: >>> On Wed, Dec 28, 2016 at 7:27 PM, Prasad Ghangal >>> <prasad.ghan...@gmail.com> wrote: >>>> Hi, >>>> The attached patch tries fix ICE due to undeclared variable(s) in the >>>> input. >>>> Successfully bootstrapped on x86_64-pc-linux-gnu, testing is in progress >>> >>> Ok. >>> >> Can you please commit the patch? I don't have access for that. > > Can you share a testcase that broke? I tried >
Consider following testcases: Case 1: int __GIMPLE foo() { if (a != 2) goto bb1; else goto bb2; bb1: a_1 = 10; return a_1; bb2: return 1; } gives: foo gcc/test.c: In function ‘foo’: gcc/test.c:3:7: error: ‘a’ undeclared (first use in this function) if (a != 2) ^ gcc/test.c:3:7: note: each undeclared identifier is reported only once for each function it appears in gcc/test.c:9:3: internal compiler error: in make_ssa_name_fn, at tree-ssanames.c:268 a_1 = 10; ^~~ 0x1199aa0 make_ssa_name_fn(function*, tree_node*, gimple*, unsigned int) ../../git_gcc/gcc/tree-ssanames.c:265 0x839e2c c_parser_parse_ssa_name ../../git_gcc/gcc/c/gimple-parser.c:675 0x83a5e6 c_parser_gimple_postfix_expression ../../git_gcc/gcc/c/gimple-parser.c:845 0x839ac5 c_parser_gimple_unary_expression ../../git_gcc/gcc/c/gimple-parser.c:603 0x838544 c_parser_gimple_statement ../../git_gcc/gcc/c/gimple-parser.c:271 0x83848e c_parser_gimple_compound_statement ../../git_gcc/gcc/c/gimple-parser.c:226 0x837fd2 c_parser_parse_gimple_body(c_parser*) ../../git_gcc/gcc/c/gimple-parser.c:92 0x7f7bb5 c_parser_declaration_or_fndef ../../git_gcc/gcc/c/c-parser.c:2091 0x7f628a c_parser_external_declaration ../../git_gcc/gcc/c/c-parser.c:1468 0x7f5dd3 c_parser_translation_unit ../../git_gcc/gcc/c/c-parser.c:1348 0x82a3c4 c_parse_file() ../../git_gcc/gcc/c/c-parser.c:18185 0x89c5d9 c_common_parse_file() ../../git_gcc/gcc/c-family/c-opts.c:1107 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. Case 2: int __GIMPLE () main (int argc, char * * argv) { bb_2: switch (a) {default: L2; case 1: L0; case 2: L1; } L0: a = 0; goto bb_6; L1: a = 3; goto L2; L2: return a; } main gcc/test3.c: In function ‘main’: gcc/test3.c:6:11: error: ‘a’ undeclared (first use in this function) switch (a) {default: L2; case 1: L0; case 2: L1; } ^ gcc/test3.c:6:11: note: each undeclared identifier is reported only once for each function it appears in gcc/test3.c:6:3: internal compiler error: in gimple_switch_set_index, at gimple.h:4513 switch (a) {default: L2; case 1: L0; case 2: L1; } ^~~~~~ 0xb31385 gimple_switch_set_index ../../git_gcc/gcc/gimple.h:4513 0xb33b3f gimple_build_switch_nlabels(unsigned int, tree_node*, tree_node*) ../../git_gcc/gcc/gimple.c:757 0xb33b90 gimple_build_switch(tree_node*, tree_node*, vec<tree_node*, va_heap, vl_ptr>) ../../git_gcc/gcc/gimple.c:773 0x83bd94 c_parser_gimple_switch_stmt ../../git_gcc/gcc/c/gimple-parser.c:1445 0x83832c c_parser_gimple_compound_statement ../../git_gcc/gcc/c/gimple-parser.c:175 0x837fd2 c_parser_parse_gimple_body(c_parser*) ../../git_gcc/gcc/c/gimple-parser.c:92 0x7f7bb5 c_parser_declaration_or_fndef ../../git_gcc/gcc/c/c-parser.c:2091 0x7f628a c_parser_external_declaration ../../git_gcc/gcc/c/c-parser.c:1468 0x7f5dd3 c_parser_translation_unit ../../git_gcc/gcc/c/c-parser.c:1348 0x82a3c4 c_parse_file() ../../git_gcc/gcc/c/c-parser.c:18185 0x89c5d9 c_common_parse_file() ../../git_gcc/gcc/c-family/c-opts.c:1107 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. Case 3: void __GIMPLE () foo (int a) { bb_2: a = *b; bb_3: return; } foo gcc/test6.c: In function ‘foo’: gcc/test6.c:5:8: error: ‘b’ undeclared (first use in this function) a = *b; ^ gcc/test6.c:5:8: note: each undeclared identifier is reported only once for each function it appears in gcc/test6.c:5:3: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in build_int_cst, at tree.c:1297 a = *b; ^ 0x125cd92 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ../../git_gcc/gcc/tree.c:9866 0x77f8e3 tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) ../../git_gcc/gcc/tree.h:3183 0x123db1e build_int_cst(tree_node*, long) ../../git_gcc/gcc/tree.c:1297 0x124b279 build_simple_mem_ref_loc(unsigned int, tree_node*) ../../git_gcc/gcc/tree.c:4634 0x8396a8 c_parser_gimple_unary_expression ../../git_gcc/gcc/c/gimple-parser.c:565 0x838c9a c_parser_gimple_statement ../../git_gcc/gcc/c/gimple-parser.c:339 0x83848e c_parser_gimple_compound_statement ../../git_gcc/gcc/c/gimple-parser.c:226 0x837fd2 c_parser_parse_gimple_body(c_parser*) ../../git_gcc/gcc/c/gimple-parser.c:92 0x7f7bb5 c_parser_declaration_or_fndef ../../git_gcc/gcc/c/c-parser.c:2091 0x7f628a c_parser_external_declaration ../../git_gcc/gcc/c/c-parser.c:1468 0x7f5dd3 c_parser_translation_unit ../../git_gcc/gcc/c/c-parser.c:1348 0x82a3c4 c_parse_file() ../../git_gcc/gcc/c/c-parser.c:18185 0x89c5d9 c_common_parse_file() ../../git_gcc/gcc/c-family/c-opts.c:1107 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. > int __GIMPLE foo(int a) > { > if (t1 != 2) > goto bb1; > else > goto bb2; > > bb1: > return t1; > > bb2: > return 1; > } > > and it reports > > t.c: In function ‘foo’: > t.c:3:7: error: ‘t1’ undeclared (first use in this function) > if (t1 != 2) > ^~ > t.c:3:7: note: each undeclared identifier is reported only once for > each function it appears in > t.c:9:10: error: invalid conversion in return statement > return t1; > ^~ > t.c:1:14: note: declared here > int __GIMPLE foo(int a) > ^~~ > > and thus doesn't ICE. > > Maybe one of my patches in this area made yours redundant (it doesn't > apply cleanly anymore as well). I have rebased and updated the patch. Thanks, Prasad > > Thanks, > Richard. > >> Thanks, >> Prasad >> >>> Richard. >>> >>>> >>>> Thanks, >>>> Prasad
undecl_var.patch
Description: Binary data
Changelog
Description: Binary data