[PATCH] Fix PR19876 - Generic lambdas that capture 'this' used within NSDMIs result in a crash

Richard Smith richard at metafoo.co.uk
Thu May 29 20:30:29 PDT 2014


================
Comment at: lib/Sema/SemaExprCXX.cpp:744-750
@@ +743,9 @@
+      // This is a generic lambda call operator that is being instantiated
+      // within an NSDMI - use the enclosing class as 'this'. There is no 
+      // enclosing member function to retrieve the 'this' pointer from.
+      QualType ClassTy = Context.getTypeDeclType(
+          cast<CXXRecordDecl>(CurContext->getParent()->getParent()));
+      // Unlike for within methods, we don't have to worry about adding
+      // CVR qualifications in this context.  Just get the pointer to
+      // the enclosing class.
+      return Context.getPointerType(ClassTy);
----------------
Instead of these comments, I'd say "There are no cv-qualifiers, per [expr.prim.general]p4." Also, please use "default initializer" rather than "NSDMI".

http://reviews.llvm.org/D3935






More information about the cfe-commits mailing list