]> gcc.gnu.org Git - gcc.git/commit
c: Fix up error-recovery on functions initialized as variables [PR109412]
authorJakub Jelinek <jakub@redhat.com>
Thu, 27 Apr 2023 09:35:55 +0000 (11:35 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 27 Apr 2023 09:35:55 +0000 (11:35 +0200)
commita1030fbf70eef5b635e4fbb904ec7209ebd137ca
tree3a92867dffd66e5ab33578e84e12f39d5b165279
parent429c72eb632040bacef9569b6d783d72fee93b42
c: Fix up error-recovery on functions initialized as variables [PR109412]

The change to allow empty initializers in C broke error-recovery on the
following testcase.  We are emitting function %qD is initialized like a
variable error early; if the initializer is non-empty, we just emit
another error that the initializer is invalid.  Previously if it was empty,
we'd emit another error that scalar is being initialized by empty
initializer (not really correct), but now we instead just try to
build_zero_cst for the FUNCTION_TYPE and ICE on it.

The following patch just emits the same diagnostics for the empty
initializers as we emit for the non-empty ones.

2023-04-27  Jakub Jelinek  <jakub@redhat.com>

PR c/107682
PR c/109412
* c-typeck.cc (pop_init_level): If constructor_type is FUNCTION_TYPE,
reject empty initializer as invalid.

* gcc.dg/pr109412.c: New test.
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/pr109412.c [new file with mode: 0644]
This page took 0.066767 seconds and 5 git commands to generate.