Hi Joseph,

I've removed the diagnostics about bool.  It now accepts bool just like
the n3628 proposal.  At the bottom of this mail, you can find the
range-diff against v3.

Please let me know if you want some or all of these patches squashed.

Successfully tested for regressions:

        alx@devuan:~/src/gnu/gcc/maxof$ git tag maxof4
        alx@devuan:~/src/gnu/gcc/maxof$ git log --oneline gnu/master^..maxof4
        4b4334f3c071 (HEAD -> maxof, tag: maxof4) c: _Maxof and _Minof have not 
been accepted yet by the C Committee
        96b815be5e5d c: Reduce excess errors of _Maxof and _Minof
        da4cf539a385 c: Add _Maxof and _Minof operators
        d8e3ddc3191f (gnu/trunk, gnu/master, gnu/HEAD) cobol: Correct libgcobol 
install directory and add components.
        alx@devuan:~/src/gnu/gcc/maxof$ git reset gnu/master --h
        HEAD is now at d8e3ddc3191f cobol: Correct libgcobol install directory 
and add components.
        alx@devuan:~/src/gnu/gcc/maxof$ mkdir ../maxof4
        alx@devuan:~/src/gnu/gcc/maxof$ cd ../maxof4/
        alx@devuan:~/src/gnu/gcc/maxof4$ set -o pipefail
        alx@devuan:~/src/gnu/gcc/maxof4$ ../maxof/configure --disable-multilib 
--prefix=/opt/local/gnu/gcc/maxof3 |& ts -s | tail -n1; echo $?; make -j24 
bootstrap |& ts -s | tail -n1; echo $?; make -j24 check |& ts -s | tail -n1; 
echo $?;
        00:00:02 config.status: creating Makefile
        0
        00:22:35 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/maxof4'
        0
        00:34:49 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/maxof4'
        0
        alx@devuan:~/src/gnu/gcc/maxof4$ cd ../maxof
        alx@devuan:~/src/gnu/gcc/maxof$ git merge --ff-only maxof4
        Updating d8e3ddc3191f..4b4334f3c071
        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                            |  65 +++++++-
         gcc/c/c-tree.h                               |   2 +
         gcc/c/c-typeck.cc                            |  54 ++++++
         gcc/doc/extend.texi                          |  19 +++
         gcc/testsuite/gcc.dg/maxof-compat.c          |   5 +
         gcc/testsuite/gcc.dg/maxof-compile.c         | 163 +++++++++++++++++++
         gcc/testsuite/gcc.dg/maxof-no-compat.c       |   5 +
         gcc/testsuite/gcc.dg/maxof-pedantic-errors.c |   5 +
         gcc/testsuite/gcc.dg/maxof-pedantic.c        |   5 +
         12 files changed, 363 insertions(+), 2 deletions(-)
         create mode 100644 gcc/testsuite/gcc.dg/maxof-compat.c
         create mode 100644 gcc/testsuite/gcc.dg/maxof-compile.c
         create mode 100644 gcc/testsuite/gcc.dg/maxof-no-compat.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 maxof4/ maxof4_b4
        alx@devuan:~/src/gnu/gcc$ mkdir maxof4
        alx@devuan:~/src/gnu/gcc$ cd maxof4
        alx@devuan:~/src/gnu/gcc/maxof4$ ../maxof/configure --disable-multilib 
--prefix=/opt/local/gnu/gcc/maxof3 |& 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:14 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/maxof4'
        0
        00:35:18 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/maxof4'
        0
        alx@devuan:~/src/gnu/gcc/maxof4$ find -type f | grep '\.sum$' | while 
read f; do diff -u "../maxof4_b4/$f" "$f"; done;
        --- ../maxof4_b4/./x86_64-pc-linux-gnu/libitm/testsuite/libitm.sum      
2025-11-18 01:13:39.644072848 +0100
        +++ ./x86_64-pc-linux-gnu/libitm/testsuite/libitm.sum   2025-11-18 
09:57:51.164602800 +0100
        @@ -1,4 +1,4 @@
        -Test run by alx on Tue Nov 18 01:13:36 2025
        +Test run by alx on Tue Nov 18 09:57:48 2025
         Native configuration is x86_64-pc-linux-gnu
         
                        === libitm tests ===
        --- 
../maxof4_b4/./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.sum2025-11-18 
01:13:38.561831797 +0100
        +++ ./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.sum     
2025-11-18 09:57:49.846842163 +0100
        @@ -1,4 +1,4 @@
        -Test run by alx on Tue Nov 18 01:13:36 2025
        +Test run by alx on Tue Nov 18 09:57:48 2025
         Native configuration is x86_64-pc-linux-gnu
         
                        === libatomic tests ===
        --- ../maxof4_b4/./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.sum    
2025-11-18 01:16:27.108421297 +0100
        +++ ./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.sum 2025-11-18 
