public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/autopar_devel] c++: *this capture in const member fn [PR95193].
@ 2020-08-22 21:53 Giuliano Belinassi
  0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-22 21:53 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d5ad367027b215306ea4860b502fd4c42dfd932c

commit d5ad367027b215306ea4860b502fd4c42dfd932c
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jun 1 17:58:57 2020 -0400

    c++: *this capture in const member fn [PR95193].
    
    Here, the capture proxy for *this is const, but its DECL_VALUE_EXPR is not.
    Don't ICE on this; it's a reasonable difference, since in C++ an rvalue of
    scalar type does not have cv-qualifiers.
    
    gcc/cp/ChangeLog:
    
            PR c++/95193
            * pt.c (tsubst_decl): Relax assert.
    
    gcc/testsuite/ChangeLog:
    
            PR c++/95193
            * g++.dg/cpp1z/lambda-this7.C: New test.

Diff:
---
 gcc/cp/pt.c                               |  3 ++-
 gcc/testsuite/g++.dg/cpp1z/lambda-this7.C | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 907ca879c73..9c03c5a5bbd 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -14633,7 +14633,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
 			 && DECL_BIT_FIELD_TYPE (TREE_OPERAND (ve, 1)) == type)
 		  type = TREE_TYPE (ve);
 		else
-		  gcc_checking_assert (TREE_TYPE (ve) == type);
+		  gcc_checking_assert (TYPE_MAIN_VARIANT (TREE_TYPE (ve))
+				       == TYPE_MAIN_VARIANT (type));
 		SET_DECL_VALUE_EXPR (r, ve);
 	      }
 	    if (CP_DECL_THREAD_LOCAL_P (r)
diff --git a/gcc/testsuite/g++.dg/cpp1z/lambda-this7.C b/gcc/testsuite/g++.dg/cpp1z/lambda-this7.C
new file mode 100644
index 00000000000..8137061e161
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/lambda-this7.C
@@ -0,0 +1,11 @@
+// PR c++/95193
+// { dg-do compile { target c++17 } }
+
+struct X {
+  void foo() const {
+    auto GL1 = [*this](auto a) {
+    };
+
+    GL1("abc");
+  }
+};


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-22 21:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 21:53 [gcc/devel/autopar_devel] c++: *this capture in const member fn [PR95193] Giuliano Belinassi

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).