]> granicus.if.org Git - clang/commitdiff
Warn on top-level 'asm volatile' (instead of misparsing it).
authorJohn McCall <rjmccall@apple.com>
Mon, 25 Jan 2010 22:27:48 +0000 (22:27 +0000)
committerJohn McCall <rjmccall@apple.com>
Mon, 25 Jan 2010 22:27:48 +0000 (22:27 +0000)
"Fixes" rdar://problem/7574870

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94458 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/Parser.cpp
test/Sema/asm.c

index c6d06052528537969ebd906ad22cf03a3cc46246..6093282423d990de150522c66a9b9a82a8f68f3f 100644 (file)
@@ -14,6 +14,8 @@
 let Component = "Parse" in {
 
 def w_asm_qualifier_ignored : Warning<"ignored %0 qualifier on asm">;
+def warn_file_asm_volatile : Warning<
+  "meaningless 'volatile' on asm outside function">;
 
 def ext_empty_source_file : Extension<"ISO C forbids an empty source file">;
 def ext_top_level_semi : Extension<
index f2bc303acd698d7f017ffaceafa5f0a792be5662..8ae85e3c26a6d3b14ebae51943599b0b318a7fe2 100644 (file)
@@ -835,6 +835,11 @@ Parser::OwningExprResult Parser::ParseSimpleAsm(SourceLocation *EndLoc) {
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
   SourceLocation Loc = ConsumeToken();
 
+  if (Tok.is(tok::kw_volatile)) {
+    Diag(Tok, diag::warn_file_asm_volatile);
+    ConsumeToken();
+  }
+
   if (Tok.isNot(tok::l_paren)) {
     Diag(Tok, diag::err_expected_lparen_after) << "asm";
     return ExprError();
index 18d900c80dd48c6ac4904dc9cfb585da19d7e953..6f2272da9e775cf6dcb6af55ba8d161930e84c16 100644 (file)
@@ -76,3 +76,6 @@ int test7(unsigned long long b) {
   asm volatile("foo %0 %1" : "=a" (a) :"0" (b)); // expected-error {{input with type 'unsigned long long' matching output with type 'int'}}
   return a;
 }
+
+// <rdar://problem/7574870>
+asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}