From: Jakub Jelinek Date: Wed, 23 Oct 2019 12:35:00 +0000 (+0200) Subject: constexpr.c (cxx_eval_constant_expression): Temporarily change input_location to... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=acfdb9605f32a99dcbddff5753928dee3932b06b;p=gcc.git constexpr.c (cxx_eval_constant_expression): Temporarily change input_location to CLEANUP_STMT location. * constexpr.c (cxx_eval_constant_expression) : Temporarily change input_location to CLEANUP_STMT location. * g++.dg/cpp2a/constexpr-dtor3.C: Expect in 'constexpr' expansion of message on the line with variable declaration. * g++.dg/ext/constexpr-attr-cleanup1.C: Likewise. From-SVN: r277320 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3da069f8a3c..4295b0c3ed6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-10-23 Jakub Jelinek + + * constexpr.c (cxx_eval_constant_expression) : + Temporarily change input_location to CLEANUP_STMT location. + 2019-10-22 Jakub Jelinek PR tree-optimization/85887 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 2e1b9b76549..11a1eaa0e82 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -4988,14 +4988,20 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, non_constant_p, overflow_p, jump_target); if (!CLEANUP_EH_ONLY (t) && !*non_constant_p) - /* Also evaluate the cleanup. If we weren't skipping at the - start of the CLEANUP_BODY, change jump_target temporarily - to &initial_jump_target, so that even a return or break or - continue in the body doesn't skip the cleanup. */ - cxx_eval_constant_expression (ctx, CLEANUP_EXPR (t), true, - non_constant_p, overflow_p, - jump_target ? &initial_jump_target - : NULL); + { + location_t loc = input_location; + if (EXPR_HAS_LOCATION (t)) + input_location = EXPR_LOCATION (t); + /* Also evaluate the cleanup. If we weren't skipping at the + start of the CLEANUP_BODY, change jump_target temporarily + to &initial_jump_target, so that even a return or break or + continue in the body doesn't skip the cleanup. */ + cxx_eval_constant_expression (ctx, CLEANUP_EXPR (t), true, + non_constant_p, overflow_p, + jump_target ? &initial_jump_target + : NULL); + input_location = loc; + } } break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c578af30ce8..790ffe4bf6d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-10-23 Jakub Jelinek + + * g++.dg/cpp2a/constexpr-dtor3.C: Expect in 'constexpr' expansion of + message on the line with variable declaration. + * g++.dg/ext/constexpr-attr-cleanup1.C: Likewise. + 2019-10-23 Eric Botcazou * gcc.c-torture/execute/20191023-1.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-dtor3.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-dtor3.C index dcfa4e6caf2..d9461836970 100644 --- a/gcc/testsuite/g++.dg/cpp2a/constexpr-dtor3.C +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-dtor3.C @@ -149,7 +149,7 @@ constexpr int x3 = f3 (); constexpr int f4 () { - W7 w13 = 5; + W7 w13 = 5; // { dg-message "in 'constexpr' expansion of" } return 0; } diff --git a/gcc/testsuite/g++.dg/ext/constexpr-attr-cleanup1.C b/gcc/testsuite/g++.dg/ext/constexpr-attr-cleanup1.C index 2c4f61ac44b..b6e7c691367 100644 --- a/gcc/testsuite/g++.dg/ext/constexpr-attr-cleanup1.C +++ b/gcc/testsuite/g++.dg/ext/constexpr-attr-cleanup1.C @@ -15,7 +15,7 @@ cleanup2 (int *x) constexpr bool foo () { - int a __attribute__((cleanup (cleanup))) = 1; + int a __attribute__((cleanup (cleanup))) = 1; // { dg-message "in 'constexpr' expansion of" } return true; }