]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: Implement C2Y alignof on incomplete arrays
authorJoseph Myers <josmyers@redhat.com>
Mon, 17 Jun 2024 19:45:43 +0000 (19:45 +0000)
committerJoseph Myers <josmyers@redhat.com>
Mon, 17 Jun 2024 19:45:43 +0000 (19:45 +0000)
commitedf514f83fa41012e52aaef2faef5a649e4b3f6d
tree9bbfe742a84e6b96e8d08b2af3404550b0b0a7be
parentb63c7d92012f92e0517190cf263d29bbef8a06bf
c: Implement C2Y alignof on incomplete arrays

C2Y has adopted support for alignof applied to incomplete array types
(N3273).  Add this support to GCC.  As the relevant checks are in
c-family code that doesn't have access to functions such as
pedwarn_c23, this remains a hard error for older versions and isn't
handled by -Wc23-c2y-compat, although preferably it would work like
pedwarn_c23 (pedwarn-if-pedantic for older versions, warning with
-Wc23-c2y-compat in C2Y mode).

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c-family/
* c-common.cc (c_sizeof_or_alignof_type): Allow alignof on an
incomplete array type for C2Y.

gcc/testsuite/
* gcc.dg/c23-align-10.c, gcc.dg/c2y-align-1.c,
gcc.dg/c2y-align-2.c: New tests.
gcc/c-family/c-common.cc
gcc/testsuite/gcc.dg/c23-align-10.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2y-align-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2y-align-2.c [new file with mode: 0644]