diff options
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 942c1bc5c2..f4b6ce92e5 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4770,15 +4770,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // are implicitly inline. NewFD->setImplicitlyInline(); - // FIXME: If this is a redeclaration, check the original declaration was - // marked constepr. - // C++0x [dcl.constexpr]p3: functions declared constexpr are required to // be either constructors or to return a literal type. Therefore, // destructors cannot be declared constexpr. if (isa<CXXDestructorDecl>(NewFD)) - Diag(D.getDeclSpec().getConstexprSpecLoc(), - diag::err_constexpr_dtor); + Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_constexpr_dtor); } // If __module_private__ was specified, mark the function accordingly. @@ -5050,6 +5046,10 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, Previous.getResultKind() != LookupResult::FoundOverloaded) && "previous declaration set still overloaded"); + if (NewFD->isConstexpr() && !NewFD->isInvalidDecl() && + !CheckConstexprFunctionDecl(NewFD, CCK_Declaration)) + NewFD->setInvalidDecl(); + NamedDecl *PrincipalDecl = (FunctionTemplate ? cast<NamedDecl>(FunctionTemplate) : NewFD); @@ -6963,6 +6963,10 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, ActivePolicy = &WP; } + if (FD && FD->isConstexpr() && !FD->isInvalidDecl() && + !CheckConstexprFunctionBody(FD, Body)) + FD->setInvalidDecl(); + assert(ExprTemporaries.empty() && "Leftover temporaries in function"); assert(!ExprNeedsCleanups && "Unaccounted cleanups in function"); } |