summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerge Pavlov <sepavloff@gmail.com>2015-04-28 17:58:47 +0000
committerSerge Pavlov <sepavloff@gmail.com>2015-04-28 17:58:47 +0000
commit907233fd99182cf9ca794bec7bc974939dd1c4ed (patch)
tree55f2a328788fa2d08c17db9f7b5a32dc0099fa0f
parent96301d2455e658aae00d99e3ad8ca65abc92a04c (diff)
downloadbcm5719-llvm-907233fd99182cf9ca794bec7bc974939dd1c4ed.tar.gz
bcm5719-llvm-907233fd99182cf9ca794bec7bc974939dd1c4ed.zip
Combine instantiation context of field initializer with context of class.
Inclass initializer is instantiated in its own LocalInstantiationScope. It causes problems when instantiating local classes - when instantiation scope is searched for DeclContext of the field, the search fails. As a solution, the instantiation scope of field initializer is combined with its outer scope. This patch fixes PR23194. Differential Revision: http://reviews.llvm.org/D9258 llvm-svn: 236005
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp2
-rw-r--r--clang/test/SemaTemplate/instantiate-local-class.cpp19
2 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index eec13c581d4..62b506276e6 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2233,7 +2233,7 @@ bool Sema::InstantiateInClassInitializer(
EnterExpressionEvaluationContext EvalContext(*this,
Sema::PotentiallyEvaluated);
- LocalInstantiationScope Scope(*this);
+ LocalInstantiationScope Scope(*this, true);
// Instantiate the initializer.
ActOnStartCXXInClassMemberInitializer();
diff --git a/clang/test/SemaTemplate/instantiate-local-class.cpp b/clang/test/SemaTemplate/instantiate-local-class.cpp
index c9897b9c614..367134a2a53 100644
--- a/clang/test/SemaTemplate/instantiate-local-class.cpp
+++ b/clang/test/SemaTemplate/instantiate-local-class.cpp
@@ -194,3 +194,22 @@ struct B {
void f() { F<int>(); }
};
}
+
+namespace PR23194 {
+ struct X {
+ int operator()() const { return 0; }
+ };
+ struct Y {
+ Y(int) {}
+ };
+ template <bool = true> int make_seed_pair() noexcept {
+ struct state_t {
+ X x;
+ Y y{x()};
+ };
+ return 0;
+ }
+ int func() {
+ return make_seed_pair();
+ }
+}
OpenPOWER on IntegriCloud