diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-01-18 03:06:12 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-01-18 03:06:12 +0000 |
commit | 9cf080fba3bd8a72e119db43f8a05cf11ce709f0 (patch) | |
tree | da78c23793b9e24a4e8a70ef5bedd06b56525a84 /clang/lib/AST/ExprConstant.cpp | |
parent | 1f4f9ddee8c84213a5f0a249d2f7d34a114dbaff (diff) | |
download | bcm5719-llvm-9cf080fba3bd8a72e119db43f8a05cf11ce709f0.tar.gz bcm5719-llvm-9cf080fba3bd8a72e119db43f8a05cf11ce709f0.zip |
A call to strlen is not a constant expression, even if we're treating it as a
builtin.
llvm-svn: 148374
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 1ad0bc5474b..fc3c5aac01c 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -3891,8 +3891,15 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) { case Builtin::BI__builtin_expect: return Visit(E->getArg(0)); - + case Builtin::BIstrlen: + // A call to strlen is not a constant expression. + if (Info.getLangOpts().CPlusPlus0x) + Info.CCEDiag(E->getExprLoc(), diag::note_constexpr_invalid_function) + << /*isConstexpr*/0 << /*isConstructor*/0 << "'strlen'"; + else + Info.CCEDiag(E->getExprLoc(), diag::note_invalid_subexpr_in_const_expr); + // Fall through. case Builtin::BI__builtin_strlen: // As an extension, we support strlen() and __builtin_strlen() as constant // expressions when the argument is a string literal. |