Message ID | cover.1729622352.git.alx@kernel.org |
---|---|
Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 90F023858C32 for <patchwork@sourceware.org>; Tue, 22 Oct 2024 18:49:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by sourceware.org (Postfix) with ESMTPS id C820F3858D21 for <gcc-patches@gcc.gnu.org>; Tue, 22 Oct 2024 18:48:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C820F3858D21 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C820F3858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=139.178.84.217 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729622896; cv=none; b=HRVweOhvojDifuEsK4qFC8SujEsQXjbVEujpGDsaafN4hK5C9/Rn7tn8jbK0RIcIVblmMZvjwN2ivOHOibXkilx5m3MBUrjrCMFqdy2fn6KLP0Q09yJK0YNzC+pY7xAcnqXqwfyn3Vb/Pwne/Gz0p+oHcPv5gVWxS+GhJ73dONQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729622896; c=relaxed/simple; bh=7poyGnsfp3z+olkYsej3incrREciA9dRGVqIkIkj3f4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=szd2CXMgl7x3ONDUN+Wz0VuD+FlfoazxMA8nA/SmuyIyDhXYtZDTOaJNIpBL2He529+sk9U3O1bIkrnyFY8bCqohubrFCkBtSEnXylTDelOqagN06KnGcHW+GC2xGlWdEhnmg+AtY1D5w4SeANnxA9yHNEznRwMLcAjhCNNtMBU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 363025C593F; Tue, 22 Oct 2024 18:48:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D78DFC4CEC3; Tue, 22 Oct 2024 18:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729622890; bh=7poyGnsfp3z+olkYsej3incrREciA9dRGVqIkIkj3f4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lIAAS8W5SBTp4q2HiwLNUJ/rtWTpWaf0j9yRFEPQ2rZsRxp3086uxltIjPh1HdZP5 xKNza4sg7X32XQHnNnZlYzQWlwsOvkXpp2jRk6YC8N901WkcL3BIehqDXgF7sQDPT+ G7HCGLaNTVRO+q02sBnEdYGa+ecjkiFA2NARqRb5qkv96OZinVVSIbZONmt/Yo4sIM Vk6VUmxwCsH6xAQOTO5tnK2mlfUKQS00BgkIE13fVJ3Oc+Anv478ZYBd1uvUa77mCi F6FpB0nQgARARK+etlA15uLo1xFyk9nZB1rWlYfJ8cAmeMrPP10VuMikrru7xq92U4 cLbtuMLeZqZdg== Date: Tue, 22 Oct 2024 20:48:07 +0200 From: Alejandro Colomar <alx@kernel.org> To: gcc-patches@gcc.gnu.org, josmyers@redhat.com Cc: Alejandro Colomar <alx@kernel.org> Subject: [PATCH v17 0/2] c: Add __countof__ operator Message-ID: <cover.1729622352.git.alx@kernel.org> X-Mailer: git-send-email 2.45.2 References: <cover.1729080460.git.alx@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gik35x3afj5yido2" Content-Disposition: inline In-Reply-To: <20240728141547.302478-1-alx@kernel.org> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
Series |
c: Add __countof__ operator
|
|
Message
Alejandro Colomar
Oct. 22, 2024, 6:48 p.m. UTC
Hi Joseph, I found some tests that could be improved, so I've worked on that in the last few days. I'll post as a reply to this email the bootstrap and regression testing results. v17 changes: - Rebase (patches 2/4 and 3/4 from v16b have been merged already). - Improve and add tests. Below is the range diff against v16b. Have a lovely night! Alex Alejandro Colomar (2): contrib/: Add support for Cc: and Link: tags c: Add __countof__ operator contrib/gcc-changelog/git_commit.py | 5 +- gcc/c-family/c-common.cc | 26 +++++ gcc/c-family/c-common.def | 3 + gcc/c-family/c-common.h | 2 + gcc/c/c-decl.cc | 22 +++- gcc/c/c-parser.cc | 62 +++++++--- gcc/c/c-tree.h | 4 + gcc/c/c-typeck.cc | 118 ++++++++++++++++++- gcc/doc/extend.texi | 30 +++++ gcc/testsuite/gcc.dg/countof-compile.c | 127 +++++++++++++++++++++ gcc/testsuite/gcc.dg/countof-vla.c | 46 ++++++++ gcc/testsuite/gcc.dg/countof.c | 150 +++++++++++++++++++++++++ 12 files changed, 570 insertions(+), 25 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/countof-compile.c create mode 100644 gcc/testsuite/gcc.dg/countof-vla.c create mode 100644 gcc/testsuite/gcc.dg/countof.c Range-diff against v16b: 1: eac2d18d8a0 = 1: d847dc4a795 contrib/: Add support for Cc: and Link: tags 2: 7418a11fcd6 < -: ----------- gcc/: Rename array_type_nelts => array_type_nelts_minus_one 3: 0cfae0598b3 < -: ----------- gcc/: Merge definitions of array_type_nelts_top 4: 12a30a2a6fd ! 2: 936f7945fae c: Add __countof__ operator @@ gcc/testsuite/gcc.dg/countof-compile.c (new) +static int y[__countof__(z)]; + +void -+automatic(void) ++completed (void) +{ -+ __countof__ (w); ++ int i = 42; ++ int a[] = {1, 2, i}; ++ ++ _Static_assert(__countof__ (w) == 3); ++ __countof__ (a); +} + +void @@ gcc/testsuite/gcc.dg/countof-compile.c (new) +{ + __countof__ (x); /* { dg-error "incomplete" } */ + -+ /* We want to support the following one in the future, -+ but for now it should fail. */ ++ /* We want to support array parameters in the future, ++ which should change this from "invalid" to "incomplete". */ + __countof__ (p); /* { dg-error "invalid" } */ +} + @@ gcc/testsuite/gcc.dg/countof-compile.c (new) + __countof__ (s.fam); /* { dg-error "incomplete" } */ +} + ++void ++param (int n, int p[n]) ++{ ++ /* We want to support array parameters in the future, ++ which would make this work. */ ++ __countof__ (p); /* { dg-error "invalid" } */ ++} ++ +void fix_fix (int i, char (*a)[3][5], int (*x)[__countof__ (*a)]); +void fix_var (int i, char (*a)[3][i], int (*x)[__countof__ (*a)]); +void fix_uns (int i, char (*a)[3][*], int (*x)[__countof__ (*a)]);
Comments
On Tue, Oct 22, 2024 at 08:48:10PM GMT, Alejandro Colomar wrote: > Hi Joseph, > > I found some tests that could be improved, so I've worked on that in the > last few days. I'll post as a reply to this email the bootstrap and > regression testing results. alx@debian:~/src/gnu/gcc/len$ git tag len17 alx@debian:~/src/gnu/gcc/len$ git log --oneline gnu/master^..len17 936f7945fae (HEAD -> len, tag: len17) c: Add __countof__ operator d847dc4a795 contrib/: Add support for Cc: and Link: tags 01f50ebfd97 (gnu/trunk, gnu/master) Revert "[PATCH 7/7] RISC-V: Disable by pieces for ve> alx@debian:~/src/gnu/gcc/len$ git reset gnu/master --h HEAD is now at 01f50ebfd97 Revert "[PATCH 7/7] RISC-V: Disable by pieces for vector setmem length > UNITS_PER_WORD" alx@debian:~/src/gnu/gcc/len$ mkdir ../len17 alx@debian:~/src/gnu/gcc/len$ cd ../len17 alx@debian:~/src/gnu/gcc/len17$ /bin/time ../len/configure --disable-multilib --prefix=/opt/local/gnu/gcc/countof |& ts -s | ovr -n 3; echo $? 00:00:04 config.status: creating Makefile 00:00:04 2.86user 1.75system 0:04.17elapsed 110%CPU (0avgtext+0avgdata 26344maxresident)k 00:00:04 97984inputs+8000outputs (305major+280624minor)pagefaults 0swaps 0 alx@debian:~/src/gnu/gcc/len17$ /bin/time make -j24 bootstrap |& ts -s | ovr -n 3; echo $? 00:21:23 make[1]: Leaving directory '/home/alx/src/gnu/gcc/len17' 00:21:23 15132.07user 432.94system 21:23.16elapsed 1213%CPU (0avgtext+0avgdata 1571468maxresident)k 00:21:23 1548192inputs+30472720outputs (19209major+118824055minor)pagefaults 0swaps 0 alx@debian:~/src/gnu/gcc/len17$ /bin/time make check |& ts -s | ovr -n 3; echo $? 06:52:09 make[1]: Leaving directory '/home/alx/src/gnu/gcc/len17' 06:52:09 21407.35user 3424.85system 6:52:09elapsed 100%CPU (0avgtext+0avgdata 2326956maxresident)k 06:52:09 731976inputs+21637088outputs (2855major+994117616minor)pagefaults 0swaps 0 alx@debian:~/src/gnu/gcc/len17$ cd ../len alx@debian:~/src/gnu/gcc/len$ git merge --ff-only len17 Updating 01f50ebfd97..936f7945fae Fast-forward contrib/gcc-changelog/git_commit.py | 5 +- gcc/c-family/c-common.cc | 26 ++++++++ gcc/c-family/c-common.def | 3 + gcc/c-family/c-common.h | 2 + gcc/c/c-decl.cc | 22 +++++-- gcc/c/c-parser.cc | 62 +++++++++++++---- gcc/c/c-tree.h | 4 ++ gcc/c/c-typeck.cc | 118 +++++++++++++++++++++++++++++++-- gcc/doc/extend.texi | 30 +++++++++ gcc/testsuite/gcc.dg/countof-compile.c | 127 +++++++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/countof-vla.c | 46 +++++++++++++ gcc/testsuite/gcc.dg/countof.c | 150 ++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 570 insertions(+), 25 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/countof-compile.c create mode 100644 gcc/testsuite/gcc.dg/countof-vla.c create mode 100644 gcc/testsuite/gcc.dg/countof.c alx@debian:~/src/gnu/gcc/len17$ cd .. alx@debian:~/src/gnu/gcc$ mv len17/ len17_b4 alx@debian:~/src/gnu/gcc/len$ mkdir len17 alx@debian:~/src/gnu/gcc/len$ cd len17 alx@debian:~/src/gnu/gcc/len17$ /bin/time ../len/configure --disable-multilib --prefix=/opt/local/gnu/gcc/countof |& ts -s | ovr; echo $? 00:00:03 232inputs+8000outputs (1major+278059minor)pagefaults 0swaps 0 alx@debian:~/src/gnu/gcc/len17$ /bin/time make -j24 bootstrap |& ts -s | ovr; echo $? 00:20:39 40992inputs+30487656outputs (561major+125063297minor)pagefaults 0swaps 0 alx@debian:~/src/gnu/gcc/len17$ /bin/time make check |& ts -s | ovr; echo $? 06:56:00 74496inputs+21640408outputs (2723major+991618593minor)pagefaults 0swaps 0 alx@debian:~/src/gnu/gcc/len17$ find -type f | grep '\.sum$' | while read f; do diff -u ../len17_b4/$f $f; done --- ../len17_b4/./gcc/testsuite/gcc/gcc.sum 2024-10-20 21:28:04.131516030 +0200 +++ ./gcc/testsuite/gcc/gcc.sum 2024-10-22 13:06:18.877529401 +0200 @@ -1,4 +1,4 @@ -Test run by alx on Sun Oct 20 19:42:24 2024 +Test run by alx on Tue Oct 22 11:17:17 2024 Native configuration is x86_64-pc-linux-gnu === gcc tests === @@ -78022,6 +78022,30 @@ PASS: gcc.dg/conv-2.c (test for excess errors) PASS: gcc.dg/conv-3.c (test for excess errors) PASS: gcc.dg/conv-3.c execution test +PASS: gcc.dg/countof-compile.c (test for errors, line 24) +PASS: gcc.dg/countof-compile.c (test for errors, line 28) +PASS: gcc.dg/countof-compile.c (test for errors, line 39) +PASS: gcc.dg/countof-compile.c (test for errors, line 47) +PASS: gcc.dg/countof-compile.c (test for errors, line 62) +PASS: gcc.dg/countof-compile.c (test for errors, line 65) +PASS: gcc.dg/countof-compile.c (test for errors, line 68) +PASS: gcc.dg/countof-compile.c (test for errors, line 80) +PASS: gcc.dg/countof-compile.c (test for errors, line 81) +PASS: gcc.dg/countof-compile.c (test for errors, line 82) +PASS: gcc.dg/countof-compile.c (test for errors, line 83) +PASS: gcc.dg/countof-compile.c (test for errors, line 84) +PASS: gcc.dg/countof-compile.c (test for errors, line 85) +PASS: gcc.dg/countof-compile.c (test for errors, line 86) +PASS: gcc.dg/countof-compile.c (test for errors, line 87) +PASS: gcc.dg/countof-compile.c (test for errors, line 88) +PASS: gcc.dg/countof-compile.c (test for warnings, line 92) +PASS: gcc.dg/countof-compile.c (test for errors, line 112) +PASS: gcc.dg/countof-compile.c (test for errors, line 121) +PASS: gcc.dg/countof-compile.c (test for errors, line 126) +PASS: gcc.dg/countof-compile.c (test for excess errors) +PASS: gcc.dg/countof-vla.c (test for excess errors) +PASS: gcc.dg/countof.c (test for excess errors) +PASS: gcc.dg/countof.c execution test PASS: gcc.dg/cr-decimal-dig-1.c (test for excess errors) PASS: gcc.dg/cr-decimal-dig-2.c (test for excess errors) PASS: gcc.dg/cr-decimal-dig-3.c (test for excess errors) @@ -208690,7 +208714,7 @@ === gcc Summary === -# of expected passes 203598 +# of expected passes 203622 # of unexpected failures 37 # of unexpected successes 2 # of expected failures 1471 --- ../len17_b4/./gcc/testsuite/gfortran/gfortran.sum 2024-10-20 23:07:39.361276662 +0200 +++ ./gcc/testsuite/gfortran/gfortran.sum 2024-10-22 14:45:01.978602257 +0200 @@ -1,4 +1,4 @@ -Test run by alx on Sun Oct 20 22:32:36 2024 +Test run by alx on Tue Oct 22 14:10:06 2024 Native configuration is x86_64-pc-linux-gnu === gfortran tests === --- ../len17_b4/./gcc/testsuite/objc/objc.sum 2024-10-20 23:08:46.517872353 +0200 +++ ./gcc/testsuite/objc/objc.sum 2024-10-22 14:46:08.167200761 +0200 @@ -1,4 +1,4 @@ -Test run by alx on Sun Oct 20 23:07:39 2024 +Test run by alx on Tue Oct 22 14:45:02 2024 Native configuration is x86_64-pc-linux-gnu === objc tests === --- ../len17_b4/./gcc/testsuite/g++/g++.sum 2024-10-20 22:32:35.602258071 +0200 +++ ./gcc/testsuite/g++/g++.sum 2024-10-22 14:10:05.487527382 +0200 @@ -1,4 +1,4 @@ -Test run by alx on Sun Oct 20 21:28:04 2024 +Test run by alx on Tue Oct 22 13:06:19 2024 Native configuration is x86_64-pc-linux-gnu === g++ tests === --- ../len17_b4/./x86_64-pc-linux-gnu/libitm/testsuite/libitm.sum 2024-10-21 02:34:25.906785565 +0200 +++ ./x86_64-pc-linux-gnu/libitm/testsuite/libitm.sum 2024-10-22 18:13:10.216200995 +0200 @@ -1,4 +1,4 @@ -Test run by alx on Mon Oct 21 02:34:23 2024 +Test run by alx on Tue Oct 22 18:13:08 2024 Native configuration is x86_64-pc-linux-gnu === libitm tests === --- ../len17_b4/./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.sum 2024-10-21 02:34:23.258761608 +0200 +++ ./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.sum 2024-10-22 18:13:07.608178686 +0200 @@ -1,4 +1,4 @@ -Test run by alx on Mon Oct 21 02:20:07 2024 +Test run by alx on Tue Oct 22 17:58:52 2024 Native configuration is x86_64-pc-linux-gnu === libgomp tests === --- ../len17_b4/./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.sum2024-10-21 02:34:28.354807711 +0200 +++ ./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.sum 2024-10-22 18:13:12.560221047 +0200 @@ -1,4 +1,4 @@ -Test run by alx on Mon Oct 21 02:34:26 2024 +Test run by alx on Tue Oct 22 18:13:10 2024 Native configuration is x86_64-pc-linux-gnu === libatomic tests === --- ../len17_b4/./x86_64-pc-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum 2024-10-21 02:19:44.922761161 +0200 +++ ./x86_64-pc-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum 2024-10-22 17:58:29.992819146 +0200 @@ -1,4 +1,4 @@ -Test run by alx on Sun Oct 20 23:09:16 2024 +Test run by alx on Tue Oct 22 14:46:37 2024 Native configuration is x86_64-pc-linux-gnu === libstdc++ tests === > > > v17 changes: > > - Rebase (patches 2/4 and 3/4 from v16b have been merged already). > - Improve and add tests. > > Below is the range diff against v16b. > > > Have a lovely night! > Alex > > Alejandro Colomar (2): > contrib/: Add support for Cc: and Link: tags > c: Add __countof__ operator > > contrib/gcc-changelog/git_commit.py | 5 +- > gcc/c-family/c-common.cc | 26 +++++ > gcc/c-family/c-common.def | 3 + > gcc/c-family/c-common.h | 2 + > gcc/c/c-decl.cc | 22 +++- > gcc/c/c-parser.cc | 62 +++++++--- > gcc/c/c-tree.h | 4 + > gcc/c/c-typeck.cc | 118 ++++++++++++++++++- > gcc/doc/extend.texi | 30 +++++ > gcc/testsuite/gcc.dg/countof-compile.c | 127 +++++++++++++++++++++ > gcc/testsuite/gcc.dg/countof-vla.c | 46 ++++++++ > gcc/testsuite/gcc.dg/countof.c | 150 +++++++++++++++++++++++++ > 12 files changed, 570 insertions(+), 25 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/countof-compile.c > create mode 100644 gcc/testsuite/gcc.dg/countof-vla.c > create mode 100644 gcc/testsuite/gcc.dg/countof.c > > Range-diff against v16b: > 1: eac2d18d8a0 = 1: d847dc4a795 contrib/: Add support for Cc: and Link: tags > 2: 7418a11fcd6 < -: ----------- gcc/: Rename array_type_nelts => array_type_nelts_minus_one > 3: 0cfae0598b3 < -: ----------- gcc/: Merge definitions of array_type_nelts_top > 4: 12a30a2a6fd ! 2: 936f7945fae c: Add __countof__ operator > @@ gcc/testsuite/gcc.dg/countof-compile.c (new) > +static int y[__countof__(z)]; > + > +void > -+automatic(void) > ++completed (void) > +{ > -+ __countof__ (w); > ++ int i = 42; > ++ int a[] = {1, 2, i}; > ++ > ++ _Static_assert(__countof__ (w) == 3); > ++ __countof__ (a); > +} > + > +void > @@ gcc/testsuite/gcc.dg/countof-compile.c (new) > +{ > + __countof__ (x); /* { dg-error "incomplete" } */ > + > -+ /* We want to support the following one in the future, > -+ but for now it should fail. */ > ++ /* We want to support array parameters in the future, > ++ which should change this from "invalid" to "incomplete". */ > + __countof__ (p); /* { dg-error "invalid" } */ > +} > + > @@ gcc/testsuite/gcc.dg/countof-compile.c (new) > + __countof__ (s.fam); /* { dg-error "incomplete" } */ > +} > + > ++void > ++param (int n, int p[n]) > ++{ > ++ /* We want to support array parameters in the future, > ++ which would make this work. */ > ++ __countof__ (p); /* { dg-error "invalid" } */ > ++} > ++ > +void fix_fix (int i, char (*a)[3][5], int (*x)[__countof__ (*a)]); > +void fix_var (int i, char (*a)[3][i], int (*x)[__countof__ (*a)]); > +void fix_uns (int i, char (*a)[3][*], int (*x)[__countof__ (*a)]); > > -- > 2.45.2 >