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)]); -- 2.45.2
signature.asc
Description: PGP signature