Skip to content
Snippets Groups Projects
Commit d5cebf7e authored by Joseph Myers's avatar Joseph Myers
Browse files

c: Diagnose compound literal for empty array [PR114266]

As reported in bug 114266, GCC fails to pedwarn for a compound
literal, whose type is an array of unknown size, initialized with an
empty initializer.  This case is disallowed by C23 (which doesn't have
zero-size objects); the case of a named object is diagnosed as
expected, but not that for compound literals.  (Before C23, the
pedwarn for empty initializers sufficed.)  Add a check for this
specific case with a pedwarn.

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

	PR c/114266

gcc/c/
	* c-decl.cc (build_compound_literal): Diagnose array of unknown
	size with empty initializer for C23.

gcc/testsuite/
	* gcc.dg/c23-empty-init-4.c: New test.
parent cf544af0
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment