r272447 - [Sema] Return an appropriate result from CheckSpecifiedExceptionType

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 10 18:25:05 PDT 2016


Author: majnemer
Date: Fri Jun 10 20:25:04 2016
New Revision: 272447

URL: http://llvm.org/viewvc/llvm-project?rev=272447&view=rev
Log:
[Sema] Return an appropriate result from CheckSpecifiedExceptionType

We shouldn't return true from CheckSpecifiedExceptionType if
the record type is incomplete and -fms-extensions is engaged.  Otherwise
we will have an incomplete AST.

Modified:
    cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
    cfe/trunk/test/SemaCXX/ms-exception-spec.cpp

Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=272447&r1=272446&r2=272447&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Fri Jun 10 20:25:04 2016
@@ -112,12 +112,15 @@ bool Sema::CheckSpecifiedExceptionType(Q
   //   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)
+  bool ReturnValueOnError = true;
+  if (getLangOpts().MicrosoftExt) {
     DiagID = diag::ext_incomplete_in_exception_spec;
+    ReturnValueOnError = false;
+  }
   if (!(PointeeT->isRecordType() &&
         PointeeT->getAs<RecordType>()->isBeingDefined()) &&
       RequireCompleteType(Range.getBegin(), PointeeT, DiagID, Kind, Range))
-    return true;
+    return ReturnValueOnError;
 
   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=272447&r1=272446&r2=272447&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ms-exception-spec.cpp (original)
+++ cfe/trunk/test/SemaCXX/ms-exception-spec.cpp Fri Jun 10 20:25:04 2016
@@ -1,8 +1,9 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -fexceptions -fcxx-exceptions
 
 void f() throw(...) { }
 
 namespace PR28080 {
-struct S; // expected-note {{forward declaration}}
-void fn() throw(S); // expected-warning {{incomplete type}}
+struct S;           // expected-note {{forward declaration}}
+void fn() throw(S); // expected-warning {{incomplete type}} expected-note{{previous declaration}}
+void fn() throw();  // expected-warning {{does not match previous declaration}}
 }




More information about the cfe-commits mailing list