Improve const assignment errors
Closes https://github.com/Vexu/arocc/issues/422
The type printing changes look correct at least compared to clang. Did you compare with gcc?
I did. But gcc issues diagnostics in a different way compared to clang.
void foo() {
const int a[2];
a[2] = 1;
}
error: assignment of read-only location 'a[2]'
There are probably other cases where the type is printed but just matching Clang is also fine.
Sorry for the delay, just didn't have enough time. Looks like CI failure is unrelated to this pr @Vexu
This still doesn't cover every case:
void foo(void) {
const int arr[2][2] = { 0, 1, 2, 3};
arr[0][0] = 1;
}
This is quite close to being ready though so if you want I can take it over and fix the few remaining issues.
Looks like CI failure is unrelated to this pr
I fixed it in https://github.com/Vexu/arocc/pull/860/commits/891adc96b1067b8189daed59a6f601c2e361e8d6
This still doesn't cover every case:
void foo(void) { const int arr[2][2] = { 0, 1, 2, 3}; arr[0][0] = 1; }This is quite close to being ready though so if you want I can take it over and fix the few remaining issues.
Looks like CI failure is unrelated to this pr
I fixed it in 891adc9
Tbh I want to finish it myself. To save time, it would be great if you listed all the code snippets that should issue the diagnostic. After that, I'll be ready to send the final commit
Tbh I want to finish it myself.
That's fine too.
To save time, it would be great if you listed all the code snippets that should issue the diagnostic. After that, I'll be ready to send the final commit
Every case that would previously cause a .not_assignable diagnostic should still produce some diagnostic after this, easiest way to achieve that is to just fall back on .not_assignable if you can't give a more specific diagnostic.
It'd also be nice if you could replace all those inline fors with loop: switch like constructs.
@Vexu can you take a look at it now?
Still missing cases:
void foo(void) {
const struct {
struct {
int a;
} a;
} a = {1};
a.a.a = 2;
}
int const* foo(void);
void bar(void) {
foo()[0] = 1;
}
@Vexu can you take a look at it now please?
Thanks!