aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/Parser.cpp
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2020-03-12 15:13:55 -0700
committerNick Desaulniers <ndesaulniers@google.com>2020-03-12 15:13:59 -0700
commit246398ece7115b57a02dbe7876d86ae8e72406ef (patch)
treeb54b63c2512e390ddaedf52892778f6f17b3a2d5 /clang/lib/Parse/Parser.cpp
parenta73528649c85dabbe22fbd27ee6e1d65bbabad14 (diff)
downloadllvm-246398ece7115b57a02dbe7876d86ae8e72406ef.zip
llvm-246398ece7115b57a02dbe7876d86ae8e72406ef.tar.gz
llvm-246398ece7115b57a02dbe7876d86ae8e72406ef.tar.bz2
[clang][Parse] properly parse asm-qualifiers, asm inline
Summary: The parsing of GNU C extended asm statements was a little brittle and had a few issues: - It was using Parse::ParseTypeQualifierListOpt to parse the `volatile` qualifier. That parser is really meant for TypeQualifiers; an asm statement doesn't really have a type qualifier. This is still maybe nice to have, but not necessary. We now can check for the `volatile` token by properly expanding the grammer, rather than abusing Parse::ParseTypeQualifierListOpt. - The parsing of `goto` was position dependent, so `asm goto volatile` wouldn't parse. The qualifiers should be position independent to one another. Now they are. - We would warn on duplicate `volatile`, but the parse error for duplicate `goto` was a generic parse error and wasn't clear. - We need to add support for the recent GNU C extension `asm inline`. Adding support to the parser with the above issues highlighted the need for this refactoring. Link: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: aheejin, jfb, nathanchance, cfe-commits, echristo, efriedma, rsmith, chandlerc, craig.topper, erichkeane, jyu2, void, srhines Tags: #clang Differential Revision: https://reviews.llvm.org/D75563
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r--clang/lib/Parse/Parser.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index ffe31f8..27cb8a2 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -1529,13 +1529,13 @@ ExprResult Parser::ParseSimpleAsm(bool ForAsmLabel, SourceLocation *EndLoc) {
assert(Tok.is(tok::kw_asm) && "Not an asm!");
SourceLocation Loc = ConsumeToken();
- if (Tok.is(tok::kw_volatile)) {
- // Remove from the end of 'asm' to the end of 'volatile'.
+ if (isGNUAsmQualifier(Tok)) {
+ // Remove from the end of 'asm' to the end of the asm qualifier.
SourceRange RemovalRange(PP.getLocForEndOfToken(Loc),
PP.getLocForEndOfToken(Tok.getLocation()));
-
- Diag(Tok, diag::warn_file_asm_volatile)
- << FixItHint::CreateRemoval(RemovalRange);
+ Diag(Tok, diag::err_global_asm_qualifier_ignored)
+ << GNUAsmQualifiers::getQualifierName(getGNUAsmQualifier(Tok))
+ << FixItHint::CreateRemoval(RemovalRange);
ConsumeToken();
}