diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-01-10 21:27:55 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-01-10 21:27:55 +0000 |
commit | c0a5d5bc4f7edab93b98204abebd59126af494b5 (patch) | |
tree | b5c690cc823870b076efad2e0ab12099161a0745 /clang/lib/Sema/DeclSpec.cpp | |
parent | 78dcc03c3791097ebefa7590269329abe616b26d (diff) | |
download | bcm5719-llvm-c0a5d5bc4f7edab93b98204abebd59126af494b5.tar.gz bcm5719-llvm-c0a5d5bc4f7edab93b98204abebd59126af494b5.zip |
Downgrade bogus ExtWarn on duplicate 'friend' specifier to a Warning, and add a
Warning for a duplicate 'constexpr' specifier.
llvm-svn: 198956
Diffstat (limited to 'clang/lib/Sema/DeclSpec.cpp')
-rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index d23df82be50..214599c481b 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -827,7 +827,12 @@ bool DeclSpec::SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID) { if (Friend_specified) { PrevSpec = "friend"; - DiagID = diag::ext_duplicate_declspec; + // Keep the later location, so that we can later diagnose ill-formed + // declarations like 'friend class X friend;'. Per [class.friend]p3, + // 'friend' must be the first token in a friend declaration that is + // not a function declaration. + FriendLoc = Loc; + DiagID = diag::warn_duplicate_declspec; return true; } @@ -850,7 +855,13 @@ bool DeclSpec::setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, bool DeclSpec::SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID) { - // 'constexpr constexpr' is ok. + // 'constexpr constexpr' is ok, but warn as this is likely not what the user + // intended. + if (Constexpr_specified) { + DiagID = diag::warn_duplicate_declspec; + PrevSpec = "constexpr"; + return true; + } Constexpr_specified = true; ConstexprLoc = Loc; return false; |