aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-10-23 14:35:00 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2019-10-23 14:35:00 +0200
commitacfdb9605f32a99dcbddff5753928dee3932b06b (patch)
tree82fdc942d3d842fd493e527840f3a3c0365cb962 /gcc
parent149a3e4d4e3aacdbfee165f0efea4d6327327265 (diff)
downloadgcc-acfdb9605f32a99dcbddff5753928dee3932b06b.zip
gcc-acfdb9605f32a99dcbddff5753928dee3932b06b.tar.gz
gcc-acfdb9605f32a99dcbddff5753928dee3932b06b.tar.bz2
constexpr.c (cxx_eval_constant_expression): Temporarily change input_location to CLEANUP_STMT location.
* constexpr.c (cxx_eval_constant_expression) <case CLEANUP_STMT>: 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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/constexpr.c22
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/constexpr-dtor3.C2
-rw-r--r--gcc/testsuite/g++.dg/ext/constexpr-attr-cleanup1.C2
5 files changed, 27 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3da069f..4295b0c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-23 Jakub Jelinek <jakub@redhat.com>
+
+ * constexpr.c (cxx_eval_constant_expression) <case CLEANUP_STMT>:
+ Temporarily change input_location to CLEANUP_STMT location.
+
2019-10-22 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/85887
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 2e1b9b7..11a1eaa 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 c578af3..790ffe4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2019-10-23 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <ebotcazou@adacore.com>
* 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 dcfa4e6..d946183 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 2c4f61a..b6e7c69 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;
}