[cfe-commits] r145656 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/Parser.cpp test/Parser/asm.c
Ted Kremenek
kremenek at apple.com
Thu Dec 1 16:35:47 PST 2011
Author: kremenek
Date: Thu Dec 1 18:35:46 2011
New Revision: 145656
URL: http://llvm.org/viewvc/llvm-project?rev=145656&view=rev
Log:
Diagnose use of wide string literal in 'asm' instead of crashing. Fixes <rdar://problem/10465079>.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/test/Parser/asm.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=145656&r1=145655&r2=145656&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Dec 1 18:35:46 2011
@@ -191,6 +191,8 @@
def err_address_of_label_outside_fn : Error<
"use of address-of-label extension outside of a function body">;
def err_expected_string_literal : Error<"expected string literal">;
+def err_asm_operand_wide_string_literal : Error<
+ "cannot use wide string literal in 'asm'">;
def err_expected_asm_operand : Error<
"expected string literal or '[' for asm operand">, CatInlineAsm;
def err_expected_selector_for_method : Error<
Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=145656&r1=145655&r2=145656&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Thu Dec 1 18:35:46 2011
@@ -1104,16 +1104,23 @@
/// string-literal
///
Parser::ExprResult Parser::ParseAsmStringLiteral() {
- if (!isTokenStringLiteral()) {
- Diag(Tok, diag::err_expected_string_literal);
- return ExprError();
+ switch (Tok.getKind()) {
+ case tok::string_literal:
+ break;
+ case tok::wide_string_literal: {
+ SourceLocation L = Tok.getLocation();
+ Diag(Tok, diag::err_asm_operand_wide_string_literal)
+ << SourceRange(L, L);
+ return ExprError();
+ }
+ default:
+ Diag(Tok, diag::err_expected_string_literal);
+ return ExprError();
}
ExprResult Res(ParseStringLiteralExpression());
if (Res.isInvalid()) return move(Res);
- // TODO: Diagnose: wide string literal in 'asm'
-
return move(Res);
}
Modified: cfe/trunk/test/Parser/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/asm.c?rev=145656&r1=145655&r2=145656&view=diff
==============================================================================
--- cfe/trunk/test/Parser/asm.c (original)
+++ cfe/trunk/test/Parser/asm.c Thu Dec 1 18:35:46 2011
@@ -14,3 +14,6 @@
// rdar://5952468
__asm ; // expected-error {{expected '(' after 'asm'}}
+// <rdar://problem/10465079> - Don't crash on wide string literals in 'asm'.
+int foo asm (L"bar"); // expected-error {{cannot use wide string literal in 'asm'}}
+
More information about the cfe-commits
mailing list