From: Reid Kleckner Date: Mon, 2 Oct 2017 17:16:14 +0000 (+0000) Subject: Revert "[Sema] Warn on attribute nothrow conflicting with language specifiers" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a1ab56d8194f84071d8c7fb0c5a874bdca5d06c;p=clang Revert "[Sema] Warn on attribute nothrow conflicting with language specifiers" This reverts r314461. It is warning on user code that uses END_COM_MAP(), which expands to declare QueryInterface with conflicting exception specifers. I've spent a while trying to understand why, but haven't been able to extract a reduced test case. Let's revert and I'll keep trying. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314689 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 38f2a3bd65..3d20cab8d7 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1419,10 +1419,6 @@ def err_noexcept_needs_constant_expression : Error< "argument to noexcept specifier must be a constant expression">; def err_exception_spec_not_parsed : Error< "exception specification is not available until end of class definition">; -def warn_nothrow_attr_disagrees_with_exception_specification - : ExtWarn<"attribute 'nothrow' ignored due to conflicting exception " - "specification">, - InGroup; // C++ access checking def err_class_redeclared_with_different_access : Error< diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 2a13c9576c..1f4be4405b 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1985,25 +1985,6 @@ static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &Attrs) { Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); } -static void handleNoThrowAttr(Sema &S, Decl *D, const AttributeList &Attrs) { - assert(isa(D) && "attribute nothrow only valid on functions"); - - auto *FD = cast(D); - const auto *FPT = FD->getType()->getAs(); - - if (FPT && FPT->hasExceptionSpec() && - FPT->getExceptionSpecType() != EST_BasicNoexcept) { - S.Diag(Attrs.getLoc(), - diag::warn_nothrow_attr_disagrees_with_exception_specification); - S.Diag(FD->getExceptionSpecSourceRange().getBegin(), - diag::note_previous_decl) - << "exception specification"; - } - - D->addAttr(::new (S.Context) NoThrowAttr( - Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); -} - static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (S.CheckNoCallerSavedRegsAttr(Attr)) @@ -6230,7 +6211,7 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, handleNoReturnAttr(S, D, Attr); break; case AttributeList::AT_NoThrow: - handleNoThrowAttr(S, D, Attr); + handleSimpleAttribute(S, D, Attr); break; case AttributeList::AT_CUDAShared: handleSharedAttr(S, D, Attr); diff --git a/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp b/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp deleted file mode 100644 index c927c4f926..0000000000 --- a/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++14 - -struct S { - //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting exception specification}} - //expected-note@+1 {{exception specification declared here}} - __attribute__((nothrow)) S() noexcept(true); - //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting exception specification}} - //expected-note@+1 {{exception specification declared here}} - __attribute__((nothrow)) void Func1() noexcept(false); - __attribute__((nothrow)) void Func3() noexcept; -}; - -void throwing() noexcept(false); -void non_throwing(bool b = true) noexcept; - -template -struct T { - __attribute__((nothrow)) void f(Fn) noexcept(Fn()); -}; - -//expected-warning@-3 {{attribute 'nothrow' ignored due to conflicting exception specification}} -//expected-note@-4 {{exception specification declared here}} -template struct T; -template struct T;