]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Add ast validation check on union variant number
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Mon, 20 Nov 2023 14:41:39 +0000 (15:41 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 30 Jan 2024 11:36:44 +0000 (12:36 +0100)
commit72792563e60fb56b42c2e96b3ae27d28e09c2e7d
tree995e7a3930a3162cf43fa392238fe32e3078e0b4
parent4f45c715b83b91fe3c5a326a3474c7cebeefc09f
gccrs: Add ast validation check on union variant number

Unions with zero fields are forbidden. Add regression test for empty
unions.

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add
zero field check during ast validation pass.
* checks/errors/rust-ast-validation.h: Add union visit function
prototype.

gcc/testsuite/ChangeLog:

* rust/compile/const_generics_8.rs: Fill the union with dummy values.
* rust/compile/empty_union.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/checks/errors/rust-ast-validation.cc
gcc/rust/checks/errors/rust-ast-validation.h
gcc/testsuite/rust/compile/const_generics_8.rs
gcc/testsuite/rust/compile/empty_union.rs [new file with mode: 0644]