aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Parse/Parser.cpp9
-rw-r--r--test/Parser/knr_parameter_attributes.c11
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 30899c5ddd..24162373e0 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -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
index 0000000000..fb975cbf33
--- /dev/null
+++ b/test/Parser/knr_parameter_attributes.c
@@ -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;
+}