From: Francois Pichet Date: Tue, 24 May 2011 02:11:43 +0000 (+0000) Subject: MSVC doesn't do any validation regarding exception specification. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f161593b36584ec447e5268dbed2953489854d8;p=clang MSVC doesn't do any validation regarding exception specification. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131950 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index e5354b6424..8653358265 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -582,6 +582,9 @@ def warn_mismatched_exception_spec : ExtWarn< def err_override_exception_spec : Error< "exception specification of overriding function is more lax than " "base version">; +def warn_override_exception_spec : ExtWarn< + "exception specification of overriding function is more lax than " + "base version">, InGroup; def err_incompatible_exception_specs : Error< "target exception specification is not superset of source">; def err_deep_exception_specs_differ : Error< diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index fc20403960..0f6108c8bc 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -714,7 +714,10 @@ bool Sema::CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, return false; } } - return CheckExceptionSpecSubset(PDiag(diag::err_override_exception_spec), + unsigned DiagID = diag::err_override_exception_spec; + if (getLangOptions().Microsoft) + DiagID = diag::warn_override_exception_spec; + return CheckExceptionSpecSubset(PDiag(DiagID), PDiag(diag::note_overridden_virtual_function), Old->getType()->getAs(), Old->getLocation(), diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp index 3391e7afb0..22a06673b9 100644 --- a/test/SemaCXX/MicrosoftExtensions.cpp +++ b/test/SemaCXX/MicrosoftExtensions.cpp @@ -6,6 +6,8 @@ void f(const type_info &a); // Microsoft doesn't validate exception specification. +namespace microsoft_exception_spec { + void foo(); // expected-note {{previous declaration}} void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}} @@ -22,6 +24,15 @@ struct Derived : Base { virtual void f3(); }; +class A { + virtual ~A() throw(); // expected-note {{overridden virtual function is here}} +}; + +class B : public A { + virtual ~B(); // expected-warning {{exception specification of overriding function is more lax than base version}} +}; + +} // MSVC allows type definition in anonymous union and struct struct A