[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 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:

[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] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Alejandro Colomar via cfe-commits
alejandro-colomar wrote: > > Thanks @AaronBallman !! I am still working on my patch, so just for > > learning about Clang internals, I'll try to finish mine, and compare it to > > yours. :-) > > Sorry for stealing this one out from under you! No problem. :-) > It turns out it was a bit more

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Alejandro Colomar via cfe-commits
@@ -0,0 +1,117 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -fexperimental-new-constant-interpreter -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * +

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

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

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

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

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Alejandro Colomar via cfe-commits
alejandro-colomar wrote: Thanks @AaronBallman !! I am still working on my patch, so just for learning about Clang internals, I'll try to finish mine, and compare it to yours. :-) Sorry for being so slow! Cheers, Alex https://github.com/llvm/llvm-project/pull/133125 _

[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
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 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 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
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 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-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-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-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 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 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 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
@@ -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-05-05 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar updated https://github.com/llvm/llvm-project/pull/13 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Ar

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

2025-05-05 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-05-05 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-05-05 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar updated https://github.com/llvm/llvm-project/pull/13 >From f4f1f5661b0bdb9a11dbeafd9c7242592c40ff4a 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-05-05 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-05-05 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar ready_for_review 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-05-05 Thread Alejandro Colomar via cfe-commits
alejandro-colomar wrote: @AaronBallman This is ready. Still, my patches for GCC had another set of tests that are completely missing here: run-time tests (assert(3)) for non-ICE (so, VLA). Maybe you could add a set of tests that are run (not just compiled). https://github.com/llvm/llvm-proje

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

2025-05-05 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-05-05 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar updated https://github.com/llvm/llvm-project/pull/13 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Ar

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

2025-05-05 Thread Alejandro Colomar 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-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 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: 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
@@ -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
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: @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-05-07 Thread Alejandro Colomar via cfe-commits
alejandro-colomar wrote: > > @AaronBallman This is ready. Still, my patches for GCC had another set of > > tests that are completely missing here: run-time tests (assert(3)) for > > non-ICE (so, VLA). Maybe you could add a set of tests that are run (not > > just compiled). > > We don't do end

[clang] [C2y] Add stdcountof.h (PR #140890)

2025-05-21 Thread Alejandro Colomar via cfe-commits
alejandro-colomar wrote: > > Thanks! > > For the first commit: > > ``` > > Suggested-by: Alejandro Colomar > > ``` > > Happy to add it, Thanks! :) > but for my own education: what's that do? :-D

[clang] [C2y] Add stdcountof.h (PR #140890)

2025-05-21 Thread Alejandro Colomar via cfe-commits
https://github.com/alejandro-colomar approved this pull request. Thanks! For the first commit: ``` Suggested-by: Alejandro Colomar ``` https://github.com/llvm/llvm-project/pull/140890 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://li

[clang] [Clang] Make the result type of sizeof/pointer subtraction/size_t lit… (PR #136542)

2025-05-21 Thread Alejandro Colomar via cfe-commits
alejandro-colomar wrote: Hi! I don't see it mentioned, so I'll note it down here. The standard allows this: ```c typedef typeof(sizeof(0)) size_t; ``` as a valid implementation of `size_t`. It would be good to keep this in mind to not accidentally break it. (Not saying this would break it

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-05-21 Thread Alejandro Colomar via cfe-commits
alejandro-colomar wrote: @AaronBallman I'm not sure who's responsible for `` in LLVM. In GCC it's a header provided by the compiler. I see that this PR does not add the header, so I was wondering if that's to be added in a separate commit, or if it's not supported by Clang and depends on l

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-05-21 Thread Alejandro Colomar via cfe-commits
alejandro-colomar wrote: > > @AaronBallman > > I'm not sure who's responsible for `` in LLVM. > > Yeah, it's never really clear who is expected to provide these headers. > > > In GCC it's a header provided by the compiler. I see that this PR does not > > add the header, so I was wondering if t

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-05-21 Thread Alejandro Colomar via cfe-commits
alejandro-colomar wrote: No problem. Thanks! :-D https://github.com/llvm/llvm-project/pull/133125 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits