aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 3c73f689e7..de9feccaf3 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3991,15 +3991,8 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
TemplateParamLists.release());
}
- if (D.getDeclSpec().isConstexprSpecified()) {
+ if (D.getDeclSpec().isConstexprSpecified())
NewVD->setConstexpr(true);
- SourceLocation ConstexprLoc = D.getDeclSpec().getConstexprSpecLoc();
- if (!NewVD->isInvalidDecl() && !R->isDependentType() &&
- RequireLiteralType(NewVD->getLocation(), R,
- PDiag(diag::err_constexpr_var_non_literal)
- << SourceRange(ConstexprLoc)))
- NewVD->setInvalidDecl();
- }
}
// Set the lexical context. If the declarator has a C++ scope specifier, the
@@ -4347,6 +4340,13 @@ bool Sema::CheckVariableDeclaration(VarDecl *NewVD,
return false;
}
+ if (NewVD->isConstexpr() && !T->isDependentType() &&
+ RequireLiteralType(NewVD->getLocation(), T,
+ PDiag(diag::err_constexpr_var_non_literal))) {
+ NewVD->setInvalidDecl();
+ return false;
+ }
+
if (!Previous.empty()) {
MergeVarDecl(NewVD, Previous);
return true;