From 2de5a939e2f1fe6773865af021608ccc368b2418 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 5 Feb 2012 02:30:54 +0000 Subject: constexpr: Implement DR1358: An instantiation of a constexpr function which can't produce a constant expression is not ill-formed (so long as some instantiation of that function can produce a constant expression). llvm-svn: 149802 --- clang/lib/Sema/SemaDeclCXX.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'clang/lib/Sema/SemaDeclCXX.cpp') diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index a52d44c4f2e..10883af4b41 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -837,7 +837,8 @@ static void CheckConstexprCtorInitializer(Sema &SemaRef, /// the permitted types of statement. C++11 [dcl.constexpr]p3,p4. /// /// \return true if the body is OK, false if we have diagnosed a problem. -bool Sema::CheckConstexprFunctionBody(const FunctionDecl *Dcl, Stmt *Body) { +bool Sema::CheckConstexprFunctionBody(const FunctionDecl *Dcl, Stmt *Body, + bool IsInstantiation) { if (isa(Body)) { // C++11 [dcl.constexpr]p3: // The definition of a constexpr function shall satisfy the following @@ -989,7 +990,7 @@ bool Sema::CheckConstexprFunctionBody(const FunctionDecl *Dcl, Stmt *Body) { // can't produce constant expressions. llvm::SmallVector Diags; if (!Context.getSourceManager().isInSystemHeader(Dcl->getLocation()) && - !Expr::isPotentialConstantExpr(Dcl, Diags)) { + !IsInstantiation && !Expr::isPotentialConstantExpr(Dcl, Diags)) { Diag(Dcl->getLocation(), diag::err_constexpr_function_never_constant_expr) << isa(Dcl); for (size_t I = 0, N = Diags.size(); I != N; ++I) -- cgit v1.2.3