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

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 01/11] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y

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

2025-04-05 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,68 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * + * Adds an operator to get the length of an array. Note that WG14 N3469 renamed + * this operator to _Countof. + */ -

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

2025-04-05 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Did WG14 considered some sort of macros for this feature? Otherwise I'd be > tempted to ask you to add something to `__has_feature`. I can see user > wanting to use `_Countof` when available and fallback to something else when > not. There is weak consensus to add `stdco

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

2025-04-05 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > > So you want this to be a FEATURE in C2y and an EXTENSION in older language > > modes? > > Presumably yes. > > > And when we get the countof macro in a few months, this becomes unnecessary? > > Are most users going to include `stdcountof.h` ? > > My assumption is that

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

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 1/3] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y ad

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

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 1/9] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y ad

[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 Aaron Ballman via cfe-commits
AaronBallman 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! It turns out it was a bit more involved than I expected because I di

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

2025-03-27 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed 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] [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 + * +

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

2025-03-27 Thread Aaron Ballman 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 Aaron Ballman 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 Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 01/10] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y

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

2025-03-27 Thread Shafik Yaghmour 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 Shafik Yaghmour 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 Aaron Ballman via cfe-commits
AaronBallman wrote: > > > So you want this to be a FEATURE in C2y and an EXTENSION in older > > > language modes? > > > > > > Presumably yes. > > > And when we get the countof macro in a few months, this becomes > > > unnecessary? > > > > > > Are most users going to include `stdcountof.h` ?

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

