]> granicus.if.org Git - clang/commitdiff
Fix rejects-valid with default member initializers exposed by r291318.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 10 Jan 2017 08:51:46 +0000 (08:51 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 10 Jan 2017 08:51:46 +0000 (08:51 +0000)
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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291551 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiate.cpp
test/SemaCXX/cxx0x-class.cpp

index ba4a5b7bc0d789cdee348107eb809b5e6ce5a5cb..9f744a1dc1b2cd3959be414164b42c93b8a59adf 100644 (file)
@@ -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();
 }
index 2b1338f97fd776edc04d001c0d4b64d0e671d8a6..8afb0fd6f3c0e71010ecab2e16068ac197568d4f 100644 (file)
@@ -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;
+};