diff options
author | Martin Sebor <msebor@redhat.com> | 2021-09-19 17:16:26 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-09-19 17:16:26 -0600 |
commit | c3895ef466f3068cac6f5c18b55716f494484917 (patch) | |
tree | 066ced93767328959c83c7dbe4cc863142b13a05 /gcc/tree-ssa-strlen.c | |
parent | 32731fa5b0abf092029b8e2be64319b978bda514 (diff) | |
download | gcc-c3895ef466f3068cac6f5c18b55716f494484917.zip gcc-c3895ef466f3068cac6f5c18b55716f494484917.tar.gz gcc-c3895ef466f3068cac6f5c18b55716f494484917.tar.bz2 |
Handle null cfun [PR102243].
Resolves:
PR middle-end/102243 - ICE on placement new at global scope
gcc/ChangeLog:
PR middle-end/102243
* tree-ssa-strlen.c (get_range): Handle null cfun.
gcc/testsuite/ChangeLog:
PR middle-end/102243
* g++.dg/warn/Wplacement-new-size-10.C: New test.
Diffstat (limited to 'gcc/tree-ssa-strlen.c')
-rw-r--r-- | gcc/tree-ssa-strlen.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 7c93958..7c568a4 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -199,16 +199,22 @@ static bool handle_assign (gimple_stmt_iterator *, tree, bool *, /* Sets MINMAX to either the constant value or the range VAL is in and returns either the constant value or VAL on success or null - when the range couldn't be determined. Uses RVALS when nonnull - to determine the range, otherwise uses CFUN or global range info, - whichever is nonnull. */ + when the range couldn't be determined. Uses RVALS or CFUN for + range info, whichever is nonnull. */ tree get_range (tree val, gimple *stmt, wide_int minmax[2], range_query *rvals /* = NULL */) { if (!rvals) - rvals = get_range_query (cfun); + { + if (!cfun) + /* When called from front ends for global initializers CFUN + may be null. */ + return NULL_TREE; + + rvals = get_range_query (cfun); + } value_range vr; if (!rvals->range_of_expr (vr, val, stmt)) |