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

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Dec 4 07:19:46 PST 2013


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>];
>  }
>
>  def CarriesDependency : InheritableParamAttr {
> Index: test/Misc/openbsd-bounded.c
> ===================================================================
> --- test/Misc/openbsd-bounded.c (revision 0)
> +++ test/Misc/openbsd-bounded.c (working copy)
> @@ -0,0 +1,15 @@
> +// RUN: %clang_cc1 -fsyntax-only %s
> +// Make sure OpenBSD's bounded extension is accepted.
> +
> +typedef long ssize_t;
> +typedef unsigned long size_t;
> +typedef struct FILE FILE;
> +
> +ssize_t read(int, void *, size_t)
> +    __attribute__((__bounded__(__buffer__,2,3)));
> +int readlink(const char *, char *, size_t)
> +    __attribute__((__bounded__(__string__,2,3)));
> +size_t fread(void *, size_t, size_t, FILE *)
> +    __attribute__((__bounded__(__size__,1,3,2)));
> +char *getwd(char *)
> +    __attribute__((__bounded__(__minbytes__,1,1024)));
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list