]> granicus.if.org Git - clang/commitdiff
Retain attributes for K&R style parameter declarations.
authorRichard Pennington <rich@pennware.com>
Tue, 23 Feb 2010 12:22:13 +0000 (12:22 +0000)
committerRichard Pennington <rich@pennware.com>
Tue, 23 Feb 2010 12:22:13 +0000 (12:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96941 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/Parser.cpp
test/Parser/knr_parameter_attributes.c [new file with mode: 0644]

index 30899c5dddb5b664bfdd84ba71d3fc0c6d055a89..24162373e0eb3ac9c2a5b55bbff131e17ff48528 100644 (file)
@@ -743,10 +743,11 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) {
     // Handle the full declarator list.
     while (1) {
       // If attributes are present, parse them.
-      llvm::OwningPtr<AttributeList> AttrList;
-      if (Tok.is(tok::kw___attribute))
-        // FIXME: attach attributes too.
-        AttrList.reset(ParseGNUAttributes());
+      if (Tok.is(tok::kw___attribute)) {
+        SourceLocation Loc;
+        AttributeList *AttrList = ParseGNUAttributes(&Loc);
+        ParmDeclarator.AddAttributes(AttrList, Loc);
+      }
 
       // Ask the actions module to compute the type for this declarator.
       Action::DeclPtrTy Param =
diff --git a/test/Parser/knr_parameter_attributes.c b/test/Parser/knr_parameter_attributes.c
new file mode 100644 (file)
index 0000000..fb975cb
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -W -Wall -Werror -verify %s
+
+int f(int i __attribute__((__unused__)))
+{
+    return 0;
+}
+int g(i)
+    int i __attribute__((__unused__));
+{
+    return 0;
+}