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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236005
91177308-0d34-0410-b5e6-
96231b3b80d8
EnterExpressionEvaluationContext EvalContext(*this,
Sema::PotentiallyEvaluated);
- LocalInstantiationScope Scope(*this);
+ LocalInstantiationScope Scope(*this, true);
// Instantiate the initializer.
ActOnStartCXXInClassMemberInitializer();
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();
+ }
+}