diff options
author | Reid Kleckner | 2017-10-02 12:16:14 -0500 |
---|---|---|
committer | Reid Kleckner | 2017-10-02 12:16:14 -0500 |
commit | 3a1ab56d8194f84071d8c7fb0c5a874bdca5d06c (patch) | |
tree | c5c2e41804019f83caf168ec3bc905cd4cdd6d07 | |
parent | 6046d0c42aea6115c0f376c7bad45672ae3ca393 (diff) | |
download | clang-3a1ab56d8194f84071d8c7fb0c5a874bdca5d06c.tar.gz clang-3a1ab56d8194f84071d8c7fb0c5a874bdca5d06c.tar.xz clang-3a1ab56d8194f84071d8c7fb0c5a874bdca5d06c.zip |
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
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 4 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 21 | ||||
-rw-r--r-- | test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp | 24 |
3 files changed, 1 insertions, 48 deletions
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< | |||
1419 | "argument to noexcept specifier must be a constant expression">; | 1419 | "argument to noexcept specifier must be a constant expression">; |
1420 | def err_exception_spec_not_parsed : Error< | 1420 | def err_exception_spec_not_parsed : Error< |
1421 | "exception specification is not available until end of class definition">; | 1421 | "exception specification is not available until end of class definition">; |
1422 | def warn_nothrow_attr_disagrees_with_exception_specification | ||
1423 | : ExtWarn<"attribute 'nothrow' ignored due to conflicting exception " | ||
1424 | "specification">, | ||
1425 | InGroup<IgnoredAttributes>; | ||
1426 | 1422 | ||
1427 | // C++ access checking | 1423 | // C++ access checking |
1428 | def err_class_redeclared_with_different_access : Error< | 1424 | 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) { | |||
1985 | Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); | 1985 | Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); |
1986 | } | 1986 | } |
1987 | 1987 | ||
1988 | static void handleNoThrowAttr(Sema &S, Decl *D, const AttributeList &Attrs) { | ||
1989 | assert(isa<FunctionDecl>(D) && "attribute nothrow only valid on functions"); | ||
1990 | |||
1991 | auto *FD = cast<FunctionDecl>(D); | ||
1992 | const auto *FPT = FD->getType()->getAs<FunctionProtoType>(); | ||
1993 | |||
1994 | if (FPT && FPT->hasExceptionSpec() && | ||
1995 | FPT->getExceptionSpecType() != EST_BasicNoexcept) { | ||
1996 | S.Diag(Attrs.getLoc(), | ||
1997 | diag::warn_nothrow_attr_disagrees_with_exception_specification); | ||
1998 | S.Diag(FD->getExceptionSpecSourceRange().getBegin(), | ||
1999 | diag::note_previous_decl) | ||
2000 | << "exception specification"; | ||
2001 | } | ||
2002 | |||
2003 | D->addAttr(::new (S.Context) NoThrowAttr( | ||
2004 | Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); | ||
2005 | } | ||
2006 | |||
2007 | static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D, | 1988 | static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D, |
2008 | const AttributeList &Attr) { | 1989 | const AttributeList &Attr) { |
2009 | if (S.CheckNoCallerSavedRegsAttr(Attr)) | 1990 | if (S.CheckNoCallerSavedRegsAttr(Attr)) |
@@ -6230,7 +6211,7 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, | |||
6230 | handleNoReturnAttr(S, D, Attr); | 6211 | handleNoReturnAttr(S, D, Attr); |
6231 | break; | 6212 | break; |
6232 | case AttributeList::AT_NoThrow: | 6213 | case AttributeList::AT_NoThrow: |
6233 | handleNoThrowAttr(S, D, Attr); | 6214 | handleSimpleAttribute<NoThrowAttr>(S, D, Attr); |
6234 | break; | 6215 | break; |
6235 | case AttributeList::AT_CUDAShared: | 6216 | case AttributeList::AT_CUDAShared: |
6236 | handleSharedAttr(S, D, Attr); | 6217 | 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 @@ | |||
1 | // RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++14 | ||
2 | |||
3 | struct S { | ||
4 | //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting exception specification}} | ||
5 | //expected-note@+1 {{exception specification declared here}} | ||
6 | __attribute__((nothrow)) S() noexcept(true); | ||
7 | //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting exception specification}} | ||
8 | //expected-note@+1 {{exception specification declared here}} | ||
9 | __attribute__((nothrow)) void Func1() noexcept(false); | ||
10 | __attribute__((nothrow)) void Func3() noexcept; | ||
11 | }; | ||
12 | |||
13 | void throwing() noexcept(false); | ||
14 | void non_throwing(bool b = true) noexcept; | ||
15 | |||
16 | template <typename Fn> | ||
17 | struct T { | ||
18 | __attribute__((nothrow)) void f(Fn) noexcept(Fn()); | ||
19 | }; | ||
20 | |||
21 | //expected-warning@-3 {{attribute 'nothrow' ignored due to conflicting exception specification}} | ||
22 | //expected-note@-4 {{exception specification declared here}} | ||
23 | template struct T<decltype(throwing)>; | ||
24 | template struct T<decltype(non_throwing)>; | ||