]> granicus.if.org Git - clang/commitdiff
[-fms-extensions] Permit incomplete types in dynamic exception specifications
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 10 Jun 2016 18:24:41 +0000 (18:24 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 10 Jun 2016 18:24:41 +0000 (18:24 +0000)
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.

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExceptionSpec.cpp
test/SemaCXX/ms-exception-spec.cpp

index 1813544a78cfe56ff6d703b2539ef114320c9bfe..bc6e2024a53391c250b77aea9686ef31f373fede 100644 (file)
@@ -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<
index f12bf2415dba1fd24c993ee273114783e6dab32a..f2ae6bfe2ff31dd73a1df4ed1e4ee0e3ecb7c5da 100644 (file)
@@ -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;
index 1be8ec29369089defa74994d5cd4e717f75c3e27..81e04dd54df1b073d019ea629f6549f5e06c66e0 100644 (file)
@@ -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}}
+}