summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-01-10 08:51:46 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-01-10 08:51:46 +0000
commit9451c35982f3373729734d75ffe693b8af4a7ca0 (patch)
tree658461652054a7f1e6c573cf92dd134ef07dfbe8
parente8623b90ae143ec22605d98f39ab9cedcff3158f (diff)
downloadbcm5719-llvm-9451c35982f3373729734d75ffe693b8af4a7ca0.tar.gz
bcm5719-llvm-9451c35982f3373729734d75ffe693b8af4a7ca0.zip
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! llvm-svn: 291551
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp3
-rw-r--r--clang/test/SemaCXX/cxx0x-class.cpp8
2 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index ba4a5b7bc0d..9f744a1dc1b 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/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/clang/test/SemaCXX/cxx0x-class.cpp b/clang/test/SemaCXX/cxx0x-class.cpp
index 2b1338f97fd..8afb0fd6f3c 100644
--- a/clang/test/SemaCXX/cxx0x-class.cpp
+++ b/clang/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<typename> struct DefaultMemberTemplate { int n = 0; };
+class DefaultMemberInitSelf {
+ DefaultMemberTemplate<int> t = {};
+ int *p = &t.n;
+};
OpenPOWER on IntegriCloud