diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-07-18 05:43:12 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-07-18 05:43:12 +0000 |
commit | 2e49830b3dc01f679ac21c4059b26257c42f22f8 (patch) | |
tree | 6d80e9f7f79d7b79fc465cf33f9b24194d3af576 /clang/lib | |
parent | a5d2a49c342b82fe706bd05f931c48dee0f69420 (diff) | |
download | bcm5719-llvm-2e49830b3dc01f679ac21c4059b26257c42f22f8.tar.gz bcm5719-llvm-2e49830b3dc01f679ac21c4059b26257c42f22f8.zip |
Parse: Diagnose malformed 'message' arguments for 'availability' attr
The parsing code for 'availability' wasn't prepared for string literals
like "a" L"b" showing up. Error if this occurs.
llvm-svn: 213350
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 71b37527fd2..74df162b0b3 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -825,13 +825,24 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability, } ConsumeToken(); if (Keyword == Ident_message) { - if (Tok.isNot(tok::string_literal)) { // Also reject wide string literals. + if (Tok.isNot(tok::string_literal)) { Diag(Tok, diag::err_expected_string_literal) << /*Source='availability attribute'*/2; SkipUntil(tok::r_paren, StopAtSemi); return; } MessageExpr = ParseStringLiteralExpression(); + // Also reject wide string literals. + if (StringLiteral *MessageStringLiteral = + cast_or_null<StringLiteral>(MessageExpr.get())) { + if (MessageStringLiteral->getCharByteWidth() != 1) { + Diag(MessageStringLiteral->getSourceRange().getBegin(), + diag::err_expected_string_literal) + << /*Source='availability attribute'*/ 2; + SkipUntil(tok::r_paren, StopAtSemi); + return; + } + } break; } |