summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-07-07 06:00:13 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-07-07 06:00:13 +0000
commit22a5d61b5d3913b5967f5fa43ed4b1764a131a62 (patch)
tree9d49fcb86066603d1c3a4a1171ed3ef77cbdcf83 /clang/lib
parent45d099b995acacb165367edc7f3d77eb3cc8407d (diff)
downloadbcm5719-llvm-22a5d61b5d3913b5967f5fa43ed4b1764a131a62.tar.gz
bcm5719-llvm-22a5d61b5d3913b5967f5fa43ed4b1764a131a62.zip
Add an explicit diagnostic for the case where an expression is not a constant
expression because it uses 'this'. Inspired by PR20219 comment#2. llvm-svn: 212433
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ExprConstant.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 98061e6c494..3e8a0d0dc14 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -4666,8 +4666,13 @@ public:
// Can't look at 'this' when checking a potential constant expression.
if (Info.checkingPotentialConstantExpression())
return false;
- if (!Info.CurrentCall->This)
- return Error(E);
+ if (!Info.CurrentCall->This) {
+ if (Info.getLangOpts().CPlusPlus11)
+ Info.Diag(E, diag::note_constexpr_this) << E->isImplicit();
+ else
+ Info.Diag(E);
+ return false;
+ }
Result = *Info.CurrentCall->This;
return true;
}
OpenPOWER on IntegriCloud