constexpr.c (cxx_eval_constant_expression): Temporarily change input_location to...
authorJakub Jelinek <jakub@redhat.com>
Wed, 23 Oct 2019 12:35:00 +0000 (14:35 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 23 Oct 2019 12:35:00 +0000 (14:35 +0200)
* 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

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/constexpr-dtor3.C
gcc/testsuite/g++.dg/ext/constexpr-attr-cleanup1.C

index 3da069f8a3ce8499dba105f44784a6bfa5a9bfa2..4295b0c3ed6319490cc697fd82442f6f750ffda0 100644 (file)
@@ -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
index 2e1b9b765491772cd35ad409ecd09351afde42a2..11a1eaa0e82a3acdd2df33e0152b9c7a393fb1d8 100644 (file)
@@ -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;
 
index c578af30ce825b8229a188fecba2aa909fe9cd8d..790ffe4bf6d10f8bc86e6d4114d459a72d9f751d 100644 (file)
@@ -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.
index dcfa4e6caf28776d894c10cf2b04b42e93f73df6..d9461836970760f4e5bee4490c060983b9d9fe83 100644 (file)
@@ -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;
 }
 
index 2c4f61ac44bb89044eb399798cdedd9ba9b32c97..b6e7c6913673bd65a7dc03c50b4c87b42bc82d94 100644 (file)
@@ -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;
 }