From: David Majnemer Date: Sat, 11 Jun 2016 01:25:04 +0000 (+0000) Subject: [Sema] Return an appropriate result from CheckSpecifiedExceptionType X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3749d0e30f157b047746f55a85407c26340cf841;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272447 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index f2ae6bfe2f..b7bed6de2d 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -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()->isBeingDefined()) && RequireCompleteType(Range.getBegin(), PointeeT, DiagID, Kind, Range)) - return true; + return ReturnValueOnError; return false; } diff --git a/test/SemaCXX/ms-exception-spec.cpp b/test/SemaCXX/ms-exception-spec.cpp index 81e04dd54d..07633791b9 100644 --- a/test/SemaCXX/ms-exception-spec.cpp +++ b/test/SemaCXX/ms-exception-spec.cpp @@ -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}} }