aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorRobert Goss <goss.robert@gmail.com>2024-01-14 17:34:22 +0000
committerCohenArthur <arthur.cohen@embecosm.com>2024-01-23 16:13:10 +0000
commit7b203f66c1302c8783cf76b2b7604377073d0541 (patch)
tree33a36eb01eebcab7bc411e3d85ef9493baa1645e /libcpp
parent1586de85db580fa6fe5a3698c148d6b36209f8ff (diff)
downloadgcc-7b203f66c1302c8783cf76b2b7604377073d0541.zip
gcc-7b203f66c1302c8783cf76b2b7604377073d0541.tar.gz
gcc-7b203f66c1302c8783cf76b2b7604377073d0541.tar.bz2
Add improved error when no fields in initializer
If a struct type with a variant that has fields is initialized with some fields the expression HIR StructExprStructFields is checked that all the fields are assigned. However, if no fields are initialized the HIR StructExprStruct is generated. This doesn't check if the struct is a unit during typechekc and only fails at the compile stage with a ICE. Add a check at the typecheck stage that makes sure the struct does not have a variant with fields and give an error message based on the rustc one. We have also updated the message given in the case where one field was present to list the missing fields and match more closely the new message. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit) Add additional check * typecheck/rust-hir-type-check-struct-field.h: A helper method to make error added * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::resolve) Update message gcc/testsuite/ChangeLog: * rust/compile/missing_constructor_fields.rs: Added case with no initializers Signed-off-by: Robert Goss <goss.robert@gmail.com>
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions