diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2012-08-28 20:55:40 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2012-08-28 20:55:40 +0000 |
commit | 3731b33009620ad7509b1f101ca1c860dc1aa11c (patch) | |
tree | 2b3acc6f4202902da626acc106ff45b7845fd5fb /clang/lib/Sema/DeclSpec.cpp | |
parent | 8d48938bf38988fd4271cb3064b3f2ab80dd401e (diff) | |
download | bcm5719-llvm-3731b33009620ad7509b1f101ca1c860dc1aa11c.tar.gz bcm5719-llvm-3731b33009620ad7509b1f101ca1c860dc1aa11c.zip |
Splitting the duplicated decl spec extension warning into two: one is an ExtWarn and the other a vanilla warning. This addresses PR13705, where const char const * wouldn't warn unless -pedantic was specified under the right conditions.
llvm-svn: 162793
Diffstat (limited to 'clang/lib/Sema/DeclSpec.cpp')
-rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index d12ca783909..e8ce9ac01c3 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -325,10 +325,14 @@ unsigned DeclSpec::getParsedSpecifiers() const { template <class T> static bool BadSpecifier(T TNew, T TPrev, const char *&PrevSpec, - unsigned &DiagID) { + unsigned &DiagID, + bool IsExtension = true) { PrevSpec = DeclSpec::getSpecifierName(TPrev); - DiagID = (TNew == TPrev ? diag::ext_duplicate_declspec - : diag::err_invalid_decl_spec_combination); + if (TNew != TPrev) + DiagID = diag::err_invalid_decl_spec_combination; + else + DiagID = IsExtension ? diag::ext_duplicate_declspec : + diag::warn_duplicate_declspec; return true; } @@ -673,9 +677,15 @@ bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const LangOptions &Lang, bool IsTypeSpec) { // Duplicates are permitted in C99, and are permitted in C++11 unless the - // cv-qualifier appears as a type-specifier. - if ((TypeQualifiers & T) && !Lang.C99 && (!Lang.CPlusPlus0x || IsTypeSpec)) - return BadSpecifier(T, T, PrevSpec, DiagID); + // cv-qualifier appears as a type-specifier. However, since this is likely + // not what the user intended, we will always warn. We do not need to set the + // qualifier's location since we already have it. + if (TypeQualifiers & T) { + bool IsExtension = false; + if (Lang.C99 || (Lang.CPlusPlus0x && !IsTypeSpec)) + IsExtension = true; + return BadSpecifier(T, T, PrevSpec, DiagID, IsExtension); + } TypeQualifiers |= T; switch (T) { |