From c0a5d5bc4f7edab93b98204abebd59126af494b5 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 10 Jan 2014 21:27:55 +0000 Subject: Downgrade bogus ExtWarn on duplicate 'friend' specifier to a Warning, and add a Warning for a duplicate 'constexpr' specifier. llvm-svn: 198956 --- clang/lib/Sema/DeclSpec.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'clang/lib') 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; -- cgit v1.2.3