summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-09-27 04:14:12 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-09-27 04:14:12 +0000
commitc185aa7d925ea21a08951798bd3980e93d2caf35 (patch)
tree7f4ac6adb3e7b566c0d24ff04842463cff0644f3 /clang/lib
parent61f71c39033d6694937b675878220429f8b3968d (diff)
downloadbcm5719-llvm-c185aa7d925ea21a08951798bd3980e93d2caf35.tar.gz
bcm5719-llvm-c185aa7d925ea21a08951798bd3980e93d2caf35.zip
Sema: Respect -fdelayed-template-parsing when parsing constexpr functions
Functions declared as constexpr must have their parsing delayed in -fdelayed-template-parsing mode so as not to upset later template instantiation. N.B. My reading of the standard makes it seem like delayed template parsing is at odds with constexpr. We may want to make refinements in other places in clang to make constexpr play nicer with this feature. This fixes PR17334. llvm-svn: 191484
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 10ed15a2903..a52ebf6e2f6 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11010,7 +11010,8 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func) {
// However, they cannot be referenced if they are deleted, and they are
// deleted whenever the implicit definition of the special member would
// fail.
- if (!Func->isConstexpr() || Func->getBody())
+ if (!(Func->isConstexpr() && !getLangOpts().DelayedTemplateParsing) ||
+ Func->getBody())
return;
CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Func);
if (!Func->isImplicitlyInstantiable() && (!MD || MD->isUserProvided()))
@@ -11101,13 +11102,14 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func) {
}
}
- if (!AlreadyInstantiated || Func->isConstexpr()) {
+ if (!AlreadyInstantiated ||
+ (Func->isConstexpr() && !getLangOpts().DelayedTemplateParsing)) {
if (isa<CXXRecordDecl>(Func->getDeclContext()) &&
cast<CXXRecordDecl>(Func->getDeclContext())->isLocalClass() &&
ActiveTemplateInstantiations.size())
PendingLocalImplicitInstantiations.push_back(
std::make_pair(Func, PointOfInstantiation));
- else if (Func->isConstexpr())
+ else if (Func->isConstexpr() && !getLangOpts().DelayedTemplateParsing)
// Do not defer instantiations of constexpr functions, to avoid the
// expression evaluator needing to call back into Sema if it sees a
// call to such a function.
OpenPOWER on IntegriCloud