<p dir="ltr"><br>
On 28 Aug 2012 21:58, "Aaron Ballman" <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:<br>
><br>
> Author: aaronballman<br>
> Date: Tue Aug 28 15:55:40 2012<br>
> New Revision: 162793<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=162793&view=rev">http://llvm.org/viewvc/llvm-project?rev=162793&view=rev</a><br>
> Log:<br>
> 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.<br>
><br>
> Modified:<br>
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td<br>
> cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td<br>
> cfe/trunk/lib/Sema/DeclSpec.cpp<br>
> cfe/trunk/test/Misc/warning-flags.c<br>
> cfe/trunk/test/Parser/cxx-decl.cpp<br>
> cfe/trunk/test/Parser/cxx0x-decl.cpp<br>
><br>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=162793&r1=162792&r2=162793&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=162793&r1=162792&r2=162793&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)<br>
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Aug 28 15:55:40 2012<br>
> @@ -197,6 +197,7 @@<br>
> def StrncatSize : DiagGroup<"strncat-size">;<br>
> def TautologicalCompare : DiagGroup<"tautological-compare">;<br>
> def HeaderHygiene : DiagGroup<"header-hygiene">;<br>
> +def DuplicateDeclSpecifiers : DiagGroup<"duplicate-decl-specifiers">;</p>
<p dir="ltr">It seems inconsistent to use a plural here and a singular in the warning text.</p>
<p dir="ltr">><br>
> // Preprocessor warnings.<br>
> def : DiagGroup<"builtin-macro-redefined">;<br>
><br>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=162793&r1=162792&r2=162793&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=162793&r1=162792&r2=162793&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)<br>
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Tue Aug 28 15:55:40 2012<br>
> @@ -43,7 +43,10 @@<br>
> "extra ';' after member function definition">,<br>
> InGroup<ExtraSemi>, DefaultIgnore;<br>
><br>
> -def ext_duplicate_declspec : Extension<"duplicate '%0' declaration specifier">;<br>
> +def ext_duplicate_declspec : ExtWarn<"duplicate '%0' declaration specifier">,<br>
> + InGroup<DuplicateDeclSpecifiers>;<br>
> +def warn_duplicate_declspec : Warning<"duplicate '%0' declaration specifier">,<br>
> + InGroup<DuplicateDeclSpecifiers>;<br>
> def ext_plain_complex : ExtWarn<<br>
> "plain '_Complex' requires a type specifier; assuming '_Complex double'">;<br>
> def ext_integer_complex : Extension<<br>
><br>
> Modified: cfe/trunk/lib/Sema/DeclSpec.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=162793&r1=162792&r2=162793&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=162793&r1=162792&r2=162793&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Sema/DeclSpec.cpp (original)<br>
> +++ cfe/trunk/lib/Sema/DeclSpec.cpp Tue Aug 28 15:55:40 2012<br>
> @@ -325,10 +325,14 @@<br>
><br>
> template <class T> static bool BadSpecifier(T TNew, T TPrev,<br>
> const char *&PrevSpec,<br>
> - unsigned &DiagID) {<br>
> + unsigned &DiagID,<br>
> + bool IsExtension = true) {<br>
> PrevSpec = DeclSpec::getSpecifierName(TPrev);<br>
> - DiagID = (TNew == TPrev ? diag::ext_duplicate_declspec<br>
> - : diag::err_invalid_decl_spec_combination);<br>
> + if (TNew != TPrev)<br>
> + DiagID = diag::err_invalid_decl_spec_combination;<br>
> + else<br>
> + DiagID = IsExtension ? diag::ext_duplicate_declspec :<br>
> + diag::warn_duplicate_declspec;<br>
> return true;<br>
> }<br>
><br>
> @@ -673,9 +677,15 @@<br>
> unsigned &DiagID, const LangOptions &Lang,<br>
> bool IsTypeSpec) {<br>
> // Duplicates are permitted in C99, and are permitted in C++11 unless the<br>
> - // cv-qualifier appears as a type-specifier.<br>
> - if ((TypeQualifiers & T) && !Lang.C99 && (!Lang.CPlusPlus0x || IsTypeSpec))<br>
> - return BadSpecifier(T, T, PrevSpec, DiagID);<br>
> + // cv-qualifier appears as a type-specifier. However, since this is likely<br>
> + // not what the user intended, we will always warn. We do not need to set the<br>
> + // qualifier's location since we already have it.<br>
> + if (TypeQualifiers & T) {<br>
> + bool IsExtension = false;<br>
> + if (Lang.C99 || (Lang.CPlusPlus0x && !IsTypeSpec))<br>
> + IsExtension = true;</p>
<p dir="ltr">Isn't this backwards? The warning is not an extension in C99 because the code is well-formed there.</p>