summaryrefslogtreecommitdiffstats
path: root/clang/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
commit2de5a939e2f1fe6773865af021608ccc368b2418 (patch)
tree219b6a5e88d1e609b92ba989fb42b8c2caf6eb43 /clang/lib/Sema/SemaDeclCXX.cpp
parent9c81833c8dbe3d903d6df71a62c705c06a2f0e9a (diff)
downloadbcm5719-llvm-2de5a939e2f1fe6773865af021608ccc368b2418.tar.gz
bcm5719-llvm-2de5a939e2f1fe6773865af021608ccc368b2418.zip
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
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp5
1 files changed, 3 insertions, 2 deletions
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<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)
OpenPOWER on IntegriCloud