r196387 - When parsing ignored attribute arguments, presuming the first argument is an unresolved identifier the same way that we do for unknown arguments. This resolves PR18075, where we regressed the handling of OpenBSD's bounded attribute.

Aaron Ballman aaron at aaronballman.com
Wed Dec 4 07:32:26 PST 2013


Author: aaronballman
Date: Wed Dec  4 09:32:26 2013
New Revision: 196387

URL: http://llvm.org/viewvc/llvm-project?rev=196387&view=rev
Log:
When parsing ignored attribute arguments, presuming the first argument is an unresolved identifier the same way that we do for unknown arguments. This resolves PR18075, where we regressed the handling of OpenBSD's bounded attribute.

Added:
    cfe/trunk/test/Sema/attr-bounded.c
Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=196387&r1=196386&r2=196387&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Dec  4 09:32:26 2013
@@ -288,7 +288,8 @@ void Parser::ParseGNUAttributeArgs(Ident
 
     // If we don't know how to parse this attribute, but this is the only
     // token in this argument, assume it's meant to be an identifier.
-    if (AttrKind == AttributeList::UnknownAttribute) {
+    if (AttrKind == AttributeList::UnknownAttribute ||
+        AttrKind == AttributeList::IgnoredAttribute) {
       const Token &Next = NextToken();
       IsIdentifierArg = Next.is(tok::r_paren) || Next.is(tok::comma);
     }

Added: cfe/trunk/test/Sema/attr-bounded.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-bounded.c?rev=196387&view=auto
==============================================================================
--- cfe/trunk/test/Sema/attr-bounded.c (added)
+++ cfe/trunk/test/Sema/attr-bounded.c Wed Dec  4 09:32:26 2013
@@ -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)));
\ No newline at end of file





More information about the cfe-commits mailing list