Patchwork C++ PATCH for c++/52374 (ICE with call to base memfn in lambda)

login
register
mail settings
Submitter Jason Merrill
Date March 17, 2013, 1:50 a.m.
Message ID <51452152.7030105@redhat.com>
Download mbox | patch
Permalink /patch/228264/
State New
Headers show

Comments

Jason Merrill - March 17, 2013, 1:50 a.m.
A place where we want the enclosing non-lambda class for lookup.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 21c6e4ca4c733fc04f29a6ed30b94af32be53ba7
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 12 22:51:36 2013 -0400

    	PR c++/52374
    	* pt.c (tsubst_qualified_id): Use current_nonlambda_class_type.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 1bbcba2..4274479 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12043,7 +12043,7 @@  tsubst_qualified_id (tree qualified_id, tree args,
   else if (TYPE_P (scope))
     {
       expr = (adjust_result_of_qualified_name_lookup
-	      (expr, scope, current_class_type));
+	      (expr, scope, current_nonlambda_class_type ()));
       expr = (finish_qualified_id_expr
 	      (scope, expr, done, address_p && PTRMEM_OK_P (qualified_id),
 	       QUALIFIED_NAME_IS_TEMPLATE (qualified_id),
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this13.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this13.C
new file mode 100644
index 0000000..090d0a1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this13.C
@@ -0,0 +1,20 @@ 
+// PR c++/52374
+// { dg-do compile { target c++11 } }
+
+struct B
+{
+  int get() const { return 42; }
+};
+
+template<typename X>
+struct D
+  : public X
+{
+  int get() const { return [this]() -> int { return X::get(); }(); }
+};
+
+int main()
+{
+  D<B> d;
+  d.get();
+}