diff options
author | Alexandre Oliva <oliva@adacore.com> | 2022-04-11 12:11:09 -0300 |
---|---|---|
committer | Alexandre Oliva <oliva@gnu.org> | 2022-04-11 12:11:09 -0300 |
commit | 5ce08ecb15b2501abea7215e3fc59646ef7a73f9 (patch) | |
tree | e328283de9045ba3cd21877efe8422873ff00e65 | |
parent | 396a013a5857f85d878993eda32fb2df689bb8e8 (diff) | |
download | gcc-5ce08ecb15b2501abea7215e3fc59646ef7a73f9.zip gcc-5ce08ecb15b2501abea7215e3fc59646ef7a73f9.tar.gz gcc-5ce08ecb15b2501abea7215e3fc59646ef7a73f9.tar.bz2 |
c++: Tolerate cdtors returning this in constexpr
On targets that return this from cdtors, cxx_eval_call_expression may
flag flowing off the end of a dtor. That's preempted for ctors, and
avoided entirely when dtors return void, but when they return this,
the return value should be conceptually disregarded, without making
room for such internal ABI details to make a program ill-formed, as in
g++.dg/cpp2a/constexpr-dtor12.C on arm-eabi.
for gcc/cp/ChangeLog
* constexpr.cc (cxx_eval_call_expression): Disregard dtor
result.
-rw-r--r-- | gcc/cp/constexpr.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index db78b4a..1ce1842 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -2889,7 +2889,8 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, else { result = *ctx->global->values.get (res); - if (result == NULL_TREE && !*non_constant_p) + if (result == NULL_TREE && !*non_constant_p + && !DECL_DESTRUCTOR_P (fun)) { if (!ctx->quiet) error ("%<constexpr%> call flows off the end " |