public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ibm/heads/gcc-9)] c++: Unshare expressions from constexpr cache.
@ 2020-02-04 21:16 Peter Bergner
0 siblings, 0 replies; only message in thread
From: Peter Bergner @ 2020-02-04 21:16 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a4b7cf5865823df4b4df1d840d692dfc83fd0672
commit a4b7cf5865823df4b4df1d840d692dfc83fd0672
Author: Jason Merrill <jason@redhat.com>
Date: Thu Jan 23 15:45:36 2020 -0500
c++: Unshare expressions from constexpr cache.
Another place we need to unshare cached expressions.
PR c++/92852 - ICE with generic lambda and reference var.
* constexpr.c (maybe_constant_value): Likewise.
Diff:
---
gcc/cp/ChangeLog | 5 +++++
gcc/cp/constexpr.c | 2 +-
gcc/testsuite/g++.dg/cpp1y/lambda-generic-ref1.C | 12 ++++++++++++
gcc/testsuite/g++.dg/cpp1z/decomp48.C | 8 ++++----
4 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b3008ff..9961a6f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-24 Jason Merrill <jason@redhat.com>
+
+ PR c++/92852 - ICE with generic lambda and reference var.
+ * constexpr.c (maybe_constant_value): Likewise.
+
2020-01-22 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index e2ca305..f0d4cb5 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -5582,7 +5582,7 @@ maybe_constant_value (tree t, tree decl, bool manifestly_const_eval)
if (cv_cache == NULL)
cv_cache = hash_map<tree, tree>::create_ggc (101);
if (tree *cached = cv_cache->get (t))
- return *cached;
+ return unshare_expr_without_location (*cached);
r = cxx_eval_outermost_constant_expr (t, true, true, false, decl);
gcc_checking_assert (r == t
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ref1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ref1.C
new file mode 100644
index 0000000..a96fa1c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ref1.C
@@ -0,0 +1,12 @@
+// PR c++/92852
+// { dg-do compile { target c++14 } }
+
+struct S { int operator<<(const int &); } glob;
+void foo()
+{
+ S& message_stream = glob;
+ auto format = [&message_stream](auto && x)
+ { message_stream << x ; };
+ format(3);
+ format(4u);
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp48.C b/gcc/testsuite/g++.dg/cpp1z/decomp48.C
index 3c50b02..35413c7 100644
--- a/gcc/testsuite/g++.dg/cpp1z/decomp48.C
+++ b/gcc/testsuite/g++.dg/cpp1z/decomp48.C
@@ -18,7 +18,7 @@ f2 ()
{
S v {1, 2};
auto& [s, t] = v; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
- return s; // { dg-warning "reference to local variable 'v' returned" "" { target *-*-* } .-1 }
+ return s; // { dg-warning "reference to local variable 'v' returned" }
}
int &
@@ -33,7 +33,7 @@ f4 ()
{
int a[3] = {1, 2, 3};
auto& [s, t, u] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
- return s; // { dg-warning "reference to local variable 'a' returned" "" { target *-*-* } .-1 }
+ return s; // { dg-warning "reference to local variable 'a' returned" }
}
int &
@@ -78,7 +78,7 @@ f10 ()
{
S v {1, 2};
auto& [s, t] = v; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
- return &s; // { dg-warning "address of local variable 'v' returned" "" { target *-*-* } .-1 }
+ return &s; // { dg-warning "address of local variable 'v' returned" }
}
int *
@@ -93,7 +93,7 @@ f12 ()
{
int a[3] = {1, 2, 3};
auto& [s, t, u] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
- return &s; // { dg-warning "address of local variable 'a' returned" "" { target *-*-* } .-1 }
+ return &s; // { dg-warning "address of local variable 'a' returned" }
}
int *
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-02-04 21:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 21:16 [gcc(refs/vendors/ibm/heads/gcc-9)] c++: Unshare expressions from constexpr cache Peter Bergner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).