OLD | NEW |
1 //===--- Parser.cpp - C Language Family Parser ----------------------------===// | 1 //===--- Parser.cpp - C Language Family Parser ----------------------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements the Parser interfaces. | 10 // This file implements the Parser interfaces. |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 // __extension__ silences extension warnings in the subexpression. | 662 // __extension__ silences extension warnings in the subexpression. |
663 ExtensionRAIIObject O(Diags); // Use RAII to do this. | 663 ExtensionRAIIObject O(Diags); // Use RAII to do this. |
664 ConsumeToken(); | 664 ConsumeToken(); |
665 return ParseExternalDeclaration(attrs); | 665 return ParseExternalDeclaration(attrs); |
666 } | 666 } |
667 case tok::kw_asm: { | 667 case tok::kw_asm: { |
668 ProhibitAttributes(attrs); | 668 ProhibitAttributes(attrs); |
669 | 669 |
670 SourceLocation StartLoc = Tok.getLocation(); | 670 SourceLocation StartLoc = Tok.getLocation(); |
671 SourceLocation EndLoc; | 671 SourceLocation EndLoc; |
| 672 |
672 ExprResult Result(ParseSimpleAsm(&EndLoc)); | 673 ExprResult Result(ParseSimpleAsm(&EndLoc)); |
673 | 674 |
| 675 // Check if GNU-style InlineAsm is disabled. |
| 676 // Empty asm string is allowed because it will not introduce |
| 677 // any assembly code. |
| 678 if (!(getLangOpts().GNUAsm || Result.isInvalid())) { |
| 679 const auto *SL = cast<StringLiteral>(Result.get()); |
| 680 if (!SL->getString().trim().empty()) |
| 681 Diag(StartLoc, diag::err_gnu_inline_asm_disabled); |
| 682 } |
| 683 |
674 ExpectAndConsume(tok::semi, diag::err_expected_after, | 684 ExpectAndConsume(tok::semi, diag::err_expected_after, |
675 "top-level asm block"); | 685 "top-level asm block"); |
676 | 686 |
677 if (Result.isInvalid()) | 687 if (Result.isInvalid()) |
678 return DeclGroupPtrTy(); | 688 return DeclGroupPtrTy(); |
679 SingleDecl = Actions.ActOnFileScopeAsmDecl(Result.get(), StartLoc, EndLoc); | 689 SingleDecl = Actions.ActOnFileScopeAsmDecl(Result.get(), StartLoc, EndLoc); |
680 break; | 690 break; |
681 } | 691 } |
682 case tok::at: | 692 case tok::at: |
683 return ParseObjCAtDirectives(); | 693 return ParseObjCAtDirectives(); |
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 Parser::StopAtSemi | Parser::StopBeforeMatch) && | 1963 Parser::StopAtSemi | Parser::StopBeforeMatch) && |
1954 P.Tok.is(Close)) | 1964 P.Tok.is(Close)) |
1955 LClose = P.ConsumeAnyToken(); | 1965 LClose = P.ConsumeAnyToken(); |
1956 return true; | 1966 return true; |
1957 } | 1967 } |
1958 | 1968 |
1959 void BalancedDelimiterTracker::skipToEnd() { | 1969 void BalancedDelimiterTracker::skipToEnd() { |
1960 P.SkipUntil(Close, Parser::StopBeforeMatch); | 1970 P.SkipUntil(Close, Parser::StopBeforeMatch); |
1961 consumeClose(); | 1971 consumeClose(); |
1962 } | 1972 } |
OLD | NEW |