-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Description
$ cat test.c
int g __attribute__((availability(macosx,introduced=15)));
void foo(int);
void test1(void) {
int i1 = 1, i2 = g;
foo(i2);
foo(i1);
}
void test2(void) {
int i1 = g;
int i2 = i1;
foo(i2);
}
$ clang -c test.c -target arm64-apple-macosx14.0.0 -fdiagnostics-parseable-fixits
test.c:5:20: warning: 'g' is only available on macOS 15 or newer [-Wunguarded-availability-new]
5 | int i1 = 1, i2 = g;
| ^
test.c:1:5: note: 'g' has been marked as being introduced in macOS 15 here, but the deployment target is macOS
14.0.0
1 | int g __attribute__((availability(macosx,introduced=15)));
| ^
test.c:5:20: note: enclose 'g' in a __builtin_available check to silence this warning
5 | int i1 = 1, i2 = g;
| ^
6 | foo(i2);
|
fix-it:"test.c":{5:3-5:3}:"if (__builtin_available(macOS 15, *)) {\n "
fix-it:"test.c":{6:11-6:11}:"\n } else {\n // Fallback on earlier versions\n }"
test.c:11:12: warning: 'g' is only available on macOS 15 or newer [-Wunguarded-availability-new]
11 | int i1 = g;
| ^
test.c:1:5: note: 'g' has been marked as being introduced in macOS 15 here, but the deployment target is macOS
14.0.0
1 | int g __attribute__((availability(macosx,introduced=15)));
| ^
test.c:11:12: note: enclose 'g' in a __builtin_available check to silence this warning
11 | int i1 = g;
| ^
12 | int i2 = i1;
|
fix-it:"test.c":{11:3-11:3}:"if (__builtin_available(macOS 15, *)) {\n "
fix-it:"test.c":{12:15-12:15}:"\n } else {\n // Fallback on earlier versions\n }"
The second and the fourth fixits are incorrect as they would cause compilation errors.
fix-it:"test.c":{6:11-6:11}:"\n } else {\n // Fallback on earlier versions\n }" should be applied on line 7 so that foo(i1); is placed within the same scope as the declaration of i1.
fix-it:"test.c":{12:15-12:15}:"\n } else {\n // Fallback on earlier versions\n }" should be applied on line 13 so that foo(i2); is placed within the same scope as the declaration of i2.
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer