[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-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 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 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-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 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] [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
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] [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
@@ -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 + * +