Issue |
129783
|
Summary |
[clang][BoundsSafety] Extend `-Wvla-potential-size-confusion` for struct fields and bounds annotations
|
Labels |
clang:frontend,
TBAA,
clang:bounds-safety
|
Assignees |
rapidsna
|
Reporter |
rapidsna
|
https://github.com/llvm/llvm-project/pull/129772
`-Wvla-potential-size-confusion` diagnoses when `n` references the file scope variable and not the parameter.
```
int n;
void func(int array[n], int n);
```
We may want to extend it to diagnose on situations mentioned in the PR:
- Diagnosing a similar situation in structures. e.g.,
```C
int n;
struct S {
int n;
int array[sizeof(n)]; // Refers to outer n, not member n
};
```
- Diagnosing with constant-size arrays (requires tracking the _expression_ for the constant-size array in the `QualType`) e.g.,
```C
constexpr int n = 12;
void func(int array[n], int n);
```
- Potentially, also diagnosing with any ambiguous situations with bounds annotations like below (with or without the `-fexperimental-late-parse-attributes` flag:
```
constexpr int n;
struct foo {
int * ptr __counted_by(n);
int n;
};
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs