aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-04-26 14:36:30 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-04-26 14:36:30 +0000
commitbebf5b1bcfbf591dd3cd80c4aebd6486bb34f41c (patch)
tree986b8fc5afeef78149df9a104df35b2be3cf8e67 /lib/Sema/SemaDeclCXX.cpp
parent4f1d1551ed48e2ac52f5614ba8f94e2931546b51 (diff)
C++1y: support simple variable assignments in constexpr functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180603 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--lib/Sema/SemaDeclCXX.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 5f0908ae93..48860e027b 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -845,7 +845,8 @@ static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl,
<< (VD->getTLSKind() == VarDecl::TLS_Dynamic);
return false;
}
- if (SemaRef.RequireLiteralType(
+ if (!VD->getType()->isDependentType() &&
+ SemaRef.RequireLiteralType(
VD->getLocation(), VD->getType(),
diag::err_constexpr_local_var_non_literal_type,
isa<CXXConstructorDecl>(Dcl)))
@@ -1135,11 +1136,11 @@ bool Sema::CheckConstexprFunctionBody(const FunctionDecl *Dcl, Stmt *Body) {
// statement. We still do, unless the return type is void, because
// otherwise if there's no return statement, the function cannot
// be used in a core constant expression.
+ bool OK = getLangOpts().CPlusPlus1y && Dcl->getResultType()->isVoidType();
Diag(Dcl->getLocation(),
- getLangOpts().CPlusPlus1y && Dcl->getResultType()->isVoidType()
- ? diag::warn_cxx11_compat_constexpr_body_no_return
- : diag::err_constexpr_body_no_return);
- return false;
+ OK ? diag::warn_cxx11_compat_constexpr_body_no_return
+ : diag::err_constexpr_body_no_return);
+ return OK;
}
if (ReturnStmts.size() > 1) {
Diag(ReturnStmts.back(),