File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -4165,11 +4165,12 @@ AttrInputMetaItemContainer::separate_cfg_attrs () const
41654165bool
41664166Attribute::check_cfg_predicate (const Session &session) const
41674167{
4168+ auto string_path = path.as_string ();
41684169 /* assume that cfg predicate actually can exist, i.e. attribute has cfg or
41694170 * cfg_attr path */
41704171 if (!has_attr_input ()
4171- || (path. as_string () != Values::Attributes::CFG
4172- && path. as_string () != Values::Attributes::CFG_ATTR))
4172+ || (string_path != Values::Attributes::CFG
4173+ && string_path != Values::Attributes::CFG_ATTR))
41734174 {
41744175 // DEBUG message
41754176 rust_debug (
@@ -4185,6 +4186,13 @@ Attribute::check_cfg_predicate (const Session &session) const
41854186 return false ;
41864187
41874188 auto &meta_item = static_cast <AttrInputMetaItemContainer &> (*attr_input);
4189+ if (meta_item.get_items ().empty ()
4190+ && string_path == Values::Attributes::CFG_ATTR)
4191+ {
4192+ rust_error_at (path.get_locus (),
4193+ " malformed %<cfg_attr%> attribute input" );
4194+ return false ;
4195+ }
41884196 return meta_item.get_items ().front ()->check_cfg_predicate (session);
41894197}
41904198
Original file line number Diff line number Diff line change 1+ struct S {
2+ #[ cfg_attr( ) ]
3+ field : u8 ,
4+ // { dg-error "malformed .cfg_attr. attribute input" "" { target *-*-* } .-2 }
5+ }
You can’t perform that action at this time.
0 commit comments