Fix issue with GCC attribute syntax

This commit is contained in:
Jonathan Müller 2017-10-30 18:52:11 +01:00
commit da3d515d09
4 changed files with 15 additions and 17 deletions

View file

@ -561,12 +561,16 @@ namespace
}
}
cpp_attribute_list detail::parse_attributes(detail::cxtoken_stream& stream)
cpp_attribute_list detail::parse_attributes(detail::cxtoken_stream& stream, bool skip_anway)
{
cpp_attribute_list result;
while (parse_attribute_impl(result, stream))
{
}
skip_anway = false;
if (skip_anway)
stream.bump();
return result;
}

View file

@ -191,7 +191,8 @@ namespace cppast
void skip_brackets(cxtoken_stream& stream);
// parses attributes
cpp_attribute_list parse_attributes(cxtoken_stream& stream);
// if skip_anyway is true it will bump even if no attributes have been parsed
cpp_attribute_list parse_attributes(cxtoken_stream& stream, bool skip_anyway = false);
// converts a token range to a string
cpp_token_string to_string(cxtoken_stream& stream, cxtoken_iterator end);

View file

@ -281,12 +281,9 @@ namespace
result.is_explicit = true;
else
{
auto attributes = detail::parse_attributes(stream);
if (attributes.empty())
stream.bump();
else
result.attributes.insert(result.attributes.end(), attributes.begin(),
attributes.end());
auto attributes = detail::parse_attributes(stream, true);
result.attributes.insert(result.attributes.end(), attributes.begin(),
attributes.end());
}
}
DEBUG_ASSERT(!stream.done(), detail::parse_error_handler{}, stream.cursor(),
@ -296,8 +293,7 @@ namespace
}
auto attributes = detail::parse_attributes(stream);
if (!attributes.empty())
result.attributes.insert(result.attributes.end(), attributes.begin(), attributes.end());
result.attributes.insert(result.attributes.end(), attributes.begin(), attributes.end());
return result;
}

View file

@ -38,11 +38,8 @@ std::unique_ptr<cpp_expression> detail::parse_default_value(cpp_attribute_list&
}
else
{
auto cur_attributes = detail::parse_attributes(stream);
if (cur_attributes.empty())
stream.bump();
else
attributes.insert(attributes.end(), cur_attributes.begin(), cur_attributes.end());
auto cur_attributes = detail::parse_attributes(stream, true);
attributes.insert(attributes.end(), cur_attributes.begin(), cur_attributes.end());
}
}
if (has_default)