"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">;
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(),
return false;
}
- Diag(New->getLocation(), diag::err_mismatched_exception_spec);
+ Diag(New->getLocation(), DiagID);
Diag(Old->getLocation(), diag::note_previous_declaration);
return true;
}
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);
}
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;
// ::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();