[PATCH] D38205: [Sema] Warn on attribute nothrow conflicting with language specifiers

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 25 05:32:47 PDT 2017


aaron.ballman added inline comments.


================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1411
+def warn_nothrow_attr_disagrees_with_exception_specification
+    : ExtWarn<"Attribute nothrow ignored, it disagrees with language specified "
+              "exception specification">,
----------------
How about: `"attribute 'nothrow' ignored due to conflicting exception specification"`


================
Comment at: lib/Sema/SemaDeclAttr.cpp:1972
 
+static void handleNoThrowAttr(Sema &S, Decl *D, const AttributeList &attr) {
+  assert(isa<FunctionDecl>(D) && "attribute nothrow only valid on functions");
----------------
`attr` doesn't meet the coding guidelines. I'd go with `AL`.


================
Comment at: test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp:3
+
+struct S {
+  //expected-warning at +2 {{Attribute nothrow ignored, it disagrees with}}
----------------
You should add some tests that include templates and test it on Windows as well as non-Windows. I'm wondering about computed exception specifications during template instantiation. e.g.,
```
void throwing() noexcept(false);
void non_throwing() noexcept;

template <typename Fn>
struct T {
  __attribute__((nothrow)) void f(Fn) noexcept(Fn());
};

template struct T<decltype(throwing)>;
template struct T<decltype(non_throwing)>;
```


https://reviews.llvm.org/D38205





More information about the cfe-commits mailing list