diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2019-08-04 10:08:51 +0000 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2019-08-04 10:08:51 +0000 |
commit | 0778fc61cf6933981705c2258d59ae82e79c9e24 (patch) | |
tree | 7fdede2eec68c95592d2782beffc13cc1527da02 /lib/Parse/ParseDecl.cpp | |
parent | d985828d5afead32e20cb98d117c337f05cc32b9 (diff) | |
download | clang-0778fc61cf6933981705c2258d59ae82e79c9e24.tar.gz |
[Parser] Emit descriptive diagnostic for misplaced pragma
If a class or struct or union declaration contains a pragma that
is not valid in this context, compiler issues generic error like
"expected member name or ';' after declaration specifiers". With this
change the error tells that this pragma cannot appear in this declaration.
Differential Revision: https://reviews.llvm.org/D64932
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367779 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 63a7de454c..5fc36e86b1 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -4148,6 +4148,14 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc, continue; } + if (tok::isPragmaAnnotation(Tok.getKind())) { + Diag(Tok.getLocation(), diag::err_pragma_misplaced_in_decl) + << DeclSpec::getSpecifierName( + TagType, Actions.getASTContext().getPrintingPolicy()); + ConsumeAnnotationToken(); + continue; + } + if (!Tok.is(tok::at)) { auto CFieldCallback = [&](ParsingFieldDeclarator &FD) { // Install the declarator into the current TagDecl. |