summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-04-22 23:14:23 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-04-22 23:14:23 +0000
commit06ffb45ce4b0ec32567a2e64eeb69c07a8d4d358 (patch)
tree980284f318e5876a75836c4e8f5719875cd32f84 /clang/lib/Sema/SemaDeclCXX.cpp
parent637cac42edf5405cd8ef5556319cbb4c303f6d63 (diff)
downloadbcm5719-llvm-06ffb45ce4b0ec32567a2e64eeb69c07a8d4d358.tar.gz
bcm5719-llvm-06ffb45ce4b0ec32567a2e64eeb69c07a8d4d358.zip
PR18746: If a constexpr function has a dependent return type and no return
statements, don't diagnose; the return type might end up being 'void'. Patch by Rahul Jain! Tiny tweaks by me. llvm-svn: 206929
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 96c63601148..197518f99ef 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1175,10 +1175,12 @@ bool Sema::CheckConstexprFunctionBody(const FunctionDecl *Dcl, Stmt *Body) {
} else {
if (ReturnStmts.empty()) {
// C++1y doesn't require constexpr functions to contain a 'return'
- // statement. We still do, unless the return type is void, because
+ // statement. We still do, unless the return type might be void, because
// otherwise if there's no return statement, the function cannot
// be used in a core constant expression.
- bool OK = getLangOpts().CPlusPlus1y && Dcl->getReturnType()->isVoidType();
+ bool OK = getLangOpts().CPlusPlus1y &&
+ (Dcl->getReturnType()->isVoidType() ||
+ Dcl->getReturnType()->isDependentType());
Diag(Dcl->getLocation(),
OK ? diag::warn_cxx11_compat_constexpr_body_no_return
: diag::err_constexpr_body_no_return);
OpenPOWER on IntegriCloud