Skip to content

Commit 6130523

Browse files
committed
gccrs: FIX ICE for malformed repr attribute
Fixes #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>
1 parent 8d1c01c commit 6130523

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

gcc/rust/typecheck/rust-hir-type-check-base.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,12 @@ TypeCheckBase::parse_repr_options (const AST::AttrVec &attrs, location_t locus)
305305
for (const auto &attr : attrs)
306306
{
307307
bool is_repr = attr.get_path ().as_string () == Values::Attributes::REPR;
308+
if (is_repr && !attr.has_attr_input ())
309+
{
310+
rust_error_at (attr.get_locus (), "malformed %qs attribute", "repr");
311+
continue;
312+
}
313+
308314
if (is_repr)
309315
{
310316
const AST::AttrInput &input = attr.get_attr_input ();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#[repr] // { dg-error "malformed .repr. attribute" }
2+
3+
struct _B {}

0 commit comments

Comments
 (0)