]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: Check for modifiable static compound literals in inline definitions
authorJoseph Myers <joseph@codesourcery.com>
Mon, 9 Jan 2023 21:56:34 +0000 (21:56 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Mon, 9 Jan 2023 21:56:34 +0000 (21:56 +0000)
commit799e2e7f023784b9cdcebfe5751d183d125b2bd8
treeb06e62909bde04fd684f9c5265f1c3abb0d0a79b
parent150d4b02838c73b392c4da89a5acc0130c0950e0
c: Check for modifiable static compound literals in inline definitions

The C rule against modifiable objects with static storage duration in
inline definitions should apply to compound literals (using the C2x
feature of storage-class specifiers for compound literals) just as to
variables.  Add a call to record_inline_static for compound literals
to make sure this case is detected.

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

gcc/c/
* c-decl.cc (build_compound_literal): Call record_inline_static.

gcc/testsuite/
* gcc.dg/c2x-complit-8.c: New test.
gcc/c/c-decl.cc
gcc/testsuite/gcc.dg/c2x-complit-8.c [new file with mode: 0644]