2025-03-27 Thread via cfe-commits
@@ -14926,6 +14926,42 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr( return false; } + case UETT_CountOf: { +QualType Ty = E->getTypeOfArgument(); +assert(Ty->isArrayType()); + +// We don't need to worry about array element qualifiers, so getting t

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

2025-03-27 Thread via cfe-commits
https://github.com/cor3ntin approved this pull request. Thanks! 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 Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 1/8] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y ad

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

2025-03-27 Thread Aaron Ballman via cfe-commits
@@ -141,6 +141,12 @@ C2y Feature Support paper also introduced octal and hexadecimal delimited escape sequences (e.g., ``"\x{12}\o{12}"``) which are also supported as an extension in older C language modes. +- Implemented `WG14 N3369

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

2025-03-27 Thread via cfe-commits
cor3ntin wrote: > So you want this to be a FEATURE in C2y and an EXTENSION in older language > modes? Presumably yes. > And when we get the countof macro in a few months, this becomes unnecessary? Are most users going to include `stdcountof.h` ? My assumption is that they would not, so havi

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

2025-03-27 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,68 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * + * Adds an operator to get the length of an array. Note that WG14 N3469 renamed + * this operator to _Countof. + */ -

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

2025-03-27 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > > There is weak consensus to add `stdcountof.h` which supplies a `countof` > > macro. However, there's no changes to the standard which add one (yet), so > > I figured that can be done in a follow-up. > > Then I'd really like a feature. We already have a bunch, It makes s

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

2025-03-27 Thread Aaron Ballman via cfe-commits
@@ -14926,6 +14926,42 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr( return false; } + case UETT_CountOf: { +QualType Ty = E->getTypeOfArgument(); +assert(Ty->isArrayType()); + +// We don't need to worry about array element qualifiers, so getting t

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

2025-03-27 Thread via cfe-commits
cor3ntin wrote: > There is weak consensus to add `stdcountof.h` which supplies a `countof` > macro. However, there's no changes to the standard which add one (yet), so I > figured that can be done in a follow-up. Then I'd really like a feature. We already have a bunch, It makes sense to add on

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

2025-03-27 Thread via cfe-commits
@@ -0,0 +1,68 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * + * Adds an operator to get the length of an array. Note that WG14 N3469 renamed + * this operator to _Countof. + */ -

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

2025-03-27 Thread via cfe-commits
@@ -14926,6 +14926,42 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr( return false; } + case UETT_CountOf: { +QualType Ty = E->getTypeOfArgument(); +assert(Ty->isArrayType()); + +// We don't need to worry about array element qualifiers, so getting t

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

2025-03-27 Thread via cfe-commits
@@ -0,0 +1,68 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * + * Adds an operator to get the length of an array. Note that WG14 N3469 renamed + * this operator to _Countof. + */ -

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

2025-03-27 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 1/7] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y ad

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

2025-03-27 Thread Aaron Ballman via cfe-commits
@@ -14926,6 +14926,42 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr( return false; } + case UETT_CountOf: { AaronBallman wrote: I'll add support for this there. https://github.com/llvm/llvm-project/pull/133125 ___

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

2025-03-27 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 1/6] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y ad

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

2025-03-27 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 1/5] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y ad

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

2025-03-27 Thread Aaron Ballman via cfe-commits
@@ -14926,6 +14926,42 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr( return false; } + case UETT_CountOf: { +QualType Ty = E->getTypeOfArgument(); +assert(Ty->isArrayType()); + +// We don't need to worry about array element qualifiers, so getting t

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

2025-03-27 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,68 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * + * Adds an operator to get the length of an array. Note that WG14 N3469 renamed + * this operator to _Countof. + */ -

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

2025-03-27 Thread Aaron Ballman via cfe-commits
@@ -4338,6 +4338,21 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E, E->getSourceRange(), ExprKind)) return true; + if (ExprKind == UETT_CountOf) { +// The type has to be an array type. We already checked for incomplete +

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

2025-03-27 Thread A. Jiang via cfe-commits
@@ -141,6 +141,12 @@ C2y Feature Support paper also introduced octal and hexadecimal delimited escape sequences (e.g., ``"\x{12}\o{12}"``) which are also supported as an extension in older C language modes. +- Implemented `WG14 N3369

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

2025-03-27 Thread via cfe-commits
@@ -4338,6 +4338,21 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E, E->getSourceRange(), ExprKind)) return true; + if (ExprKind == UETT_CountOf) { +// The type has to be an array type. We already checked for incomplete +

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

2025-03-27 Thread via cfe-commits
@@ -14926,6 +14926,42 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr( return false; } + case UETT_CountOf: { cor3ntin wrote: Did you consider the new interpreter? @tbaederr https://github.com/llvm/llvm-project/pull/133125 ___

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

2025-03-27 Thread via cfe-commits
@@ -0,0 +1,68 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * + * Adds an operator to get the length of an array. Note that WG14 N3469 renamed + * this operator to _Countof. + */ -

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

2025-03-27 Thread via cfe-commits
https://github.com/cor3ntin commented: Did WG14 considered some sort of macros for this feature? Otherwise I'd be tempted to ask you to add something to `__has_feature`. I can see user wanting to use `_Countof` when available and fallback to something else when not. https://github.com/llvm/llv

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

2025-03-27 Thread via cfe-commits
https://github.com/cor3ntin 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-26 Thread James Y Knight via cfe-commits
https://github.com/jyknight approved this pull request. 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-26 Thread James Y Knight via cfe-commits
jyknight wrote: > We make a VariableArrayType whose element type is a VariableArrayType rather > than a ConstantArrayType of size 7 whose element type is a VariableArrayType. Yea. Up till now I think there was no observable difference between the outer array having a constant or variable boun

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

2025-03-26 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: Good catch on the VLA test cases @jyknight! It turns out we model VLAs very oddly in the type system. Given: ``` extern int n; int array[7][n]; ``` We make a VariableArrayType whose element type is a VariableArrayType rather than a ConstantArrayType of size 7 whose element t

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

2025-03-26 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 1/4] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y ad

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,92 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -std=c2y -emit-llvm -o - %s | FileCheck %s + +// This tests the codegen behavior for _Countof. +// CHECK-LABEL: define dso_local i32 @test1( +

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

2025-03-26 Thread James Y Knight via cfe-commits
@@ -0,0 +1,92 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -std=c2y -emit-llvm -o - %s | FileCheck %s + +// This tests the codegen behavior for _Countof. +// CHECK-LABEL: define dso_local i32 @test1( +

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * + * Adds an operator to get the length of an array. Note that WG14 N3469 renamed + * this operator to _Countof. + */ + +int gl

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

2025-03-26 Thread James Y Knight via cfe-commits
@@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * + * Adds an operator to get the length of an array. Note that WG14 N3469 renamed + * this operator to _Countof. + */ + +int gl

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * + * Adds an operator to get the length of an array. Note that WG14 N3469 renamed + * this operator to _Countof. + */ + +int gl

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

2025-03-26 Thread James Y Knight via cfe-commits
@@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * + * Adds an operator to get the length of an array. Note that WG14 N3469 renamed + * this operator to _Countof. + */ + +int gl

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

2025-03-26 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Although C++ might have good alternatives, that's not so helpful for C > headers being included from C++ that might end up using this (e.g. some > static inline function in a system header). (i.e. if it's not too much effort > to do, I would encourage exposing it in C++)

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

2025-03-26 Thread Jessica Clarke via cfe-commits
jrtc27 wrote: Although C++ might have good alternatives, that's not so helpful for C headers being included from C++ that might end up using this (e.g. some static inline function in a system header). https://github.com/llvm/llvm-project/pull/133125

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

2025-03-26 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) Changes C2y adds the _Countof operator which returns the number of elements in an array. As with sizeof, _Countof either accepts a parenthesized type name or an expression. Its operand must be (of) an array ty

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

2025-03-26 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/133125 C2y adds the _Countof operator which returns the number of elements in an array. As with sizeof, _Countof either accepts a parenthesized type name or an expression. Its operand must be (of) an array type.

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

2025-03-26 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 15f5a7a3ec71c624cea0cbdf02e3c5205ba81d9d 75ef42d644da9136fb07014ade18b6be137426a1 --e

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

2025-03-26 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman 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