[clang] Add more tests for _Countof (PR #133333)

2025-04-07 Thread Alejandro Colomar via cfe-commits
@@ -144,3 +177,13 @@ void test_compound_literals() { static_assert(_Countof((int[2]){}) == 2); static_assert(_Countof((int[]){1, 2, 3, 4}) == 4); } + +static int test_f1(); +static int test_f2(); // expected-warning {{never defined}} alejandro-colomar w

[clang] Add more tests for _Countof (PR #133333)

2025-04-07 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar updated https://github.com/llvm/llvm-project/pull/13 >From 3660f83ad4beb674127a2033d1662c3cb15ace67 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 27 Mar 2025 23:51:18 +0100 Subject: [PATCH] Add more tests for _Countof Link:

[clang] Add more tests for _Countof (PR #133333)

2025-04-07 Thread Alejandro Colomar via cfe-commits
@@ -144,3 +177,13 @@ void test_compound_literals() { static_assert(_Countof((int[2]){}) == 2); static_assert(_Countof((int[]){1, 2, 3, 4}) == 4); } + +static int test_f1(); +static int test_f2(); // expected-warning {{never defined}} + +void test_symbols() { + int a[gl

[clang] Add more tests for _Countof (PR #133333)

2025-04-07 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-04-07 Thread Alejandro Colomar via cfe-commits
@@ -121,10 +150,14 @@ void test_typedefs() { static_assert(_Countof(*x) == 12); } -void test_zero_size_arrays() { +void test_zero_size_arrays(int n) { int array[0]; // expected-warning {{zero size arrays are an extension}} static_assert(_Countof(array) == 0); static

[clang] Add more tests for _Countof (PR #133333)

2025-04-07 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-04-07 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar updated https://github.com/llvm/llvm-project/pull/13 >From eb63ad49de452c88fe7739172da9c17eadfce2d4 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 27 Mar 2025 23:51:18 +0100 Subject: [PATCH] Add more tests for _Countof Link:

[clang] Add more tests for _Countof (PR #133333)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -144,3 +177,13 @@ void test_compound_literals() { static_assert(_Countof((int[2]){}) == 2); static_assert(_Countof((int[]){1, 2, 3, 4}) == 4); } + +static int test_f1(); +static int test_f2(); // expected-warning {{never defined}} AaronBallman wrote:

[clang] Add more tests for _Countof (PR #133333)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -121,10 +150,14 @@ void test_typedefs() { static_assert(_Countof(*x) == 12); } -void test_zero_size_arrays() { +void test_zero_size_arrays(int n) { int array[0]; // expected-warning {{zero size arrays are an extension}} static_assert(_Countof(array) == 0); static

[clang] Add more tests for _Countof (PR #133333)

2025-04-06 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-04-06 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-04-06 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar updated https://github.com/llvm/llvm-project/pull/13 >From b8f95e71efec49e90ed20bc1f78fe2055caccece Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 27 Mar 2025 23:51:18 +0100 Subject: [PATCH] Add more tests for _Countof Link:

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Aaron Ballman via cfe-commits
@@ -102,6 +126,11 @@ void test_unspecified_array_length() { static_assert(_Countof(**x) == 3); } +void test_completed_array() { + int a[] = {1, 2, global_num}; + static_assert(_Countof(a) == 3); AaronBallman wrote: Yeah it was because of the `errno` causi

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar updated https://github.com/llvm/llvm-project/pull/13 >From 6c5c502ca376f6097ee783ed1f4f8bb1e2a3b2a0 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 27 Mar 2025 23:51:18 +0100 Subject: [PATCH] Add more tests for _Countof Link:

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
@@ -102,6 +126,11 @@ void test_unspecified_array_length() { static_assert(_Countof(**x) == 3); } +void test_completed_array() { + int a[] = {1, 2, global_num}; + static_assert(_Countof(a) == 3); alejandro-colomar wrote: Actually, I don't see it anymore.

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
@@ -102,6 +126,11 @@ void test_unspecified_array_length() { static_assert(_Countof(**x) == 3); } +void test_completed_array() { + int a[] = {1, 2, global_num}; + static_assert(_Countof(a) == 3); alejandro-colomar wrote: Or maybe it's because it was using

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar updated https://github.com/llvm/llvm-project/pull/13 >From a651447d3faca50423afa7fe528960afd58d8711 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 27 Mar 2025 23:51:18 +0100 Subject: [PATCH] Add more tests for _Countof Link:

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
@@ -102,6 +126,11 @@ void test_unspecified_array_length() { static_assert(_Countof(**x) == 3); } +void test_completed_array() { + int a[] = {1, 2, global_num}; + static_assert(_Countof(a) == 3); alejandro-colomar wrote: @AaronBallman This test seems to ha

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
@@ -102,6 +126,11 @@ void test_unspecified_array_length() { static_assert(_Countof(**x) == 3); } +void test_completed_array() { + int a[] = {1, 2, errno}; alejandro-colomar wrote: I could use the global_num here. I wrote that one after having used errno,

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Aaron Ballman via cfe-commits
@@ -144,3 +177,13 @@ void test_compound_literals() { static_assert(_Countof((int[2]){}) == 2); static_assert(_Countof((int[]){1, 2, 3, 4}) == 4); } + +static int test_f1(); +static int test_f2(); // expected-warning {{never defined}} + +void test_symbols() { + int a[gl

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Aaron Ballman via cfe-commits
@@ -102,6 +126,11 @@ void test_unspecified_array_length() { static_assert(_Countof(**x) == 3); } +void test_completed_array() { + int a[] = {1, 2, errno}; AaronBallman wrote: Ah, in that case, go with a local or global variable (we don't typically pull in

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
@@ -144,3 +177,13 @@ void test_compound_literals() { static_assert(_Countof((int[2]){}) == 2); static_assert(_Countof((int[]){1, 2, 3, 4}) == 4); } + +static int test_f1(); +static int test_f2(); // expected-warning {{never defined}} + +void test_symbols() { + int a[gl

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Alejandro Colomar via cfe-commits
@@ -102,6 +126,11 @@ void test_unspecified_array_length() { static_assert(_Countof(**x) == 3); } +void test_completed_array() { + int a[] = {1, 2, errno}; alejandro-colomar wrote: I wanted something that wasn't an ICE, and which the compiler wasn't allowed

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Aaron Ballman via cfe-commits
@@ -144,3 +177,13 @@ void test_compound_literals() { static_assert(_Countof((int[2]){}) == 2); static_assert(_Countof((int[]){1, 2, 3, 4}) == 4); } + +static int test_f1(); +static int test_f2(); // expected-warning {{never defined}} + +void test_symbols() { + int a[gl

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Aaron Ballman via cfe-commits
@@ -102,6 +126,11 @@ void test_unspecified_array_length() { static_assert(_Countof(**x) == 3); } +void test_completed_array() { + int a[] = {1, 2, errno}; AaronBallman wrote: Best not to use `errno` here, just replace with `3`. https://github.com/llvm/llv

[clang] Add more tests for _Countof (PR #133333)

2025-03-28 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: Thanks for the additional test coverage! It looks like precommit CI found some issues with your tests that should be addressed: https://buildkite.com/llvm-project/github-pull-requests/builds/162502#0195d9e8-2c29-426e-9be0-afda7efd7d93 https://github.c

[clang] Add more tests for _Countof (PR #133333)

2025-03-27 Thread A. Jiang via cfe-commits
@@ -81,6 +89,22 @@ void test_with_function_param(int array[12], int (*array_ptr)[12], int static_ar (void)_Countof(static_array); // expected-error {{'_Countof' requires an argument of array type; 'int *' invalid}} } +void test_func_fix_fix(int i, char (*a)[3][5], int (*x)

[clang] Add more tests for _Countof (PR #133333)

2025-03-27 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-03-27 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar edited https://github.com/llvm/llvm-project/pull/13 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-03-27 Thread via cfe-commits
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it

[clang] Add more tests for _Countof (PR #133333)

2025-03-27 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar created https://github.com/llvm/llvm-project/pull/13 Cc: @AaronBallman I haven't yet tried to run these tests. I've pasted and adapted them from the ones I wrote for my own implementation. >From c9ce60fef4e3af6faaea2a7e7f41b3866856d237 Mon Sep 17 00: