diff options
| author | Richard Pennington <rich@pennware.com> | 2010-02-23 12:22:13 +0000 |
|---|---|---|
| committer | Richard Pennington <rich@pennware.com> | 2010-02-23 12:22:13 +0000 |
| commit | 14cc983d86f883e320f27955926f5beeb5385471 (patch) | |
| tree | 496d697e20bdc4e52aa35402f053e1e5eda5da6b | |
| parent | 7e4acbdf530251544e0237a8a50889acffd972ca (diff) | |
| download | bcm5719-llvm-14cc983d86f883e320f27955926f5beeb5385471.tar.gz bcm5719-llvm-14cc983d86f883e320f27955926f5beeb5385471.zip | |
Retain attributes for K&R style parameter declarations.
llvm-svn: 96941
| -rw-r--r-- | clang/lib/Parse/Parser.cpp | 9 | ||||
| -rw-r--r-- | clang/test/Parser/knr_parameter_attributes.c | 11 |
2 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 30899c5dddb..24162373e0e 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/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/clang/test/Parser/knr_parameter_attributes.c b/clang/test/Parser/knr_parameter_attributes.c new file mode 100644 index 00000000000..fb975cbf332 --- /dev/null +++ b/clang/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; +} |

