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

Matthew Dempsky matthew at dempsky.org
Wed Dec 4 00:27:29 PST 2013


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)));



More information about the cfe-commits mailing list