diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2015-03-25 00:53:27 +0000 |
---|---|---|
committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2015-03-25 00:53:27 +0000 |
commit | 93ed5cf5e62e828248ec80ba3a032df1d2159fdc (patch) | |
tree | 11e764899f5471726487b27477e05f56fb75173b /clang/include | |
parent | d811ffa5e6c0f30367b98a137298498bfc671bf2 (diff) | |
download | bcm5719-llvm-93ed5cf5e62e828248ec80ba3a032df1d2159fdc.tar.gz bcm5719-llvm-93ed5cf5e62e828248ec80ba3a032df1d2159fdc.zip |
Diagnose declspecs occuring after virt-specifier-seq and generate fixit hints
Summary: This fixes PR22075.
Reviewers: rsmith
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D6828
llvm-svn: 233160
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticParseKinds.td | 2 | ||||
-rw-r--r-- | clang/include/clang/Parse/Parser.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Sema/DeclSpec.h | 6 |
3 files changed, 9 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 56a984baf4c..d96fbac50d3 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -183,6 +183,8 @@ def warn_attribute_no_decl : Warning< "attribute %0 ignored, because it is not attached to a declaration">, InGroup<IgnoredAttributes>; def err_expected_method_body : Error<"expected method body">; +def err_declspec_after_virtspec : Error< + "'%0' qualifier may not appear after the virtual specifier '%1'">; def err_invalid_token_after_toplevel_declarator : Error< "expected ';' after top level declarator">; def err_invalid_token_after_declarator_suggest_equal : Error< diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 498af7c5b7c..ba3fd133cc6 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -2293,6 +2293,8 @@ private: VirtSpecifiers &VS, ExprResult &BitfieldSize, LateParsedAttrList &LateAttrs); + void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D, + VirtSpecifiers &VS); void ParseCXXClassMemberDeclaration(AccessSpecifier AS, AttributeList *Attr, const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), ParsingDeclRAIIObject *DiagsFromTParams = nullptr); diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index 76ccb1d23a8..03c3427d68b 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -2180,7 +2180,7 @@ public: VS_Sealed = 4 }; - VirtSpecifiers() : Specifiers(0) { } + VirtSpecifiers() : Specifiers(0), LastSpecifier(VS_None) { } bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec); @@ -2198,12 +2198,16 @@ public: static const char *getSpecifierName(Specifier VS); + SourceLocation getFirstLocation() const { return FirstLocation; } SourceLocation getLastLocation() const { return LastLocation; } + Specifier getLastSpecifier() const { return LastSpecifier; } private: unsigned Specifiers; + Specifier LastSpecifier; SourceLocation VS_overrideLoc, VS_finalLoc; + SourceLocation FirstLocation; SourceLocation LastLocation; }; |