aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-01-23 12:43:15 -0500
committerJason Merrill <jason@redhat.com>2020-01-23 13:11:10 -0500
commit6f346913f2a87e26c6095d9fbf3d20f926c5470a (patch)
tree9825df53d5952050b7aa4d91917ca99362e93ebc /gcc/cp/constexpr.c
parent20afdcd36982752ba012960b862e9be7154b1274 (diff)
downloadgcc-6f346913f2a87e26c6095d9fbf3d20f926c5470a.zip
gcc-6f346913f2a87e26c6095d9fbf3d20f926c5470a.tar.gz
gcc-6f346913f2a87e26c6095d9fbf3d20f926c5470a.tar.bz2
c++: Avoid ICE when constant evaluation of __builtin_strchr fails.
If we can't change the argument to &"...", use the original arg instead of the partially munged one. PR c++/93331 - ICE with __builtin_strchr. * constexpr.c (cxx_eval_builtin_function_call): Use the original argument if we didn't manage to extract a STRING_CST.
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r--gcc/cp/constexpr.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 5864b67..f6b8f33 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1293,6 +1293,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
for (i = 0; i < nargs; ++i)
{
tree arg = CALL_EXPR_ARG (t, i);
+ tree oarg = arg;
/* To handle string built-ins we need to pass ADDR_EXPR<STRING_CST> since
expand_builtin doesn't know how to look in the values table. */
@@ -1327,6 +1328,8 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
arg = braced_lists_to_strings (TREE_TYPE (arg), arg);
if (TREE_CODE (arg) == STRING_CST)
arg = build_address (arg);
+ else
+ arg = oarg;
}
args[i] = arg;