]> granicus.if.org Git - clang/commitdiff
Downgrade err_mismatched_exception_spec to a ExtWarning in Microsoft mode. MSVC doesn...
authorFrancois Pichet <pichet2000@gmail.com>
Sat, 19 Mar 2011 23:05:18 +0000 (23:05 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Sat, 19 Mar 2011 23:05:18 +0000 (23:05 +0000)
This remove 1 error when parsing MSVC stl lib with clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127961 91177308-0d34-0410-b5e6-96231b3b80d8

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

index a722f0514f2b2dc5b036e22c72446391124587d5..ef0c0d46ee60135640273df702043872f19be121 100644 (file)
@@ -551,6 +551,8 @@ def err_incomplete_in_exception_spec : Error<
   "in exception specification">;
 def err_mismatched_exception_spec : Error<
   "exception specification in declaration does not match previous declaration">;
+def war_mismatched_exception_spec : ExtWarn<
+  "exception specification in declaration does not match previous declaration">;
 def err_override_exception_spec : Error<
   "exception specification of overriding function is more lax than "
   "base version">;
index 490934c4b04b37a78eaba0667b94b4ed58149197..1512a2578977b5cedae97c756eedfa4eded57f72 100644 (file)
@@ -100,7 +100,11 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
   bool IsOperatorNew = OO == OO_New || OO == OO_Array_New;
   bool MissingExceptionSpecification = false;
   bool MissingEmptyExceptionSpecification = false;
-  if (!CheckEquivalentExceptionSpec(PDiag(diag::err_mismatched_exception_spec),
+  unsigned DiagID = diag::err_mismatched_exception_spec;
+  if (getLangOptions().Microsoft)
+    DiagID = diag::war_mismatched_exception_spec; 
+  
+  if (!CheckEquivalentExceptionSpec(PDiag(DiagID),
                                     PDiag(diag::note_previous_declaration),
                                     Old->getType()->getAs<FunctionProtoType>(),
                                     Old->getLocation(),
@@ -247,7 +251,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
     return false;    
   }
 
-  Diag(New->getLocation(), diag::err_mismatched_exception_spec);
+  Diag(New->getLocation(), DiagID);
   Diag(Old->getLocation(), diag::note_previous_declaration);
   return true;
 }
@@ -259,8 +263,11 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
 bool Sema::CheckEquivalentExceptionSpec(
     const FunctionProtoType *Old, SourceLocation OldLoc,
     const FunctionProtoType *New, SourceLocation NewLoc) {
+  unsigned DiagID = diag::err_mismatched_exception_spec;
+  if (getLangOptions().Microsoft)
+    DiagID = diag::war_mismatched_exception_spec; 
   return CheckEquivalentExceptionSpec(
-                                    PDiag(diag::err_mismatched_exception_spec),
+                                      PDiag(DiagID),
                                       PDiag(diag::note_previous_declaration),
                                       Old, OldLoc, New, NewLoc);
 }
@@ -339,14 +346,6 @@ bool Sema::CheckEquivalentExceptionSpec(const PartialDiagnostic &DiagID,
     return true;
   }
 
-  if (getLangOptions().Microsoft) {
-    // Treat throw(whatever) as throw(...) to be compatible with MS headers.
-    if (OldEST == EST_Dynamic)
-      OldEST = EST_MSAny;
-    if (NewEST == EST_Dynamic)
-      NewEST = EST_MSAny;
-  }
-
   // The MS extension throw(...) is compatible with itself.
   if (OldEST == EST_MSAny && NewEST == EST_MSAny)
     return false;
index 6a12d0dc963f08e99f9803f5902b33d560e59463..0434f48dd1a5771a54d338b89febbfd584c6bb41 100644 (file)
@@ -4,21 +4,13 @@
 // ::type_info is predeclared with forward class declartion
 void f(const type_info &a);
 
-// The following three are all equivalent when ms-extensions are on
-void foo() throw(int);
-void foo() throw(int, long);
-void foo() throw(...); 
-void foo(); // expected-note {{previous declaration}}
-
-// Only nothrow specification is treated specially.
-void foo() throw(); // expected-error {{exception specification in declaration does not match previous declaration}}
 
-// throw(...)
-void r3();
-void r3() throw(...);
+// Microsoft doesn't validate exception specification.
+void foo(); // expected-note {{previous declaration}}
+void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
 
-void r6() throw(...);
-void r6() throw(int); // okay
+void r6() throw(...); // expected-note {{previous declaration}}
+void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}}
 
 struct Base {
   virtual void f2();