aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois Pichet <pichet2000@gmail.com>2011-05-24 02:11:43 +0000
committerFrancois Pichet <pichet2000@gmail.com>2011-05-24 02:11:43 +0000
commit0f161593b36584ec447e5268dbed2953489854d8 (patch)
tree924df7c3c4eafda074464f042a3132761f213140
parent1ebb6f29ed1972665f35127efa907eabeb961cee (diff)
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
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td3
-rw-r--r--lib/Sema/SemaExceptionSpec.cpp5
-rw-r--r--test/SemaCXX/MicrosoftExtensions.cpp11
3 files changed, 18 insertions, 1 deletions
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<Microsoft>;
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<FunctionProtoType>(),
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