aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaExprCXX.cpp11
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp6
-rw-r--r--lib/Sema/SemaType.cpp3
3 files changed, 16 insertions, 4 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 148dc63944..44f7816798 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -2069,14 +2069,17 @@ Expr *Sema::MaybeCreateCXXExprWithTemporaries(Expr *SubExpr,
bool ShouldDestroyTemps) {
assert(SubExpr && "sub expression can't be null!");
- if (ExprTemporaries.empty())
+ unsigned FirstTemporary = ExprEvalContexts.back().NumTemporaries;
+ assert(ExprTemporaries.size() >= FirstTemporary);
+ if (ExprTemporaries.size() == FirstTemporary)
return SubExpr;
Expr *E = CXXExprWithTemporaries::Create(Context, SubExpr,
- &ExprTemporaries[0],
- ExprTemporaries.size(),
+ &ExprTemporaries[FirstTemporary],
+ ExprTemporaries.size() - FirstTemporary,
ShouldDestroyTemps);
- ExprTemporaries.clear();
+ ExprTemporaries.erase(ExprTemporaries.begin() + FirstTemporary,
+ ExprTemporaries.end());
return E;
}
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 95725bf44f..394f0eee72 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -193,6 +193,11 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
TSK_ImplicitInstantiation);
if (D->getInit()) {
+ if (Var->isStaticDataMember() && !D->isOutOfLine())
+ SemaRef.PushExpressionEvaluationContext(Sema::Unevaluated);
+ else
+ SemaRef.PushExpressionEvaluationContext(Sema::PotentiallyEvaluated);
+
OwningExprResult Init
= SemaRef.SubstExpr(D->getInit(), TemplateArgs);
if (Init.isInvalid())
@@ -235,6 +240,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
} else
SemaRef.AddInitializerToDecl(Sema::DeclPtrTy::make(Var), move(Init),
D->hasCXXDirectInitializer());
+ SemaRef.PopExpressionEvaluationContext();
} else if (!Var->isStaticDataMember() || Var->isOutOfLine())
SemaRef.ActOnUninitializedDecl(Sema::DeclPtrTy::make(Var), false);
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index afce5e33ba..526ab91e9f 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -897,6 +897,9 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
break;
}
+ if (T.isNull())
+ return T;
+
if (T == Context.UndeducedAutoTy) {
int Error = -1;