[PATCH] Fix Clang support for OpenBSD 'bounded' attribute

Aaron Ballman aaron at aaronballman.com
Wed Dec 4 07:36:55 PST 2013


On Wed, Dec 4, 2013 at 10:19 AM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
> ccing Aaron which is probably the best reviewer.
>
> On 4 December 2013 03:27, Matthew Dempsky <matthew at dempsky.org> wrote:
>> Patch below addresses bug 18075, a regression in Clang's ability to
>> ignore OpenBSD's "bounded" attribute extension.  Included also is a
>> patch to hopefully prevent such future regressions.
>>
>> I'd appreciate if someone would commit this for me; it prevents almost
>> all code from being compiled on OpenBSD with Clang.
>>
>> Thanks!
>>
>> Index: include/clang/Basic/Attr.td
>> ===================================================================
>> --- include/clang/Basic/Attr.td (revision 196358)
>> +++ include/clang/Basic/Attr.td (working copy)
>> @@ -286,6 +286,8 @@
>>
>>  def Bounded : IgnoredAttr {
>>    let Spellings = [GNU<"bounded">];
>> +  let Args = [IdentifierArgument<"Type">, IntArgument<"Arg1">,
>> +              IntArgument<"Arg2">, IntArgument<"Arg3", 1>];

Ah, this is interesting -- because bounded is an ignored attribute,
the args are useless for semantic checking, but not for parsing.
Because it takes an unresolved identifier as the first argument,
without the args it will cause problems by trying to resolve the
argument, which it can't do.

I think there's a better way to fix this than to add the args to the
attribute, which is to improve the argument parsing code. It already
handles unknown attributes properly, it just needs to handle ignored
attributes as well.

I've fixed this in r196387, thank you for bringing it up!

~Aaron




More information about the cfe-commits mailing list