[clang] [clang] SemaFunctionEffects: When verifying a function, ignore any trailing 'requires' clause. (PR #114266)

Doug Wyatt via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 1 17:37:28 PDT 2024


dougsonos wrote:

I spent a bit more time trying to extract a reduction from libc++ today but failed. Here are the diagnostics that (fortunately) were enough to devise the fix in this PR:

```c++
...../nonblocking-wip.cpp:54:30: warning: function with 'nonblocking' attribute must not call non-'nonblocking' constructor 'std::expected<int, int>::expected' [-Wfunction-effects]
   54 |  std::expected<int, int> d = c;
      |                              ^
...../usr/include/c++/v1/__expected/expected.h:483:14: note: function pointer cannot be inferred 'nonblocking'
  483 |     requires(is_copy_constructible_v<_Tp> && is_copy_constructible_v<_Err> && is_trivially_copy_constructible_v<_Tp> &&
      |              ^
.....//nonblocking-wip.cpp:54:30: note: in template expansion here
   54 |  std::expected<int, int> d = c;
      |                              ^
```

That showed me that the `requires` clause is being traversed (inappropriately) and doing something that looks like an indirect call (i.e. through a function pointer).

https://github.com/llvm/llvm-project/pull/114266


More information about the cfe-commits mailing list