From: Nico Weber Date: Mon, 23 Jan 2012 05:50:57 +0000 (+0000) Subject: In microsoft mode, downgrade pseudo-destructors on void from error to warning. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=df1be86ef5f5d55fc23b2339ee76e076424d9ba0;p=clang In microsoft mode, downgrade pseudo-destructors on void from error to warning. This matches cl.exe's behavior and fixes PR11791. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148682 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 96f85f6f6e..56fca58475 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -4053,6 +4053,9 @@ def err_operator_arrow_circular : Error< 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; 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">; diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index edc5b08900..d3bbc14728 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -4380,8 +4380,11 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, 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(); return ExprError(); } diff --git a/test/SemaCXX/MicrosoftCompatibility.cpp b/test/SemaCXX/MicrosoftCompatibility.cpp index 90a7ff731c..3634fa3462 100644 --- a/test/SemaCXX/MicrosoftCompatibility.cpp +++ b/test/SemaCXX/MicrosoftCompatibility.cpp @@ -163,3 +163,14 @@ enum ENUM2 { }; +namespace PR11791 { + template + 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}} + } +}