r236005 - Combine instantiation context of field initializer with context of class.
Serge Pavlov
sepavloff at gmail.com
Tue Apr 28 10:58:47 PDT 2015
Author: sepavloff
Date: Tue Apr 28 12:58:47 2015
New Revision: 236005
URL: http://llvm.org/viewvc/llvm-project?rev=236005&view=rev
Log:
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
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=236005&r1=236004&r2=236005&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Tue Apr 28 12:58:47 2015
@@ -2233,7 +2233,7 @@ bool Sema::InstantiateInClassInitializer
EnterExpressionEvaluationContext EvalContext(*this,
Sema::PotentiallyEvaluated);
- LocalInstantiationScope Scope(*this);
+ LocalInstantiationScope Scope(*this, true);
// Instantiate the initializer.
ActOnStartCXXInClassMemberInitializer();
Modified: cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp?rev=236005&r1=236004&r2=236005&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp Tue Apr 28 12:58:47 2015
@@ -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();
+ }
+}
More information about the cfe-commits
mailing list