aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppdefault.cc
diff options
context:
space:
mode:
authorJoseph Myers <josmyers@redhat.com>2025-09-20 00:24:26 +0000
committerJoseph Myers <josmyers@redhat.com>2025-09-20 00:24:26 +0000
commit3eca9b5119f235666a2d97cb77a6cddc567bbe8b (patch)
tree1de98b944bf7a5802f9efb96c4cc73330aab441e /gcc/cppdefault.cc
parentdcc231417fcb24f90ad2563c47edee04326426a1 (diff)
downloadgcc-3eca9b5119f235666a2d97cb77a6cddc567bbe8b.zip
gcc-3eca9b5119f235666a2d97cb77a6cddc567bbe8b.tar.gz
gcc-3eca9b5119f235666a2d97cb77a6cddc567bbe8b.tar.bz2
c: Implement C2y N3481 constraint against lvalue conversion with incomplete type
C2y replaces undefined behavior for lvalue conversion of an lvalue with incomplete, non-array type with a constraint violation. Implement this in GCC, which means disallowing lvalue conversion of qualified or atomic void for C2y. (Unqualified, non-atomic void is excluded from the definition of "lvalue".) I'm not convinced that the resolution of C90 DR#106 (which said that certain cases with qualified void were valid) was really justified even based on the wording of C90; nevertheless, this patch takes the conservative approach of only disallowing qualified void here for C2y. The test for this change showed that attempting to access an _Atomic void object produced an ICE-after-error attempting the atomic load logic for such a type. require_complete_type returning error_mark_node prevents this ICE from occurring any more in C2y mode; to avoid it in older modes, a check of COMPLETE_TYPE_P is added to really_atomic_lvalue. I didn't find any existing bug report in Bugzilla for this issue. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c/ * c-typeck.cc (really_atomic_lvalue): Return false for incomplete types. (convert_lvalue_to_rvalue): Call require_complete_type for qualified void for C2y. gcc/testsuite/ * gcc.dg/c11-atomic-6.c, gcc.dg/c23-incomplete-1.c, gcc.dg/c2y-incomplete-3.c: New tests.
Diffstat (limited to 'gcc/cppdefault.cc')
0 files changed, 0 insertions, 0 deletions