aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2022-10-19 14:12:11 +0200
committerRichard Biener <rguenther@suse.de>2022-10-20 11:29:28 +0200
commit8e2b5cf7cde999582d1b8fff021faa487c8e34b0 (patch)
treea7c5356d886096ce0bba651011198f1e34f7f0ab /gcc/c
parent5d6e834ecf212e7fc6f585b154af224d2e38c749 (diff)
downloadgcc-8e2b5cf7cde999582d1b8fff021faa487c8e34b0.zip
gcc-8e2b5cf7cde999582d1b8fff021faa487c8e34b0.tar.gz
gcc-8e2b5cf7cde999582d1b8fff021faa487c8e34b0.tar.bz2
c/107305 - avoid ICEing with invalid GIMPLE input to the GIMPLE FE
The GIMPLE FE was designed to defer semantic error checking to the GIMPLE IL verifier. But that can end up causing spurious ICEs earlier and in fact it will report an internal error. The following tries to improve the situation by explicitely calling into the verifier from the parser and intructing it to not ICE but instead zap the parsed body after an error is discovered. PR c/107305 PR c/107306 gcc/c/ * gimple-parser.cc (c_parser_parse_gimple_body): Verify the parsed IL and zap the body on error. gcc/ * tree-cfg.h (verify_gimple_in_seq): Add parameter to indicate whether to emit an ICE. Add return value. (verify_gimple_in_cfg): Likewise. * tree-cfg.cc (verify_gimple_in_seq): Likewise. (verify_gimple_in_cfg): Likewise. gcc/testsuite/ * gcc.dg/gimplefe-error-15.c: New testcase.
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/gimple-parser.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
index 5a2da2c..18ed4d4 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -364,6 +364,16 @@ c_parser_parse_gimple_body (c_parser *cparser, char *gimple_pass,
cgraph_node::get_create (cfun->decl);
cgraph_edge::rebuild_edges ();
}
+
+ /* Perform IL validation and if any error is found abort compilation
+ of this function by zapping its body. */
+ if ((cfun->curr_properties & PROP_cfg)
+ && verify_gimple_in_cfg (cfun, false, false))
+ init_empty_tree_cfg ();
+ else if (!(cfun->curr_properties & PROP_cfg)
+ && verify_gimple_in_seq (gimple_body (current_function_decl), false))
+ gimple_set_body (current_function_decl, NULL);
+
dump_function (TDI_gimple, current_function_decl);
}