Commit 4849d59
authored
[clang] Warn [[clang::lifetimebound]] misusages on types (#118281)
Emit the "cannot be applied to types" warning instead of silently
ignoring the attribute when it's attempted to be used on a type (instead
of a function argument or the function definition).
Before this commit, the warning has been printed when the attribute was
(mis)used on a decl-specifier, but not in other places in a declarator.
Examples where the warning starts being emitted with this commit:
```
int * [[clang::lifetimebound]] x;
void f(int * [[clang::lifetimebound]] x);
void g(int * [[clang::lifetimebound]]);
```
Note that the last example is the case of an unnamed function parameter.
While in theory Clang could've supported the `[[clang::lifetimebound]]`
analysis for unnamed parameters, it doesn't currently, so the commit at
least makes the situation better by highlighting this as a warning
instead of a silent ignore - which was reported at #96034.1 parent bfb2620 commit 4849d59
File tree
3 files changed
+36
-3
lines changed- clang
- docs
- lib/Sema
- test/SemaCXX
3 files changed
+36
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
151 | 166 | | |
152 | 167 | | |
153 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8612 | 8612 | | |
8613 | 8613 | | |
8614 | 8614 | | |
| 8615 | + | |
8615 | 8616 | | |
| 8617 | + | |
| 8618 | + | |
| 8619 | + | |
8616 | 8620 | | |
8617 | 8621 | | |
8618 | 8622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
17 | 31 | | |
18 | 32 | | |
19 | 33 | | |
| |||
0 commit comments