Skip to content

Commit ad2a733

Browse files
authored
Fix a failing test Checked C on MacOS (#1215)
One of the Checked C varargs tests has some error messages that are OS specific. There are test cases specific to Linux and Windows for them. Add test cases specific to MacOS. Testing: check-clang tests pass on Windows and MacOS with this change. Co-authored-by: David Tarditi <[email protected]>
1 parent 190404b commit ad2a733

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

clang/test/CheckedC/checked-scope/variadic-functions-non-win.c renamed to clang/test/CheckedC/checked-scope/variadic-functions-linux.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
// UNSUPPORTED: system-windows
1+
// UNSUPPORTED: !linux
22

33
// Test calls to variadic functions in checked scopes.
4-
// Some -Wformat error messages are different between linux and windows
5-
// systems. This file contains non-windows-specific tests. The windows tests
6-
// are in variadic-functions-win.c and the common tests are in
7-
// variadic-functions.c.
4+
// Some -Wformat error messages are different between Linux, Windows,
5+
// and MacOS. This file contains Linux specific tests. The common
6+
// tests are in variadic-functions.c.
87

98
// RUN: %clang_cc1 -fcheckedc-extension -verify \
109
// RUN: -verify-ignore-unexpected=note %s
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// UNSUPPORTED: !darwin
2+
3+
// Test calls to variadic functions in checked scopes.
4+
// Some -Wformat error messages are different between Linux, Windows
5+
// and MacOS. This file contains MacOS specific ests. The common
6+
// tests are in variadic-functions.c.
7+
8+
// RUN: %clang_cc1 -fcheckedc-extension -verify \
9+
// RUN: -verify-ignore-unexpected=note %s
10+
11+
int printf(const char *format : itype(_Nt_array_ptr<const char>), ...);
12+
int MyPrintf(const char *format : itype(_Nt_array_ptr<const char>), ...)
13+
__attribute__((format(printf, 1, 2)));
14+
15+
int scanf(const char *format : itype(_Nt_array_ptr<const char>), ...);
16+
int MyScanf(const char *format : itype(_Nt_array_ptr<const char>), ...)
17+
__attribute__((format(scanf, 1, 2)));
18+
19+
void f1 (_Nt_array_ptr<char> p) {
20+
_Checked {
21+
printf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}}
22+
MyPrintf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}}
23+
scanf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}}
24+
MyScanf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}}
25+
26+
printf("%Li", (long long) 42); // expected-error {{length modifier 'L' results in undefined behavior or no effect with 'i' conversion specifier}}
27+
MyPrintf("%Li", (long long) 42); // expected-error {{length modifier 'L' results in undefined behavior or no effect with 'i' conversion specifier}}
28+
scanf("%Li", (long long) 42); // expected-error {{length modifier 'L' results in undefined behavior or no effect with 'i' conversion specifier}} expected-error {{format specifies type 'long long *' but the argument has type 'long long'}}
29+
MyScanf("%Li", (long long) 42); // expected-error {{length modifier 'L' results in undefined behavior or no effect with 'i' conversion specifier}} expected-error {{format specifies type 'long long *' but the argument has type 'long long'}}
30+
}
31+
}

clang/test/CheckedC/checked-scope/variadic-functions-win.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// UNSUPPORTED: !windows
22

33
// Test calls to variadic functions in checked scopes.
4-
// Some -Wformat error messages are different between linux and windows
5-
// systems. This file contains windows-specific tests. The non-windows tests
6-
// are in variadic-functions-non-win.c and the common tests are in
7-
// variadic-functions.c.
4+
// Some -Wformat error messages are different between Linux, Windows,
5+
// and MacOS. This file contains windows-specific tests. The common
6+
// tests are in variadic-functions.c.
87

98
// RUN: %clang_cc1 -fcheckedc-extension -verify \
109
// RUN: -verify-ignore-unexpected=note %s

clang/test/CheckedC/parsing/invalid-where-clause.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ void invalid_cases_nullstmt(_Nt_array_ptr<char> p, int a, int b) {
1717
_Where p : ; // expected-error {{expected bounds expression}}
1818
_Where p : count(x); // expected-error {{use of undeclared identifier 'x'}}
1919
_Where q : count(0); // expected-error {{use of undeclared identifier q}}
20-
_Where (); // expected-error {{expected bounds declaration or equality expression in where clause}}
2120
_Where a = 0; // expected-error {{expected comparison operator in equality expression}}
2221
_Where a == 1 _And a; // expected-error {{invalid expression in where clause, expected bounds declaration or equality expression}}
2322
_Where a _And a == 1; // expected-error {{invalid expression in where clause, expected bounds declaration or equality expression}}

0 commit comments

Comments
 (0)