]> granicus.if.org Git - clang/commitdiff
[Sema] Return an appropriate result from CheckSpecifiedExceptionType
authorDavid Majnemer <david.majnemer@gmail.com>
Sat, 11 Jun 2016 01:25:04 +0000 (01:25 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sat, 11 Jun 2016 01:25:04 +0000 (01:25 +0000)
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.

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

lib/Sema/SemaExceptionSpec.cpp
test/SemaCXX/ms-exception-spec.cpp

index f2ae6bfe2ff31dd73a1df4ed1e4ee0e3ecb7c5da..b7bed6de2d71e8d79a82403bb8fa3f8917eb45d0 100644 (file)
@@ -112,12 +112,15 @@ bool Sema::CheckSpecifiedExceptionType(QualType &T, SourceRange Range) {
   //   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;
 }
index 81e04dd54df1b073d019ea629f6549f5e06c66e0..07633791b9f316e9cd9131134aa8dc98d9824cd6 100644 (file)
@@ -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}}
 }