[cfe-commits] r148682 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprCXX.cpp test/SemaCXX/MicrosoftCompatibility.cpp

David Blaikie dblaikie at gmail.com
Sun Jan 22 22:03:17 PST 2012


On Sun, Jan 22, 2012 at 9:50 PM, Nico Weber <nicolasweber at gmx.de> wrote:
> Author: nico
> Date: Sun Jan 22 23:50:57 2012
> New Revision: 148682
>
> URL: http://llvm.org/viewvc/llvm-project?rev=148682&view=rev
> Log:
> In microsoft mode, downgrade pseudo-destructors on void from error to warning.
>
> This matches cl.exe's behavior and fixes PR11791.
>
>
> Modified:
>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>    cfe/trunk/lib/Sema/SemaExprCXX.cpp
>    cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=148682&r1=148681&r2=148682&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Jan 22 23:50:57 2012
> @@ -4053,6 +4053,9 @@
>  def err_pseudo_dtor_base_not_scalar : Error<
>   "object expression of non-scalar type %0 cannot be used in a "
>   "pseudo-destructor expression">;
> +def ext_pseudo_dtor_on_void : ExtWarn<
> +  "pseudo-destructors on type void are a Microsoft extension">,
> +  InGroup<Microsoft>;
>  def err_pseudo_dtor_type_mismatch : Error<
>   "the type of object expression (%0) does not match the type being destroyed "
>   "(%1) in pseudo-destructor expression">;
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=148682&r1=148681&r2=148682&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun Jan 22 23:50:57 2012
> @@ -4380,8 +4380,11 @@
>     return ExprError();
>
>   if (!ObjectType->isDependentType() && !ObjectType->isScalarType()) {
> -    Diag(OpLoc, diag::err_pseudo_dtor_base_not_scalar)
> -      << ObjectType << Base->getSourceRange();
> +    if (getLangOptions().MicrosoftMode && ObjectType->isVoidType())
> +      Diag(OpLoc, diag::ext_pseudo_dtor_on_void);
> +    else
> +      Diag(OpLoc, diag::err_pseudo_dtor_base_not_scalar)
> +        << ObjectType << Base->getSourceRange();

wouldn't you want to provide the source range to the microsoft-mode
diagnostic too?

>     return ExprError();
>   }
>
>
> Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=148682&r1=148681&r2=148682&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
> +++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Sun Jan 22 23:50:57 2012
> @@ -163,3 +163,14 @@
>  };
>
>
> +namespace PR11791 {
> +  template<class _Ty>
> +  void del(_Ty *_Ptr) {
> +    _Ptr->~_Ty();  // expected-warning {{pseudo-destructors on type void are a Microsoft extension}}
> +  }
> +
> +  void f() {
> +    int* a = 0;
> +    del((void*)a);  // expected-note {{in instantiation of function template specialization}}
> +  }
> +}

This test case seems a bit more convoluted than necessary - would:

typedef void *foo;
foo f;
f.~foo();

suffice? (or are you testing a different code path? I suppose checking
all the template pseudo dtor machinery might be useful - but I assume
that's all already covered by existing test cases)

- David




More information about the cfe-commits mailing list