Author: majnemer Date: Fri Jun 10 13:24:41 2016 New Revision: 272412 URL: http://llvm.org/viewvc/llvm-project?rev=272412&view=rev Log: [-fms-extensions] Permit incomplete types in dynamic exception specifications
Microsoft headers, comdef.h and comutil.h, assume that this is an OK thing to do. Downgrade the hard error to a warning if we are in -fms-extensions mode. This fixes PR28080. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaExceptionSpec.cpp cfe/trunk/test/SemaCXX/ms-exception-spec.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=272412&r1=272411&r2=272412&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 10 13:24:41 2016 @@ -1223,6 +1223,8 @@ def err_distant_exception_spec : Error< def err_incomplete_in_exception_spec : Error< "%select{|pointer to |reference to }0incomplete type %1 is not allowed " "in exception specification">; +def ext_incomplete_in_exception_spec : ExtWarn<err_incomplete_in_exception_spec.Text>, + InGroup<MicrosoftExceptionSpec>; def err_rref_in_exception_spec : Error< "rvalue reference type %0 is not allowed in exception specification">; def err_mismatched_exception_spec : Error< Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=272412&r1=272411&r2=272412&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original) +++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Fri Jun 10 13:24:41 2016 @@ -110,10 +110,13 @@ bool Sema::CheckSpecifiedExceptionType(Q // A type denoted in an exception-specification shall not denote a // pointer or reference to an incomplete type, other than (cv) void* or a // pointer or reference to a class currently being defined. + // In Microsoft mode, downgrade this to a warning. + unsigned DiagID = diag::err_incomplete_in_exception_spec; + if (getLangOpts().MicrosoftExt) + DiagID = diag::ext_incomplete_in_exception_spec; if (!(PointeeT->isRecordType() && PointeeT->getAs<RecordType>()->isBeingDefined()) && - RequireCompleteType(Range.getBegin(), PointeeT, - diag::err_incomplete_in_exception_spec, Kind, Range)) + RequireCompleteType(Range.getBegin(), PointeeT, DiagID, Kind, Range)) return true; return false; Modified: cfe/trunk/test/SemaCXX/ms-exception-spec.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-exception-spec.cpp?rev=272412&r1=272411&r2=272412&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/ms-exception-spec.cpp (original) +++ cfe/trunk/test/SemaCXX/ms-exception-spec.cpp Fri Jun 10 13:24:41 2016 @@ -1,4 +1,8 @@ // RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -// expected-no-diagnostics void f() throw(...) { } + +namespace PR28080 { +struct S; // expected-note {{forward declaration}} +void fn() throw(S); // expected-warning {{incomplete type}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits