Add location for malformed attribute errors and avoid processing of
malformed attributes.
gcc/rust/ChangeLog:
* ast/rust-ast.cc (AttrInputMetaItemContainer::separate_cfg_attrs):
Avoid malformed attributes.
* util/rust-attributes.cc (AttributeChecker::visit): Change location.
gcc/testsuite/ChangeLog:
* rust/compile/attr_malformed_path.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
for (auto it = items.begin () + 1; it != items.end (); ++it)
{
+ if ((*it)->get_kind () == MetaItemInner::Kind::MetaItem
+ && static_cast<MetaItem &> (**it).get_item_kind ()
+ == MetaItem::ItemKind::PathExpr
+ && !static_cast<MetaItemPathExpr &> (**it).get_expr ().is_literal ())
+ continue;
+
Attribute attr = (*it)->to_attribute ();
if (attr.is_empty ())
{
{
if (!attribute.get_expr ().is_literal ())
{
- rust_error_at (attribute.get_locus (),
+ rust_error_at (attribute.get_expr ().get_locus (),
"malformed %<path%> attribute input");
- rust_inform (attribute.get_locus (),
+ rust_inform (attribute.get_expr ().get_locus (),
"must be of the form: %<#[path = \"file\"]%>");
}
}
--- /dev/null
+#[cfg_attr(target_arch = "x86_64", path = (target_arch = "x86", path = "x86.rs"))]
+mod imp {}
+// { dg-error "malformed .path. attribute input" "" { target *-*-* } .-2 }