diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-05 23:20:05 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-05 23:20:05 +0000 |
commit | f506eaf36dd8f2c54082e8278857f2f47e90488a (patch) | |
tree | 080029d3c68dde45ab111e34e3a07515ef216d1e /clang/lib/Sema/SemaDeclCXX.cpp | |
parent | 8dc347fc270cf063fb3368b39d140b2664ee9b46 (diff) | |
download | bcm5719-llvm-f506eaf36dd8f2c54082e8278857f2f47e90488a.tar.gz bcm5719-llvm-f506eaf36dd8f2c54082e8278857f2f47e90488a.zip |
static_assert: Allow any string-literal as the message, not just a character
string literal, and adjust the diagnostic code to match. This also causes us
to escape any control characters in the message.
llvm-svn: 152069
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index b603b64bda9..abcaf983572 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -9646,9 +9646,13 @@ Decl *Sema::ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, /*AllowFold=*/false).isInvalid()) return 0; - if (!Cond) + if (!Cond) { + llvm::SmallString<256> MsgBuffer; + llvm::raw_svector_ostream Msg(MsgBuffer); + AssertMessage->printPretty(Msg, Context, 0, getPrintingPolicy()); Diag(StaticAssertLoc, diag::err_static_assert_failed) - << AssertMessage->getString() << AssertExpr->getSourceRange(); + << Msg.str() << AssertExpr->getSourceRange(); + } } if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression)) |