[PATCH] Downgrade the error about nested name specifiers when building with Microsoft extensions

Richard Smith richard at metafoo.co.uk
Sat Jun 28 02:29:32 PDT 2014


On 28 Jun 2014 02:41, "Ehsan Akhgari" <ehsan.akhgari at gmail.com> wrote:
>
> Hi rnk,
>
> This fixes http://llvm.org/PR20145.
>
> http://reviews.llvm.org/D4333
>
> Files:
>   include/clang/Basic/DiagnosticSemaKinds.td
>   lib/Sema/SemaDecl.cpp
>   test/SemaCXX/MicrosoftExtensions.cpp
>
> Index: include/clang/Basic/DiagnosticSemaKinds.td
> ===================================================================
> --- include/clang/Basic/DiagnosticSemaKinds.td
> +++ include/clang/Basic/DiagnosticSemaKinds.td
> @@ -4724,6 +4724,9 @@
>  def err_standalone_class_nested_name_specifier : Error<
>    "forward declaration of %select{class|struct|interface|union|enum}0
cannot "
>    "have a nested name specifier">;
> +def warn_standalone_class_nested_name_specifier : ExtWarn<
> +  "forward declaration of %select{class|struct|interface|union|enum}0
with a "
> +  "nested name specifier is a Microsoft extension">, InGroup<Microsoft>;

An ExtWarn should be named ext_...

>  def err_typecheck_sclass_func : Error<"illegal storage class on
function">;
>  def err_static_block_func : Error<
>    "function declared in block scope cannot have 'static' storage class">;
> Index: lib/Sema/SemaDecl.cpp
> ===================================================================
> --- lib/Sema/SemaDecl.cpp
> +++ lib/Sema/SemaDecl.cpp
> @@ -3286,7 +3286,10 @@
>      // nested-name-specifier unless it is an explicit instantiation
>      // or an explicit specialization.
>      // Per C++ [dcl.enum]p1, an opaque-enum-declaration can't either.
> -    Diag(SS.getBeginLoc(),
diag::err_standalone_class_nested_name_specifier)
> +    Diag(SS.getBeginLoc(),
> +         getLangOpts().MicrosoftExt ?
> +           diag::warn_standalone_class_nested_name_specifier :
> +           diag::err_standalone_class_nested_name_specifier)
>        << (DS.getTypeSpecType() == DeclSpec::TST_class ? 0 :
>            DS.getTypeSpecType() == DeclSpec::TST_struct ? 1 :
>            DS.getTypeSpecType() == DeclSpec::TST_interface ? 2 :
> Index: test/SemaCXX/MicrosoftExtensions.cpp
> ===================================================================
> --- test/SemaCXX/MicrosoftExtensions.cpp
> +++ test/SemaCXX/MicrosoftExtensions.cpp
> @@ -418,3 +418,19 @@
>    _Static_assert(__alignof(s1) == 8, "");
>    _Static_assert(__alignof(s2) == 4, "");
>  }
> +
> +namespace forward_decl_nested_name_NS {
> +  struct X;
> +  template<typename T> struct Y;
> +}
> +
> +struct forward_decl_nested_name_NS::X; // expected-warning {{forward
declaration of struct with a nested name specifier is a Microsoft
extension}}
> +template<typename T> struct forward_decl_nested_name_NS::Y; //
expected-warning {{forward declaration of struct with a nested name
specifier is a Microsoft extension}}
> +
> +struct forward_decl_nested_name_struct {
> +  struct A;
> +  union B;
> +};
> +
> +struct forward_decl_nested_name_struct::A; // expected-warning {{forward
declaration of struct with a nested name specifier is a Microsoft
extension}}
> +union forward_decl_nested_name_struct::B; // expected-warning {{forward
declaration of union with a nested name specifier is a Microsoft extension}}
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140628/c8669d66/attachment.html>


More information about the cfe-commits mailing list