[PATCH] D62435: Add Attribute NoThrow as an Exception Specifier Type

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 27 10:48:19 PDT 2019


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaType.cpp:6970
+    if (Proto->hasExceptionSpec())
+      return true;
+
----------------
erichkeane wrote:
> aaron.ballman wrote:
> > I think we should diagnose that the `nothrow` is ignored in this case to let users know they've done something in conflict and what wins.
> I've been considering that over the weekend, and agree it is a good idea. I am on the fence about the when however. For example, should we warn with throw() or noexcept or noexcept(true)? In these cases, ignoring the attribute is the same as enforcing it.
> 
> My concern is that noexcept (expression-evaluating-to-true) gets ignored with a diagnostic, but has the same effect.
> 
> Did you have an opinion here?
I think the metric should be: if there are conflicting attributes where we need to ignore one of them, we should always diagnose when the attributes specify conflicting semantics, but we don't have to always diagnose when the attributes specify the same semantics. In this case, e.g.,
```
__declspec(nothrow) void foo1() noexcept; // Don't bother warning
__declspec(nothrow) void foo2() noexcept(true); // Don't bother warning
__declspec(nothrow) void foo3() noexcept(false); // Warn
__declspec(nothrow) void foo4() noexcept(foo1()); // Warning is debatable
__declspec(nothrow) void foo5() noexcept(foo3()); // Warn
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62435/new/

https://reviews.llvm.org/D62435





More information about the cfe-commits mailing list