Author: majnemer Date: Tue Oct 20 15:49:21 2015 New Revision: 250854 URL: http://llvm.org/viewvc/llvm-project?rev=250854&view=rev Log: [-fms-extensions] Allow missing exception specifications in redeclarations as an extension
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. 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=250854&r1=250853&r2=250854&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct 20 15:49:21 2015 @@ -1154,11 +1154,14 @@ def err_incompatible_exception_specs : E "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< Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=250854&r1=250853&r2=250854&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original) +++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Tue Oct 20 15:49:21 2015 @@ -285,10 +285,14 @@ bool Sema::CheckEquivalentExceptionSpec( 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 { Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=250854&r1=250853&r2=250854&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original) +++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Tue Oct 20 15:49:21 2015 @@ -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}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits