aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-02-05 02:30:54 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-02-05 02:30:54 +0000
commitd79093af384ac0ea78f4237a001eae7467e06a61 (patch)
tree0cd1893ec8167f9049d92f4f498aec38e12aac8d /lib/Sema/SemaDeclCXX.cpp
parent94010695f7fce626e41ef045b60def9c912e9ce8 (diff)
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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--lib/Sema/SemaDeclCXX.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index a52d44c4f2..10883af4b4 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/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<CXXTryStmt>(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<PartialDiagnosticAt, 8> 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<CXXConstructorDecl>(Dcl);
for (size_t I = 0, N = Diags.size(); I != N; ++I)