[clang] nolock/noalloc attributes (PR #84983)

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 14 18:01:12 PDT 2024


Sirraide wrote:

> 
> I was testing with `noreturn` earlier. It's hard to compare, because (at least in C23):
> 
> ```
> ../clang/test/Sema/attr-nolock-wip.cpp:15:19: error: 'noreturn' attribute cannot be applied to types
>    15 | void noret(int) [[noreturn]];
>       |                   ^
> ```

I think I was using `__attribute__((noreturn))` on a function pointer to test this. Adapted from `test/Sema/initialize-noreturn.c` (https://godbolt.org/z/q4qoaz8rP):
```c
typedef void (*Fn_noret)(void) __attribute__((noreturn));
void foo(void);
Fn_noret fn = foo;
```
This gives
```
<source>:3:10: error: incompatible function pointer types initializing 'Fn_noret' (aka 'void (*)(void) __attribute__((noreturn))') with an expression of type 'void (void)' [-Wincompatible-function-pointer-types]
    3 | Fn_noret fn = foo;
      |          ^    ~~~
```

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


More information about the cfe-commits mailing list