aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.cc
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/tree-cfg.cc
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/tree-cfg.cc')
-rw-r--r--gcc/tree-cfg.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index 9b2c0f6..d982988 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -5300,13 +5300,15 @@ verify_gimple_transaction (gtransaction *stmt)
/* Verify the GIMPLE statements inside the statement list STMTS. */
-DEBUG_FUNCTION void
-verify_gimple_in_seq (gimple_seq stmts)
+DEBUG_FUNCTION bool
+verify_gimple_in_seq (gimple_seq stmts, bool ice)
{
timevar_push (TV_TREE_STMT_VERIFY);
- if (verify_gimple_in_seq_2 (stmts))
+ bool res = verify_gimple_in_seq_2 (stmts);
+ if (res && ice)
internal_error ("%<verify_gimple%> failed");
timevar_pop (TV_TREE_STMT_VERIFY);
+ return res;
}
/* Return true when the T can be shared. */
@@ -5496,8 +5498,8 @@ collect_subblocks (hash_set<tree> *blocks, tree block)
/* Verify the GIMPLE statements in the CFG of FN. */
-DEBUG_FUNCTION void
-verify_gimple_in_cfg (struct function *fn, bool verify_nothrow)
+DEBUG_FUNCTION bool
+verify_gimple_in_cfg (struct function *fn, bool verify_nothrow, bool ice)
{
basic_block bb;
bool err = false;
@@ -5652,11 +5654,13 @@ verify_gimple_in_cfg (struct function *fn, bool verify_nothrow)
eh_table->traverse<hash_set<gimple *> *, verify_eh_throw_stmt_node>
(&visited_throwing_stmts);
- if (err || eh_error_found)
+ if (ice && (err || eh_error_found))
internal_error ("verify_gimple failed");
verify_histograms ();
timevar_pop (TV_TREE_STMT_VERIFY);
+
+ return (err || eh_error_found);
}