]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: Add _Maxof and _Minof operators
authorAlejandro Colomar <alx@kernel.org>
Wed, 26 Nov 2025 00:12:49 +0000 (01:12 +0100)
committerJoseph Myers <josmyers@redhat.com>
Wed, 26 Nov 2025 22:07:11 +0000 (22:07 +0000)
commitacbe4fd145a2d6f5537553a43ec67dfd46739438
tree658a65966640fb9442a2b5b1f5ac67741f964431
parentb11ae5fb5efcf9e0977cd54538765e1d40b1b107
c: Add _Maxof and _Minof operators

Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3628.txt>

These operators have not yet been accepted by the C Committee, so this
is implemented as a GNU extension.

gcc/ChangeLog:

* doc/extend.texi (Syntax Extensions): Document _Maxof & _Minof.

gcc/c-family/ChangeLog:

* c-common.cc (c_common_reswords): Add _Maxof & _Minof keywords.
(c_maxof_type, c_minof_type): New functions.
* c-common.def (MAXOF_EXPR, MINOF_EXPR): New trees.
* c-common.h (enum rid): Add RID_MAXOF & RID_MINOF constants.
(c_maxof_type, c_minof_type): New prototypes.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_maxof_or_minof_expression): New func.
(c_parser_unary_expression): Add RID_MAXOF & RID_MINOF cases.
* c-tree.h (c_expr_maxof_type): New prototype.
(c_expr_minof_type): New prototype.
* c-typeck.cc (c_expr_maxof_type): New function.
(c_expr_minof_type): New function.

gcc/testsuite/ChangeLog:

* gcc.dg/maxof-bitint.c: New test.
* gcc.dg/maxof-bitint575.c: New test.
* gcc.dg/maxof-compile.c: New test.
* gcc.dg/maxof-pedantic-errors.c: New test.
* gcc.dg/maxof-pedantic.c: New test.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
12 files changed:
gcc/c-family/c-common.cc
gcc/c-family/c-common.def
gcc/c-family/c-common.h
gcc/c/c-parser.cc
gcc/c/c-tree.h
gcc/c/c-typeck.cc
gcc/doc/extend.texi
gcc/testsuite/gcc.dg/maxof-bitint.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/maxof-bitint575.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/maxof-compile.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/maxof-pedantic-errors.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/maxof-pedantic.c [new file with mode: 0644]