From 2bc69213d992f10441ec43d78152e9e200d08720 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 10 Jan 2017 08:51:46 +0000 Subject: [PATCH] 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291551 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplateInstantiate.cpp | 3 --- test/SemaCXX/cxx0x-class.cpp | 8 ++++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index ba4a5b7bc0..9f744a1dc1 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -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(); } diff --git a/test/SemaCXX/cxx0x-class.cpp b/test/SemaCXX/cxx0x-class.cpp index 2b1338f97f..8afb0fd6f3 100644 --- a/test/SemaCXX/cxx0x-class.cpp +++ b/test/SemaCXX/cxx0x-class.cpp @@ -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 struct DefaultMemberTemplate { int n = 0; }; +class DefaultMemberInitSelf { + DefaultMemberTemplate t = {}; + int *p = &t.n; +}; -- 2.50.1