From ae055c2fa24a68c1908913a2be8081fcb54fd610 Mon Sep 17 00:00:00 2001 From: David Tarditi Date: Mon, 17 Jul 2023 22:30:58 -0700 Subject: [PATCH 1/3] Fix failing Checked C tests on MacOS. --- clang/test/CheckedC/checked-scope/variadic-functions-non-win.c | 2 +- clang/test/CheckedC/parsing/invalid-where-clause.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/clang/test/CheckedC/checked-scope/variadic-functions-non-win.c b/clang/test/CheckedC/checked-scope/variadic-functions-non-win.c index f1983819200a..1df5b4a47c4c 100644 --- a/clang/test/CheckedC/checked-scope/variadic-functions-non-win.c +++ b/clang/test/CheckedC/checked-scope/variadic-functions-non-win.c @@ -1,4 +1,4 @@ -// UNSUPPORTED: system-windows +// UNSUPPORTED: !linux // Test calls to variadic functions in checked scopes. // Some -Wformat error messages are different between linux and windows diff --git a/clang/test/CheckedC/parsing/invalid-where-clause.c b/clang/test/CheckedC/parsing/invalid-where-clause.c index 9014217fa6ec..3fdf0978a018 100644 --- a/clang/test/CheckedC/parsing/invalid-where-clause.c +++ b/clang/test/CheckedC/parsing/invalid-where-clause.c @@ -17,7 +17,6 @@ void invalid_cases_nullstmt(_Nt_array_ptr p, int a, int b) { _Where p : ; // expected-error {{expected bounds expression}} _Where p : count(x); // expected-error {{use of undeclared identifier 'x'}} _Where q : count(0); // expected-error {{use of undeclared identifier q}} - _Where (); // expected-error {{expected bounds declaration or equality expression in where clause}} _Where a = 0; // expected-error {{expected comparison operator in equality expression}} _Where a == 1 _And a; // expected-error {{invalid expression in where clause, expected bounds declaration or equality expression}} _Where a _And a == 1; // expected-error {{invalid expression in where clause, expected bounds declaration or equality expression}} From 0ddd8d823af828b481e222b02a67e7e8f8d8375b Mon Sep 17 00:00:00 2001 From: David Tarditi Date: Tue, 18 Jul 2023 12:34:34 -0700 Subject: [PATCH 2/3] Fix broken MacOS Checked C variadic args test. --- ...s-non-win.c => variadic-functions-linux.c} | 0 .../checked-scope/variadic-functions-macos.c | 31 +++++++++++++++++++ .../checked-scope/variadic-functions-win.c | 7 ++--- 3 files changed, 34 insertions(+), 4 deletions(-) rename clang/test/CheckedC/checked-scope/{variadic-functions-non-win.c => variadic-functions-linux.c} (100%) create mode 100644 clang/test/CheckedC/checked-scope/variadic-functions-macos.c diff --git a/clang/test/CheckedC/checked-scope/variadic-functions-non-win.c b/clang/test/CheckedC/checked-scope/variadic-functions-linux.c similarity index 100% rename from clang/test/CheckedC/checked-scope/variadic-functions-non-win.c rename to clang/test/CheckedC/checked-scope/variadic-functions-linux.c diff --git a/clang/test/CheckedC/checked-scope/variadic-functions-macos.c b/clang/test/CheckedC/checked-scope/variadic-functions-macos.c new file mode 100644 index 000000000000..39e1fda4ce14 --- /dev/null +++ b/clang/test/CheckedC/checked-scope/variadic-functions-macos.c @@ -0,0 +1,31 @@ +// UNSUPPORTED: !darwin + +// Test calls to variadic functions in checked scopes. +// Some -Wformat error messages are different between Linux, Windows +// and MacOS. This file contains MacOS specific ests. The common +// tests are in variadic-functions.c. + +// RUN: %clang_cc1 -fcheckedc-extension -verify \ +// RUN: -verify-ignore-unexpected=note %s + +int printf(const char *format : itype(_Nt_array_ptr), ...); +int MyPrintf(const char *format : itype(_Nt_array_ptr), ...) + __attribute__((format(printf, 1, 2))); + +int scanf(const char *format : itype(_Nt_array_ptr), ...); +int MyScanf(const char *format : itype(_Nt_array_ptr), ...) + __attribute__((format(scanf, 1, 2))); + +void f1 (_Nt_array_ptr p) { +_Checked { + printf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}} + MyPrintf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}} + scanf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}} + MyScanf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}} + + printf("%Li", (long long) 42); // expected-error {{length modifier 'L' results in undefined behavior or no effect with 'i' conversion specifier}} + MyPrintf("%Li", (long long) 42); // expected-error {{length modifier 'L' results in undefined behavior or no effect with 'i' conversion specifier}} + 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'}} + 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'}} +} +} diff --git a/clang/test/CheckedC/checked-scope/variadic-functions-win.c b/clang/test/CheckedC/checked-scope/variadic-functions-win.c index 78ccfce7db78..702095823570 100644 --- a/clang/test/CheckedC/checked-scope/variadic-functions-win.c +++ b/clang/test/CheckedC/checked-scope/variadic-functions-win.c @@ -1,10 +1,9 @@ // UNSUPPORTED: !windows // Test calls to variadic functions in checked scopes. -// Some -Wformat error messages are different between linux and windows -// systems. This file contains windows-specific tests. The non-windows tests -// are in variadic-functions-non-win.c and the common tests are in -// variadic-functions.c. +// Some -Wformat error messages are different between Linux, Windows, +// and MacOS. This file contains windows-specific tests. The common +// tests are in variadic-functions.c. // RUN: %clang_cc1 -fcheckedc-extension -verify \ // RUN: -verify-ignore-unexpected=note %s From e3032a615eac4b0b6564c85d6dbb698118343f88 Mon Sep 17 00:00:00 2001 From: David Tarditi Date: Tue, 18 Jul 2023 16:32:55 -0700 Subject: [PATCH 3/3] Update comment. --- .../test/CheckedC/checked-scope/variadic-functions-linux.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/test/CheckedC/checked-scope/variadic-functions-linux.c b/clang/test/CheckedC/checked-scope/variadic-functions-linux.c index 1df5b4a47c4c..62a76bfda9d8 100644 --- a/clang/test/CheckedC/checked-scope/variadic-functions-linux.c +++ b/clang/test/CheckedC/checked-scope/variadic-functions-linux.c @@ -1,10 +1,9 @@ // UNSUPPORTED: !linux // Test calls to variadic functions in checked scopes. -// Some -Wformat error messages are different between linux and windows -// systems. This file contains non-windows-specific tests. The windows tests -// are in variadic-functions-win.c and the common tests are in -// variadic-functions.c. +// Some -Wformat error messages are different between Linux, Windows, +// and MacOS. This file contains Linux specific tests. The common +// tests are in variadic-functions.c. // RUN: %clang_cc1 -fcheckedc-extension -verify \ // RUN: -verify-ignore-unexpected=note %s