Hi Joseph,
I've addressed all issues you raised in v6 (see range-diff at the
bottom):
- Fix comment about _Maxof/_Minof being supported by C2y, and say they
are GNU extensions.
- s/MAXOF_EXPR/MINOF_EXPR in c_expr_minof_type().
- Fix plural/singular wording issues in the documentation.
- Document return type of the operators.
All tests ok (see below).
Have a lovely night!
Alex
alx@devuan:~/src/gnu/gcc/maxof$ git tag maxof7
alx@devuan:~/src/gnu/gcc/maxof$ git log --oneline gnu/master^..maxof7
5f49e800bf91 (HEAD -> maxof, tag: maxof7) c: Add _Maxof and _Minof
operators
59a5fecfb260 (gnu/trunk, gnu/master, gnu/HEAD) aarch64: Extract
aarch64_indirect_branch_asm for sibcall codegen
alx@devuan:~/src/gnu/gcc/maxof$ git reset gnu/master --h
HEAD is now at 59a5fecfb260 aarch64: Extract
aarch64_indirect_branch_asm for sibcall codegen
alx@devuan:~/src/gnu/gcc/maxof$ mkdir ../maxof7
alx@devuan:~/src/gnu/gcc/maxof$ cd ../maxof7/
alx@devuan:~/src/gnu/gcc/maxof7$ set -o pipefail
alx@devuan:~/src/gnu/gcc/maxof7$ ../maxof/configure --disable-multilib
--prefix=/opt/local/gnu/gcc/maxof7 |& ts -s | tail -n1; echo $?; make -j24
bootstrap |& ts -s | tail -n1; echo $?; make -j24 check |& ts -s | tail -n1;
echo $?;
00:00:01 config.status: creating Makefile
0
00:22:13 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/maxof7'
0
00:36:49 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/maxof7'
0
alx@devuan:~/src/gnu/gcc/maxof7$ cd ../maxof
alx@devuan:~/src/gnu/gcc/maxof$ git merge --ff-only maxof7
Updating 59a5fecfb260..5f49e800bf91
Fast-forward
gcc/c-family/c-common.cc | 32 ++++
gcc/c-family/c-common.def | 6 +
gcc/c-family/c-common.h | 4 +-
gcc/c/c-parser.cc | 67 ++++++++
gcc/c/c-tree.h | 2 +
gcc/c/c-typeck.cc | 54 +++++++
gcc/doc/extend.texi | 20 +++
gcc/testsuite/gcc.dg/maxof-bitint.c | 20 +++
gcc/testsuite/gcc.dg/maxof-bitint575.c | 39 +++++
gcc/testsuite/gcc.dg/maxof-compile.c | 151 +++++++++++++++++++
gcc/testsuite/gcc.dg/maxof-pedantic-errors.c | 5 +
gcc/testsuite/gcc.dg/maxof-pedantic.c | 5 +
12 files changed, 404 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/maxof-bitint.c
create mode 100644 gcc/testsuite/gcc.dg/maxof-bitint575.c
create mode 100644 gcc/testsuite/gcc.dg/maxof-compile.c
create mode 100644 gcc/testsuite/gcc.dg/maxof-pedantic-errors.c
create mode 100644 gcc/testsuite/gcc.dg/maxof-pedantic.c
alx@devuan:~/src/gnu/gcc/maxof$ cd ../
alx@devuan:~/src/gnu/gcc$ mv maxof7/ maxof7_b4
alx@devuan:~/src/gnu/gcc$ mkdir maxof7
alx@devuan:~/src/gnu/gcc$ cd maxof7
alx@devuan:~/src/gnu/gcc/maxof7$ ../maxof/configure --disable-multilib
--prefix=/opt/local/gnu/gcc/maxof7 |& ts -s | tail -n1; echo $?; make -j24
bootstrap |& ts -s | tail -n1; echo $?; make -j24 check |& ts -s | tail -n1;
echo $?;
00:00:03 config.status: creating Makefile
0
00:22:10 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/maxof7'
0
00:36:46 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/maxof7'
0
alx@devuan:~/src/gnu/gcc/maxof7$ find -type f | grep '\.sum$' | while
read f; do diff -u "../maxof7_b4/$f" "$f"; done;
--- ../maxof7_b4/./x86_64-pc-linux-gnu/libitm/testsuite/libitm.sum
2025-11-25 00:29:15.907112290 +0100
+++ ./x86_64-pc-linux-gnu/libitm/testsuite/libitm.sum 2025-11-25
01:35:13.575138690 +0100
@@ -1,4 +1,4 @@
-Test run by alx on Tue Nov 25 00:29:13 2025
+Test run by alx on Tue Nov 25 01:35:10 2025
Native configuration is x86_64-pc-linux-gnu
=== libitm tests ===
---
../maxof7_b4/./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.sum2025-11-25
00:29:14.683203116 +0100
+++ ./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.sum
2025-11-25 01:35:12.446798155 +0100
@@ -1,4 +1,4 @@
-Test run by alx on Tue Nov 25 00:29:13 2025
+Test run by alx on Tue Nov 25 01:35:10 2025
Native configuration is x86_64-pc-linux-gnu
=== libatomic tests ===
--- ../maxof7_b4/./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.sum
2025-11-25 00:32:02.417855788 +0100
+++ ./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.sum 2025-11-25
01:37:39.820473388 +0100
@@ -1,4 +1,4 @@
-Test run by alx on Tue Nov 25 00:29:13 2025
+Test run by alx on Tue Nov 25 01:35:10 2025
Native configuration is x86_64-pc-linux-gnu
=== libgomp tests ===
---
../maxof7_b4/./x86_64-pc-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum
2025-11-25 01:06:01.117142988 +0100
+++ ./x86_64-pc-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum
2025-11-25 02:11:55.933724854 +0100
@@ -1,4 +1,4 @@
-Test run by alx on Tue Nov 25 00:29:14 2025
+Test run by alx on Tue Nov 25 01:35:11 2025
Native configuration is x86_64-pc-linux-gnu
=== libstdc++ tests ===
--- ../maxof7_b4/./gcc/testsuite/objc/objc.sum 2025-11-25
00:30:28.277259556 +0100
+++ ./gcc/testsuite/objc/objc.sum 2025-11-25 01:35:48.567946015
+0100
@@ -1,4 +1,4 @@
-Test run by alx on Tue Nov 25 00:29:14 2025
+Test run by alx on Tue Nov 25 01:35:11 2025
Native configuration is x86_64-pc-linux-gnu
=== objc tests ===
--- ../maxof7_b4/./gcc/testsuite/g++/g++.sum 2025-11-25
00:38:19.816369526 +0100
+++ ./gcc/testsuite/g++/g++.sum 2025-11-25 01:47:54.225339889 +0100
@@ -1,4 +1,4 @@
-Test run by alx on Tue Nov 25 00:29:13 2025
+Test run by alx on Tue Nov 25 01:35:11 2025
Native configuration is x86_64-pc-linux-gnu
=== g++ tests ===
--- ../maxof7_b4/./gcc/testsuite/gcc/gcc.sum 2025-11-25
00:52:35.658925581 +0100
+++ ./gcc/testsuite/gcc/gcc.sum 2025-11-25 01:55:29.048478152 +0100
@@ -1,4 +1,4 @@
-Test run by alx on Tue Nov 25 00:29:13 2025
+Test run by alx on Tue Nov 25 01:35:11 2025
Native configuration is x86_64-pc-linux-gnu
=== gcc tests ===
@@ -94161,6 +94161,44 @@
PASS: gcc.dg/max-1.c execution test
PASS: gcc.dg/max.c (test for excess errors)
PASS: gcc.dg/max.c scan-tree-dump-not optimized "MAX_EXPR"
+PASS: gcc.dg/maxof-bitint.c (test for excess errors)
+PASS: gcc.dg/maxof-bitint575.c (test for excess errors)
+PASS: gcc.dg/maxof-bitint575.c execution test
+PASS: gcc.dg/maxof-compile.c (test for errors, line 102)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 104)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 106)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 107)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 113)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 114)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 115)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 116)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 71)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 73)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 75)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 77)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 79)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 80)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 81)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 82)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 91)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 92)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 93)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 94)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 95)
+PASS: gcc.dg/maxof-compile.c (test for errors, line 96)
+PASS: gcc.dg/maxof-compile.c (test for excess errors)
+PASS: gcc.dg/maxof-compile.c syntax error at line 103 (test for
errors, line 102)
+PASS: gcc.dg/maxof-compile.c syntax error at line 105 (test for
errors, line 104)
+PASS: gcc.dg/maxof-compile.c syntax error at line 72 (test for errors,
line 71)
+PASS: gcc.dg/maxof-compile.c syntax error at line 74 (test for errors,
line 73)
+PASS: gcc.dg/maxof-compile.c syntax error at line 76 (test for errors,
line 75)
+PASS: gcc.dg/maxof-compile.c syntax error at line 78 (test for errors,
line 77)
+PASS: gcc.dg/maxof-pedantic-errors.c (test for errors, line 4)
+PASS: gcc.dg/maxof-pedantic-errors.c (test for errors, line 5)
+PASS: gcc.dg/maxof-pedantic-errors.c (test for excess errors)
+PASS: gcc.dg/maxof-pedantic.c (test for warnings, line 4)
+PASS: gcc.dg/maxof-pedantic.c (test for warnings, line 5)
+PASS: gcc.dg/maxof-pedantic.c (test for excess errors)
PASS: gcc.dg/memchr-2.c (test for excess errors)
PASS: gcc.dg/memchr-2.c scan-tree-dump-not optimized "abort"
PASS: gcc.dg/memchr-2.c scan-tree-dump-not optimized "memcmp \\("
@@ -221153,7 +221191,7 @@
=== gcc Summary ===
-# of expected passes 215080
+# of expected passes 215118
# of unexpected failures 529
# of unexpected successes 6
# of expected failures 1486
--- ../maxof7_b4/./gcc/testsuite/gfortran/gfortran.sum 2025-11-25
00:40:09.825188373 +0100
+++ ./gcc/testsuite/gfortran/gfortran.sum 2025-11-25
01:52:43.832031638 +0100
@@ -1,4 +1,4 @@
-Test run by alx on Tue Nov 25 00:29:13 2025
+Test run by alx on Tue Nov 25 01:35:11 2025
Native configuration is x86_64-pc-linux-gnu
=== gfortran tests ===
Alejandro Colomar (1):
c: Add _Maxof and _Minof operators
gcc/c-family/c-common.cc | 32 ++++
gcc/c-family/c-common.def | 6 +
gcc/c-family/c-common.h | 4 +-
gcc/c/c-parser.cc | 67 ++++++++
gcc/c/c-tree.h | 2 +
gcc/c/c-typeck.cc | 54 +++++++
gcc/doc/extend.texi | 20 +++
gcc/testsuite/gcc.dg/maxof-bitint.c | 20 +++
gcc/testsuite/gcc.dg/maxof-bitint575.c | 39 +++++
gcc/testsuite/gcc.dg/maxof-compile.c | 151 +++++++++++++++++++
gcc/testsuite/gcc.dg/maxof-pedantic-errors.c | 5 +
gcc/testsuite/gcc.dg/maxof-pedantic.c | 5 +
12 files changed, 404 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/maxof-bitint.c
create mode 100644 gcc/testsuite/gcc.dg/maxof-bitint575.c
create mode 100644 gcc/testsuite/gcc.dg/maxof-compile.c
create mode 100644 gcc/testsuite/gcc.dg/maxof-pedantic-errors.c
create mode 100644 gcc/testsuite/gcc.dg/maxof-pedantic.c
Range-diff against v6:
1: 00aab1fbde52 ! 1: 5f49e800bf91 c: Add _Maxof and _Minof operators
@@ gcc/c/c-parser.cc: static struct c_expr c_parser_unary_expression
(c_parser *);
static struct c_expr c_parser_postfix_expression_after_paren_type
(c_parser *,
struct
c_declspecs *,
@@ gcc/c/c-parser.cc: c_parser_cast_expression (c_parser *parser, struct
c_expr *after)
- _Countof ( type-name )
- sizeof unary-expression
- sizeof ( type-name )
+ unary-expression:
+ __alignof__ unary-expression
+ __alignof__ ( type-name )
+ _Maxof ( type-name )
+ _Minof ( type-name )
- static-assert-declaration-no-semi
+ && identifier
-- (_Countof and the use of static assertions in expressions are new in
C2y.)
-+ (_Countof, _Maxof, _Minof, and the use of static assertions in
-+ expressions are new in C2y.)
-
- unary-operator: one of
- & * + - ~ !
+ (C11 permits _Alignof with type names only.)
@@ gcc/c/c-parser.cc: c_parser_unary_expression (c_parser *parser)
return c_parser_sizeof_or_countof_expression (parser, rid);
case RID_ALIGNOF:
@@ gcc/c/c-typeck.cc: c_expr_countof_type (location_t loc, struct
c_type_name *t)
+ ret.value = c_minof_type (loc, type);
+ c_last_sizeof_arg = type;
+ c_last_sizeof_loc = loc;
-+ ret.original_code = MAXOF_EXPR;
++ ret.original_code = MINOF_EXPR;
+ ret.original_type = NULL;
+ ret.m_decimal = 0;
+ if (type == error_mark_node)
@@ gcc/doc/extend.texi: _Countof (int [7][n++]); // integer constant
expression
+
+The keywords @code{_Maxof} and @code{_Minof} determine
+the maximum and minimum representable values of an integer type.
-+Its syntax is similar to @code{sizeof}.
++Their syntax is similar to @code{sizeof}.
+The operand must be
+a parenthesized integer type.
-+The result of this operator is an integer constant expression.
++The result of these operators is an integer constant expression
++of the same type as the operand.
+For example:
+
+@smallexample
-+_Maxof (int); // returns INT_MAX
-+_Minof (short); // returns SHRT_MIN
++_Maxof (int); // returns '(int) INT_MAX'
++_Minof (short); // returns '(short) SHRT_MIN'
+@end smallexample
+
@node Offsetof
--
2.51.0