10:00:32.766086638 +0100
        @@ -1,4 +1,4 @@
        -Test run by alx on Tue Nov 18 01:13:37 2025
        +Test run by alx on Tue Nov 18 09:57:48 2025
         Native configuration is x86_64-pc-linux-gnu
         
                        === libgomp tests ===
        --- 
../maxof4_b4/./x86_64-pc-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum     
2025-11-18 01:48:25.085230857 +0100
        +++ ./x86_64-pc-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum  
2025-11-18 10:33:05.666043499 +0100
        @@ -1,4 +1,4 @@
        -Test run by alx on Tue Nov 18 01:13:38 2025
        +Test run by alx on Tue Nov 18 09:57:49 2025
         Native configuration is x86_64-pc-linux-gnu
         
                        === libstdc++ tests ===
        --- ../maxof4_b4/./gcc/testsuite/objc/objc.sum  2025-11-18 
01:14:33.406955976 +0100
        +++ ./gcc/testsuite/objc/objc.sum       2025-11-18 09:58:15.777835666 
+0100
        @@ -1,4 +1,4 @@
        -Test run by alx on Tue Nov 18 01:13:37 2025
        +Test run by alx on Tue Nov 18 09:57:49 2025
         Native configuration is x86_64-pc-linux-gnu
         
                        === objc tests ===
        --- ../maxof4_b4/./gcc/testsuite/g++/g++.sum    2025-11-18 
01:33:30.844922597 +0100
        +++ ./gcc/testsuite/g++/g++.sum 2025-11-18 10:07:34.586082401 +0100
        @@ -1,4 +1,4 @@
        -Test run by alx on Tue Nov 18 01:13:37 2025
        +Test run by alx on Tue Nov 18 09:57:48 2025
         Native configuration is x86_64-pc-linux-gnu
         
                        === g++ tests ===
        --- ../maxof4_b4/./gcc/testsuite/gcc/gcc.sum    2025-11-18 
