diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-01-17 03:11:34 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-01-17 03:11:34 +0000 |
commit | 741081708eb7aa6ec02e348e1e2edfba8cb7d035 (patch) | |
tree | ae31ba53547393854609093df256c6e00a295ffa /clang/lib/Sema/SemaDeclCXX.cpp | |
parent | 2c6b449098dc0047f4697b2f822a7c7e56c32f43 (diff) | |
download | bcm5719-llvm-741081708eb7aa6ec02e348e1e2edfba8cb7d035.tar.gz bcm5719-llvm-741081708eb7aa6ec02e348e1e2edfba8cb7d035.zip |
PR18477: Create a function scope representing the constructor call when
handling C++11 default initializers. Without this, other parts of Sema (such as
lambda capture) would think the default initializer is part of the surrounding
function scope.
llvm-svn: 199453
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c774f25241b..608f11ceff8 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2343,13 +2343,24 @@ namespace { } } // namespace -/// ActOnCXXInClassMemberInitializer - This is invoked after parsing an -/// in-class initializer for a non-static C++ class member, and after -/// instantiating an in-class initializer in a class template. Such actions -/// are deferred until the class is complete. -void -Sema::ActOnCXXInClassMemberInitializer(Decl *D, SourceLocation InitLoc, - Expr *InitExpr) { +/// \brief Enter a new C++ default initializer scope. After calling this, the +/// caller must call \ref ActOnFinishCXXInClassMemberInitializer, even if +/// parsing or instantiating the initializer failed. +void Sema::ActOnStartCXXInClassMemberInitializer() { + // Create a synthetic function scope to represent the call to the constructor + // that notionally surrounds a use of this initializer. + PushFunctionScope(); +} + +/// \brief This is invoked after parsing an in-class initializer for a +/// non-static C++ class member, and after instantiating an in-class initializer +/// in a class template. Such actions are deferred until the class is complete. +void Sema::ActOnFinishCXXInClassMemberInitializer(Decl *D, + SourceLocation InitLoc, + Expr *InitExpr) { + // Pop the notional constructor scope we created earlier. + PopFunctionScopeInfo(0, D); + FieldDecl *FD = cast<FieldDecl>(D); assert(FD->getInClassInitStyle() != ICIS_NoInit && "must set init style when field is created"); |