Hi!
Here's v24. Changes compared to v23 (see range-diff below):
- Use a GNU dialect in tests that use GNU extensions.
- Add comment about the syntax of _Countof.
Tests still pass:
$ grep countof ./gcc/testsuite/gcc/gcc.sum
PASS: gcc.dg/countof-compat.c (test for warnings, line 8)
PASS: gcc.dg/countof-compat.c (test for excess errors)
PASS: gcc.dg/countof-compile.c (test for errors, line 114)
PASS: gcc.dg/countof-compile.c (test for errors, line 123)
PASS: gcc.dg/countof-compile.c (test for errors, line 23)
PASS: gcc.dg/countof-compile.c (test for errors, line 27)
PASS: gcc.dg/countof-compile.c (test for errors, line 38)
PASS: gcc.dg/countof-compile.c (test for errors, line 46)
PASS: gcc.dg/countof-compile.c (test for errors, line 64)
PASS: gcc.dg/countof-compile.c (test for errors, line 67)
PASS: gcc.dg/countof-compile.c (test for errors, line 70)
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 errors, line 89)
PASS: gcc.dg/countof-compile.c (test for errors, line 90)
PASS: gcc.dg/countof-compile.c (test for errors, line 94)
PASS: gcc.dg/countof-compile.c (test for excess errors)
PASS: gcc.dg/countof-no-compat.c (test for excess errors)
PASS: gcc.dg/countof-pedantic-errors.c (test for errors, line 8)
PASS: gcc.dg/countof-pedantic-errors.c (test for excess errors)
PASS: gcc.dg/countof-pedantic.c (test for warnings, line 8)
PASS: gcc.dg/countof-pedantic.c (test for excess errors)
PASS: gcc.dg/countof-stdcountof.c (test for excess errors)
PASS: gcc.dg/countof-stdcountof.c execution test
PASS: gcc.dg/countof-vla.c (test for excess errors)
PASS: gcc.dg/countof-vmt.c (test for excess errors)
PASS: gcc.dg/countof-vmt.c execution test
PASS: gcc.dg/countof-zero-compile.c (test for excess errors)
PASS: gcc.dg/countof-zero.c (test for excess errors)
PASS: gcc.dg/countof-zero.c execution test
PASS: gcc.dg/countof.c (test for excess errors)
PASS: gcc.dg/countof.c execution test
Have a lovely day!
Alex
Alejandro Colomar (3):
c: Add _Countof operator
c: Add <stdcountof.h>
c: Add -Wpedantic diagnostic for _Countof
gcc/Makefile.in | 1 +
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 | 67 ++++++++--
gcc/c/c-tree.h | 4 +
gcc/c/c-typeck.cc | 115 +++++++++++++++-
gcc/doc/extend.texi | 30 +++++
gcc/ginclude/stdcountof.h | 31 +++++
gcc/testsuite/gcc.dg/countof-compat.c | 8 ++
gcc/testsuite/gcc.dg/countof-compile.c | 124 ++++++++++++++++++
gcc/testsuite/gcc.dg/countof-no-compat.c | 5 +
.../gcc.dg/countof-pedantic-errors.c | 8 ++
gcc/testsuite/gcc.dg/countof-pedantic.c | 8 ++
gcc/testsuite/gcc.dg/countof-stdcountof.c | 24 ++++
gcc/testsuite/gcc.dg/countof-vla.c | 35 +++++
gcc/testsuite/gcc.dg/countof-vmt.c | 20 +++
gcc/testsuite/gcc.dg/countof-zero-compile.c | 38 ++++++
gcc/testsuite/gcc.dg/countof-zero.c | 31 +++++
gcc/testsuite/gcc.dg/countof.c | 120 +++++++++++++++++
21 files changed, 698 insertions(+), 24 deletions(-)
create mode 100644 gcc/ginclude/stdcountof.h
create mode 100644 gcc/testsuite/gcc.dg/countof-compat.c
create mode 100644 gcc/testsuite/gcc.dg/countof-compile.c
create mode 100644 gcc/testsuite/gcc.dg/countof-no-compat.c
create mode 100644 gcc/testsuite/gcc.dg/countof-pedantic-errors.c
create mode 100644 gcc/testsuite/gcc.dg/countof-pedantic.c
create mode 100644 gcc/testsuite/gcc.dg/countof-stdcountof.c
create mode 100644 gcc/testsuite/gcc.dg/countof-vla.c
create mode 100644 gcc/testsuite/gcc.dg/countof-vmt.c
create mode 100644 gcc/testsuite/gcc.dg/countof-zero-compile.c
create mode 100644 gcc/testsuite/gcc.dg/countof-zero.c
create mode 100644 gcc/testsuite/gcc.dg/countof.c
Range-diff against v23:
1: 5040a7d25a96 ! 1: 1ac81ab0d3dc c: Add _Countof operator
@@ gcc/c/c-parser.cc: static struct c_expr c_parser_binary_expression
(c_parser *,
static struct c_expr c_parser_alignof_expression (c_parser *);
static struct c_expr c_parser_postfix_expression (c_parser *);
static struct c_expr c_parser_postfix_expression_after_paren_type
(c_parser *,
+@@ gcc/c/c-parser.cc: c_parser_cast_expression (c_parser *parser, struct
c_expr *after)
+ ++ unary-expression
+ -- unary-expression
+ unary-operator cast-expression
++ _Countof unary-expression
++ _Countof ( type-name )
+ sizeof unary-expression
+ sizeof ( type-name )
+
++ (_Countof is new in C2y.)
++
+ unary-operator: one of
+ & * + - ~ !
+
@@ gcc/c/c-parser.cc: c_parser_unary_expression (c_parser *parser)
case CPP_KEYWORD:
switch (c_parser_peek_token (parser)->keyword)
@@ gcc/testsuite/gcc.dg/countof-vla.c (new)
## gcc/testsuite/gcc.dg/countof-vmt.c (new) ##
@@
+/* { dg-do run } */
-+/* { dg-options "-std=c2y" } */
++/* { dg-options "-std=gnu2y" } */
+
+#define assert(e) ((e) ? (void) 0 : __builtin_abort ())
+
@@ gcc/testsuite/gcc.dg/countof-vmt.c (new)
## gcc/testsuite/gcc.dg/countof-zero-compile.c (new) ##
@@
+/* { dg-do compile } */
-+/* { dg-options "-std=c2y" } */
++/* { dg-options "-std=gnu2y" } */
+
+static int z[0];
+static int y[_Countof (z)];
@@ gcc/testsuite/gcc.dg/countof-zero-compile.c (new)
## gcc/testsuite/gcc.dg/countof-zero.c (new) ##
@@
+/* { dg-do run } */
-+/* { dg-options "-std=c2y" } */
++/* { dg-options "-std=gnu2y" } */
+
+#define assert(e) ((e) ? (void) 0 : __builtin_abort ())
+
2: a560cf1ae23b = 2: b9e8bed2de2b c: Add <stdcountof.h>
3: b1974a4507bc = 3: 264c87d60157 c: Add -Wpedantic diagnostic for _Countof
base-commit: 90c6ccebd762ae920690fce20cd3f2b8e24357a7
--
2.49.0