]> granicus.if.org Git - clang/commitdiff
MSVC doesn't do any validation regarding exception specification.
authorFrancois Pichet <pichet2000@gmail.com>
Tue, 24 May 2011 02:11:43 +0000 (02:11 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Tue, 24 May 2011 02:11:43 +0000 (02:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131950 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExceptionSpec.cpp
test/SemaCXX/MicrosoftExtensions.cpp

index e5354b64248bd07c17c14d24065c0175fa95cd6b..8653358265ee901b4939a2ebd74b5cf30d9250b1 100644 (file)
@@ -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<
index fc2040396046b734e48e0744b62fcf886ad36c21..0f6108c8bc81bb1e72e737187ec0e8bd00348693 100644 (file)
@@ -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(),
index 3391e7afb00928781c95425c29648f5525dc2823..22a06673b951689d8bc99caf6ba59e57e65581b8 100644 (file)
@@ -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