]> granicus.if.org Git - clang/commitdiff
[-fms-extensions] Allow missing exception specifications in redeclarations as an...
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 20 Oct 2015 20:49:21 +0000 (20:49 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 20 Oct 2015 20:49:21 +0000 (20:49 +0000)
Microsoft's ATL headers make use of this MSVC extension, add support for
it and issue a diagnostic under -Wmicrosoft-exception-spec.

This fixes PR25265.

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

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

index 63943ccea37ed818c58827d26ad1a193ff21de20..4829f2b74d0ea5632464b7e876cc1a79c6a04e8c 100644 (file)
@@ -1154,11 +1154,14 @@ def err_incompatible_exception_specs : Error<
   "target exception specification is not superset of source">;
 def err_deep_exception_specs_differ : Error<
   "exception specifications of %select{return|argument}0 types differ">;
-def ext_missing_exception_specification : ExtWarn<
-  "%0 is missing exception specification '%1'">,
-  InGroup<DiagGroup<"missing-exception-spec">>;
 def err_missing_exception_specification : Error<
   "%0 is missing exception specification '%1'">;
+def ext_missing_exception_specification : ExtWarn<
+  err_missing_exception_specification.Text>,
+  InGroup<DiagGroup<"missing-exception-spec">>;
+def ext_ms_missing_exception_specification : ExtWarn<
+  err_missing_exception_specification.Text>,
+  InGroup<MicrosoftExceptionSpec>;
 def err_noexcept_needs_constant_expression : Error<
   "argument to noexcept specifier must be a constant expression">;
 def err_exception_spec_not_parsed : Error<
index a4356f6941b784b49332630fa51e573f27a29aa2..a18824f1552b1714855cbc87ba64c3fd386e1d21 100644 (file)
@@ -285,10 +285,14 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
         NewProto->getExtProtoInfo().withExceptionSpec(ESI)));
   }
 
-  // Allow missing exception specifications in redeclarations as an extension,
-  // when declaring a replaceable global allocation function.
-  if (New->isReplaceableGlobalAllocationFunction() &&
-      ESI.Type != EST_ComputedNoexcept) {
+  if (getLangOpts().MicrosoftExt && ESI.Type != EST_ComputedNoexcept) {
+    // Allow missing exception specifications in redeclarations as an extension.
+    DiagID = diag::ext_ms_missing_exception_specification;
+    ReturnValueOnError = false;
+  } else if (New->isReplaceableGlobalAllocationFunction() &&
+             ESI.Type != EST_ComputedNoexcept) {
+    // Allow missing exception specifications in redeclarations as an extension,
+    // when declaring a replaceable global allocation function.
     DiagID = diag::ext_missing_exception_specification;
     ReturnValueOnError = false;
   } else {
index 11f4f195562a4ef294d9b133123a40692c6f0b9d..3d11c20148aad0611e23913f96f7b23327742952 100644 (file)
@@ -422,3 +422,11 @@ template <typename TX> struct A {
   };
 };
 }
+
+namespace PR25265 {
+struct S {
+  int fn() throw(); // expected-note {{previous declaration is here}}
+};
+
+int S::fn() { return 0; } // expected-warning {{is missing exception specification}}
+}