[cfe-commits] r148682 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprCXX.cpp test/SemaCXX/MicrosoftCompatibility.cpp
Nico Weber
nicolasweber at gmx.de
Sun Jan 22 21:50:58 PST 2012
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();
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}}
+ }
+}
More information about the cfe-commits
mailing list