[cfe-commits] r131950 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExceptionSpec.cpp test/SemaCXX/MicrosoftExtensions.cpp

Francois Pichet pichet2000 at gmail.com
Mon May 23 19:11:44 PDT 2011


Author: fpichet
Date: Mon May 23 21:11:43 2011
New Revision: 131950

URL: http://llvm.org/viewvc/llvm-project?rev=131950&view=rev
Log:
MSVC doesn't do any validation regarding exception specification.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
    cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=131950&r1=131949&r2=131950&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May 23 21:11:43 2011
@@ -582,6 +582,9 @@
 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<

Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=131950&r1=131949&r2=131950&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Mon May 23 21:11:43 2011
@@ -714,7 +714,10 @@
       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(),

Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=131950&r1=131949&r2=131950&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Mon May 23 21:11:43 2011
@@ -6,6 +6,8 @@
 
 
 // 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 @@
   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





More information about the cfe-commits mailing list