summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2014-03-17 16:39:03 +0000
committerTom Stellard <thomas.stellard@amd.com>2014-03-17 16:39:03 +0000
commitc3d4a4f3335a30bf50a589621112db8d9bab669f (patch)
tree0a80196fbe2e5cd0e9f376d099b596cfc6e85ce4
parent8febe8efbc078b8fb9a4290adb318b57a44aba85 (diff)
downloadclang-c3d4a4f3335a30bf50a589621112db8d9bab669f.tar.gz
clang-c3d4a4f3335a30bf50a589621112db8d9bab669f.tar.bz2
clang-c3d4a4f3335a30bf50a589621112db8d9bab669f.tar.xz
Merging r200954:
------------------------------------------------------------------------ r200954 | richard-llvm | 2014-02-06 15:35:16 -0800 (Thu, 06 Feb 2014) | 9 lines Temporary fix for PR18473: Don't try to evaluate the initializer for a type-dependent variable, even if the initializer isn't value-dependent. This happens for ParenListExprs composed of non-value-dependent subexpressions, for instance. We should really give ParenListExprs (and InitListExprs) the type of the initialized entity if they're used to represent a dependent initialization (and if so, set them to be type-, value- and instantiation-dependent). git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@204050 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExprCXX.cpp13
-rw-r--r--test/SemaCXX/lambda-expressions.cpp17
2 files changed, 22 insertions, 8 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 07e465766b..20118b5712 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -5836,17 +5836,16 @@ static inline bool VariableCanNeverBeAConstantExpression(VarDecl *Var,
assert(DefVD);
if (DefVD->isWeak()) return false;
EvaluatedStmt *Eval = DefVD->ensureEvaluatedStmt();
-
+
Expr *Init = cast<Expr>(Eval->Value);
if (Var->getType()->isDependentType() || Init->isValueDependent()) {
- if (!Init->isValueDependent())
- return !DefVD->checkInitIsICE();
- // FIXME: We might still be able to do some analysis of Init here
- // to conclude that even in a dependent setting, Init can never
- // be a constexpr - but for now admit agnosticity.
+ // FIXME: Teach the constant evaluator to deal with the non-dependent parts
+ // of value-dependent expressions, and use it here to determine whether the
+ // initializer is a potential constant expression.
return false;
- }
+ }
+
return !IsVariableAConstantExpression(Var, Context);
}
diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp
index e2904247c4..65f4856dda 100644
--- a/test/SemaCXX/lambda-expressions.cpp
+++ b/test/SemaCXX/lambda-expressions.cpp
@@ -282,4 +282,19 @@ namespace lambdas_in_NSDMIs {
};
L l;
}
-} \ No newline at end of file
+}
+
+namespace PR18473 {
+ template<typename T> void f() {
+ T t(0);
+ (void) [=]{ int n = t; }; // expected-error {{deleted}}
+ }
+
+ template void f<int>();
+ struct NoCopy {
+ NoCopy(int);
+ NoCopy(const NoCopy &) = delete; // expected-note {{deleted}}
+ operator int() const;
+ };
+ template void f<NoCopy>(); // expected-note {{instantiation}}
+}