Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions gcc/rust/typecheck/rust-hir-type-check-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ TypeCheckBase::parse_repr_options (const AST::AttrVec &attrs, location_t locus)
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");
rust_error_at (attr.get_locus (), "malformed %<repr%> attribute");
continue;
}

Expand All @@ -421,7 +421,11 @@ TypeCheckBase::parse_repr_options (const AST::AttrVec &attrs, location_t locus)
const AST::AttrInput &input = attr.get_attr_input ();
bool is_token_tree = input.get_attr_input_type ()
== AST::AttrInput::AttrInputType::TOKEN_TREE;
rust_assert (is_token_tree);
if (!is_token_tree)
{
rust_error_at (attr.get_locus (), "malformed %<repr%> attribute");
continue;
}
const auto &option = static_cast<const AST::DelimTokenTree &> (input);
AST::AttrInputMetaItemContainer *meta_items
= option.parse_to_meta_item ();
Expand Down
6 changes: 6 additions & 0 deletions gcc/testsuite/rust/compile/issue-4231.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[repr = ""] // { dg-error "malformed .repr. attribute" }
struct ThreeInts {
first: i16,
second: i8,
third: i32
}
Loading