]> granicus.if.org Git - clang/commitdiff
Several cleanups surrounding Parser::ParseAsmStatement() and Parser::FuzzyParseMicros...
authorSteve Naroff <snaroff@apple.com>
Mon, 11 Feb 2008 23:15:56 +0000 (23:15 +0000)
committerSteve Naroff <snaroff@apple.com>
Mon, 11 Feb 2008 23:15:56 +0000 (23:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46977 91177308-0d34-0410-b5e6-96231b3b80d8

Parse/ParseDecl.cpp
Parse/ParseStmt.cpp
include/clang/Parse/Parser.h

index ea12a7c120c07c3a6bc0581e0e99fb5005a063fa..3b6e04d84f471bccf802b19c8e4c00d89aa189fe 100644 (file)
@@ -871,6 +871,19 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, DeclTy *EnumDecl) {
     AttrList = ParseAttributes(); // FIXME: where do they do?
 }
 
+/// isTypeSpecifierQualifier - Return true if the current token could be the
+/// start of a type-qualifier-list.
+bool Parser::isTypeQualifier() const {
+  switch (Tok.getKind()) {
+  default: return false;
+    // type-qualifier
+  case tok::kw_const:
+  case tok::kw_volatile:
+  case tok::kw_restrict:
+    return true;
+  }
+}
+
 /// isTypeSpecifierQualifier - Return true if the current token could be the
 /// start of a specifier-qualifier-list.
 bool Parser::isTypeSpecifierQualifier() const {
index db91f0dec7e2124b7c04b6244f50934fadb42d46..389d5d4a54db44f7e3cecb4b625a5db47eb313bd 100644 (file)
@@ -911,6 +911,8 @@ Parser::StmtResult Parser::ParseReturnStatement() {
   return Actions.ActOnReturnStmt(ReturnLoc, R.Val);
 }
 
+/// FuzzyParseMicrosoftAsmStatement. When -fms-extensions is enabled, this
+/// routine is called to skip/ignore tokens that comprise the MS asm statement.
 Parser::StmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
   if (Tok.is(tok::l_brace)) {
     unsigned short savedBraceCount = BraceCount;
@@ -934,7 +936,11 @@ Parser::StmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
 }
 
 /// ParseAsmStatement - Parse a GNU extended asm statement.
-/// [GNU] asm-statement:
+///       asm-statement:
+///         gnu-asm-statement
+///         ms-asm-statement
+///
+/// [GNU] gnu-asm-statement:
 ///         'asm' type-qualifier[opt] '(' asm-argument ')' ';'
 ///
 /// [GNU] asm-argument:
@@ -948,11 +954,19 @@ Parser::StmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
 ///         asm-string-literal
 ///         asm-clobbers ',' asm-string-literal
 ///
+/// [MS]  ms-asm-statement:
+///         '__asm' assembly-instruction ';'[opt]
+///         '__asm' '{' assembly-instruction-list '}' ';'[opt]
+///
+/// [MS]  assembly-instruction-list:
+///         assembly-instruction ';'[opt]
+///         assembly-instruction-list ';' assembly-instruction ';'[opt]
+///
 Parser::StmtResult Parser::ParseAsmStatement(bool &msAsm) {
   assert(Tok.is(tok::kw_asm) && "Not an asm stmt");
   SourceLocation AsmLoc = ConsumeToken();
   
-  if (getLang().Microsoft && Tok.isNot(tok::l_paren)) {
+  if (getLang().Microsoft && Tok.isNot(tok::l_paren) && !isTypeQualifier()) {
     msAsm = true;
     return FuzzyParseMicrosoftAsmStatement();
   }
index 907d7ac3ea5bfb398e1bb437ce48e76b5d73e5c6..a12f52cb4a60438a1dd2048d7358f0441292e3b2 100644 (file)
@@ -439,6 +439,7 @@ private:
                               
   bool isDeclarationSpecifier() const;
   bool isTypeSpecifierQualifier() const;
+  bool isTypeQualifier() const;
 
   TypeTy *ParseTypeName();
   AttributeList *ParseAttributes();