[cfe-commits] [PATCH] Warn on duplicate const specifier

Aaron Ballman aaron at aaronballman.com
Tue Aug 28 13:47:14 PDT 2012


On Tue, Aug 28, 2012 at 4:19 PM, Chandler Carruth <chandlerc at google.com> wrote:
> Index: lib/Sema/DeclSpec.cpp
> ===================================================================
> --- lib/Sema/DeclSpec.cpp (revision 162690)
> +++ lib/Sema/DeclSpec.cpp (working copy)
> @@ -325,10 +325,17 @@
>
>  template <class T> static bool BadSpecifier(T TNew, T TPrev,
>                                              const char *&PrevSpec,
> -                                            unsigned &DiagID) {
> +                                            unsigned &DiagID,
> +                                            bool Pedantic = true) {
>
> How about "IsExtension"?
>
>    PrevSpec = DeclSpec::getSpecifierName(TPrev);
> -  DiagID = (TNew == TPrev ? diag::ext_duplicate_declspec
> -            : diag::err_invalid_decl_spec_combination);
> +  if (TNew == TPrev) {
> +    if (Pedantic)
> +      DiagID = diag::ext_duplicate_declspec;
> +    else
> +      DiagID = diag::warn_duplicate_declspec;
> +  } else {
> +    DiagID = diag::err_invalid_decl_spec_combination;
> +  }
>
> Would early exit make this cleaner?

Attached with latest suggestions.

~Aaron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dup-spec.patch
Type: application/octet-stream
Size: 4689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120828/39f0f06f/attachment.obj>


More information about the cfe-commits mailing list