Put back the top-level asm code; all tests pass now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46868 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Parse/Parser.cpp b/Parse/Parser.cpp
index 6f2a712..e3208a0 100644
--- a/Parse/Parser.cpp
+++ b/Parse/Parser.cpp
@@ -320,12 +320,15 @@
// FIXME: Restore extension warnings.
return RV;
}
- case tok::kw_asm:
- ParseSimpleAsm();
+ case tok::kw_asm: {
+ ExprResult Result = ParseSimpleAsm();
+
ExpectAndConsume(tok::semi, diag::err_expected_semi_after,
"top-level asm block");
- // TODO: Invoke action for top-level asm.
- return 0;
+
+ if (!Result.isInvalid)
+ return Actions.ActOnFileScopeAsmDecl(Tok.getLocation(), Result.Val);
+ }
case tok::at:
// @ is not a legal token unless objc is enabled, no need to check.
return ParseObjCAtDirectives();
@@ -610,19 +613,21 @@
/// [GNU] simple-asm-expr:
/// 'asm' '(' asm-string-literal ')'
///
-void Parser::ParseSimpleAsm() {
+Parser::ExprResult Parser::ParseSimpleAsm() {
assert(Tok.is(tok::kw_asm) && "Not an asm!");
- ConsumeToken();
+ SourceLocation Loc = ConsumeToken();
if (Tok.isNot(tok::l_paren)) {
Diag(Tok, diag::err_expected_lparen_after, "asm");
- return;
+ return 0;
}
- SourceLocation Loc = ConsumeParen();
+ ConsumeParen();
- ParseAsmStringLiteral();
+ ExprResult Result = ParseAsmStringLiteral();
MatchRHSPunctuation(tok::r_paren, Loc);
+
+ return Result;
}