gccrs: FIX ICE for malformed repr attribute

Fixes Rust-GCC#3614

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): check for input

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3614.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
This commit is contained in:
Philip Herron 2025-03-28 17:52:51 +00:00 committed by Arthur Cohen
parent 3729b279fb
commit 5d6467f637
2 changed files with 9 additions and 0 deletions

View file

@ -305,6 +305,12 @@ TypeCheckBase::parse_repr_options (const AST::AttrVec &attrs, location_t locus)
for (const auto &attr : attrs)
{
bool is_repr = attr.get_path ().as_string () == Values::Attributes::REPR;
if (is_repr && !attr.has_attr_input ())
{
rust_error_at (attr.get_locus (), "malformed %qs attribute", "repr");
continue;
}
if (is_repr)
{
const AST::AttrInput &input = attr.get_attr_input ();

View file

@ -0,0 +1,3 @@
#[repr] // { dg-error "malformed .repr. attribute" }
struct _B {}