diff options
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExceptionSpec.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaCXX/ms-exception-spec.cpp | 6 |
3 files changed, 12 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 1813544a78c..bc6e2024a53 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -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< diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp index f12bf2415db..f2ae6bfe2ff 100644 --- a/clang/lib/Sema/SemaExceptionSpec.cpp +++ b/clang/lib/Sema/SemaExceptionSpec.cpp @@ -110,10 +110,13 @@ bool Sema::CheckSpecifiedExceptionType(QualType &T, SourceRange Range) { // 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; diff --git a/clang/test/SemaCXX/ms-exception-spec.cpp b/clang/test/SemaCXX/ms-exception-spec.cpp index 1be8ec29369..81e04dd54df 100644 --- a/clang/test/SemaCXX/ms-exception-spec.cpp +++ b/clang/test/SemaCXX/ms-exception-spec.cpp @@ -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}} +} |