r291551 - Fix rejects-valid with default member initializers exposed by r291318.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 10 00:51:46 PST 2017


Author: rsmith
Date: Tue Jan 10 02:51:46 2017
New Revision: 291551

URL: http://llvm.org/viewvc/llvm-project?rev=291551&view=rev
Log:
Fix rejects-valid with default member initializers exposed by r291318.

Don't prematurely clean up an RAII object; there's another RAII object in the
same scope that tries to save and restore the same member!

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
    cfe/trunk/test/SemaCXX/cxx0x-class.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=291551&r1=291550&r2=291551&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Tue Jan 10 02:51:46 2017
@@ -2264,9 +2264,6 @@ bool Sema::InstantiateInClassInitializer
   if (auto *L = getASTMutationListener())
     L->DefaultMemberInitializerInstantiated(Instantiation);
 
-  // Exit the scope of this instantiation.
-  SavedContext.pop();
-
   // Return true if the in-class initializer is still missing.
   return !Instantiation->getInClassInitializer();
 }

Modified: cfe/trunk/test/SemaCXX/cxx0x-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-class.cpp?rev=291551&r1=291550&r2=291551&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-class.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-class.cpp Tue Jan 10 02:51:46 2017
@@ -37,3 +37,11 @@ namespace Foo {
     int y = x;
   };
 }
+
+// Instantiating another default member initializer while parsing one should
+// not cause us to mess up the 'this' override.
+template<typename> struct DefaultMemberTemplate { int n = 0; };
+class DefaultMemberInitSelf {
+  DefaultMemberTemplate<int> t = {};
+  int *p = &t.n;
+};




More information about the cfe-commits mailing list