01:28:55.398517706 +0100
        +++ ./gcc/testsuite/gcc/gcc.sum 2025-11-18 10:21:00.240376623 +0100
        @@ -1,4 +1,4 @@
        -Test run by alx on Tue Nov 18 01:13:37 2025
        +Test run by alx on Tue Nov 18 09:57:48 2025
         Native configuration is x86_64-pc-linux-gnu
         
                        === gcc tests ===
        @@ -94161,6 +94161,45 @@
         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-compat.c  (test for errors, line 4)
        +PASS: gcc.dg/maxof-compat.c  (test for errors, line 5)
        +PASS: gcc.dg/maxof-compat.c (test for excess errors)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 100)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 101)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 102)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 103)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 104)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 105)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 111)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 113)
        +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 122)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 123)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 80)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 82)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 84)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 86)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 88)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 89)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 90)
        +PASS: gcc.dg/maxof-compile.c  (test for errors, line 91)
        +PASS: gcc.dg/maxof-compile.c (test for excess errors)
        +PASS: gcc.dg/maxof-compile.c syntax error at line 112 (test for 
errors, line 111)
        +PASS: gcc.dg/maxof-compile.c syntax error at line 114 (test for 
errors, line 113)
        +PASS: gcc.dg/maxof-compile.c syntax error at line 81 (test for errors, 
line 80)
        +PASS: gcc.dg/maxof-compile.c syntax error at line 83 (test for errors, 
line 82)
        +PASS: gcc.dg/maxof-compile.c syntax error at line 85 (test for errors, 
line 84)
        +PASS: gcc.dg/maxof-compile.c syntax error at line 87 (test for errors, 
line 86)
        +PASS: gcc.dg/maxof-no-compat.c  (test for errors, line 4)
        +PASS: gcc.dg/maxof-no-compat.c  (test for errors, line 5)
        +PASS: gcc.dg/maxof-no-compat.c (test for excess errors)
        +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 \\("
        @@ -221120,7 +221159,7 @@
         
                        === gcc Summary ===
         
        -# of expected passes           215051
        +# of expected passes           215090
         # of unexpected failures       529
         # of unexpected successes      6
         # of expected failures         1486
        --- ../maxof4_b4/./gcc/testsuite/gfortran/gfortran.sum  2025-11-18 
01:25:14.257194034 +0100
        +++ ./gcc/testsuite/gfortran/gfortran.sum       2025-11-18 
10:12:35.459781488 +0100
        @@ -1,4 +1,4 @@
        -Test run by alx on Tue Nov 18 01:13:37 2025
        +Test run by alx on Tue Nov 18 09:57:48 2025
         Native configuration is x86_64-pc-linux-gnu
         
                        === gfortran tests ===



Have a lovely day!
Alex


Alejandro Colomar (3):
  c: Add _Maxof and _Minof operators
  c: Reduce excess errors of _Maxof and _Minof
  c: _Maxof and _Minof have not been accepted yet by the C Committee

 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                            |  65 +++++++-
 gcc/c/c-tree.h                               |   2 +
 gcc/c/c-typeck.cc                            |  54 ++++++
 gcc/doc/extend.texi                          |  19 +++
 gcc/testsuite/gcc.dg/maxof-compat.c          |   5 +
 gcc/testsuite/gcc.dg/maxof-compile.c         | 163 +++++++++++++++++++
 gcc/testsuite/gcc.dg/maxof-no-compat.c       |   5 +
 gcc/testsuite/gcc.dg/maxof-pedantic-errors.c |   5 +
 gcc/testsuite/gcc.dg/maxof-pedantic.c        |   5 +
 12 files changed, 363 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/maxof-compat.c
 create mode 100644 gcc/testsuite/gcc.dg/maxof-compile.c
 create mode 100644 gcc/testsuite/gcc.dg/maxof-no-compat.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 v3:
1:  960d6cd608f3 ! 1:  da4cf539a385 c: Add _Maxof and _Minof operators
    @@ Commit message
     
         Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3628.txt>
     
    -    This implementation differs from n3628 in that _Bool is not accepted by
    -    these operators in this implementation.  It was an oversight to allow
    -    _Bool in n3628, and I will publish a revision of that paper with that
    -    amended, prior to the next meeting of the C Committee.
    -
    -    These operators generalize the existing XXX_MAX and XXX_MIN macros.
    -    Those macros don't exist for _Bool, as it wouldn't be useful.
    -    Similarly, these new operators wouldn't be useful for use with _Bool,
    -    even if mathematically it could make sense to accept them as input.
    -
    -    To be cautious, let's constrain that, with the option to revisit that 
in
    -    the future, if a reason for accepting _Bool were discovered.
    -
         gcc/ChangeLog:
     
                 * doc/extend.texi (Syntax Extensions): Document _Maxof & 
_Minof.
    @@ gcc/c-family/c-common.cc: c_countof_type (location_t loc, tree type)
     +tree
     +c_maxof_type (location_t loc, tree type)
     +{
    -+  if (!INTEGRAL_TYPE_P (type) || TREE_CODE (type) == BOOLEAN_TYPE)
    ++  if (!INTEGRAL_TYPE_P (type))
     +    {
     +      error_at (loc, "invalid application of %<_Maxof%> to type %qT", 
type);
     +      return error_mark_node;
    @@ gcc/c-family/c-common.cc: c_countof_type (location_t loc, tree type)
     +tree
     +c_minof_type (location_t loc, tree type)
     +{
    -+  if (!INTEGRAL_TYPE_P (type) || TREE_CODE (type) == BOOLEAN_TYPE)
    ++  if (!INTEGRAL_TYPE_P (type))
     +    {
     +      error_at (loc, "invalid application of %<_Minof%> to type %qT", 
type);
     +      return error_mark_node;
    @@ gcc/testsuite/gcc.dg/maxof-compile.c (new)
     +  _Static_assert (_Minof (unsigned int) == 0);
     +  _Static_assert (_Minof (unsigned long) == 0);
     +  _Static_assert (_Minof (unsigned long long) == 0);
    ++
    ++  _Static_assert (_Maxof (bool) == true);
    ++  _Static_assert (_Minof (bool) == false);
     +}
     +
     +void
    @@ gcc/testsuite/gcc.dg/maxof-compile.c (new)
     +  _Minof (struct s);  /* { dg-error "to type" } */
     +  _Maxof (union u);  /* { dg-error "to type" } */
     +  _Minof (union u);  /* { dg-error "to type" } */
    -+  _Maxof (bool);  /* { dg-error "to type" } */
    -+  _Minof (bool);  /* { dg-error "to type" } */
     +  _Maxof (int [1]);  /* { dg-error "to type" } */
     +  _Minof (int [1]);  /* { dg-error "to type" } */
     +}
    @@ gcc/testsuite/gcc.dg/maxof-compile.c (new)
     +  _Generic (_Minof (unsigned long), unsigned long: 0);
     +  _Generic (_Minof (unsigned long long), unsigned long long: 0);
     +
    ++  _Generic (_Maxof (bool), bool: 0);
    ++  _Generic (_Minof (bool), bool: 0);
    ++
     +  _Generic (_Maxof (_BitInt (5)), _BitInt (5): 0);
     +  _Generic (_Minof (_BitInt (5)), _BitInt (5): 0);
     +  _Generic (_Maxof (unsigned _BitInt (5)), unsigned _BitInt (5): 0);
2:  c2a0e2455784 = 2:  96b815be5e5d c: Reduce excess errors of _Maxof and _Minof
3:  56794ade90a9 = 3:  4b4334f3c071 c: _Maxof and _Minof have not been accepted 
yet by the C Committee
4:  104197b2b14a < -:  ------------ c: Allow _Maxof(bool) & _Minof(bool), and 
add -Wmaxof-bool
-- 
2.51.0

Reply via email to