]> git.ipfire.org Git - thirdparty/gcc.git/commit
[hardbool] implement OP=, ++ and --, volatile and atomics
authorAlexandre Oliva <oliva@adacore.com>
Wed, 6 Aug 2025 19:31:50 +0000 (16:31 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Wed, 6 Aug 2025 19:31:50 +0000 (16:31 -0300)
commit01a523943c0a9b297726289d7333a5217b1d4d31
tree65e3025c886faac48b321ffcbf131a914026936a
parent88732d9eb88298a2e7a999c83878c8ea9edc5827
[hardbool] implement OP=, ++ and --, volatile and atomics

hardbools didn't behave quite like bools when incremented,
decremented, or otherwise modified using their previous value, as in
+= et al.  Fix that.

Also fix some checking errors that come up when using qualified base
types.

for  gcc/c-family/ChangeLog

* c-attribs.cc (handle_hardbool_attribute): Create distinct
enumeration types, with structural equality.  Handle
base type qualifiers.

for  gcc/c/ChangeLog

* c-tree.h (C_BOOLEAN_TYPE_P): Cover hardbools as well.
* c-typeck.cc (convert_lvalue_to_rvalue): New overload and
wrapper.
(build_atomic_assign, build_modify_expr): Use it.
(build_asm_expr, handle_omp-array_sections_1): Simplify with
it.
(build_unary_op): Handle hardbools.

for  gcc/testsuite/ChangeLog

* gcc.dg/torture/hardbool-ai.c: New.
* gcc.dg/torture/hardbool-vi.c: New.
* gcc.dg/torture/hardbool.c: Handle NO_BITFIELDS.
(add1, preinc, postinc, sub1, predec, postdec): New.
(main): Exercise them.
gcc/c-family/c-attribs.cc
gcc/c/c-tree.h
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/torture/hardbool-ai.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/hardbool-vi.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/hardbool.c