From 1b2fc0f3e181d99fb34f60e711066fb11628ecd0 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Wed, 25 Nov 2009 22:58:06 +0000 Subject: [PATCH] Fix attribute between function decl ')' and '{' or '=0' git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89894 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseDeclCXX.cpp | 7 +++++++ test/Parser/attributes.c | 1 + test/Parser/cxx-attributes.cpp | 9 +++++++++ 3 files changed, 17 insertions(+) create mode 100644 test/Parser/cxx-attributes.cpp diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 59cb90d6d0..505a4d800d 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -1144,6 +1144,13 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, return; } + // If attributes exist after the declarator, but before an '{', parse them. + if (Tok.is(tok::kw___attribute)) { + SourceLocation Loc; + AttributeList *AttrList = ParseGNUAttributes(&Loc); + DeclaratorInfo.AddAttributes(AttrList, Loc); + } + // function-definition: if (Tok.is(tok::l_brace) || (DeclaratorInfo.isFunctionDeclarator() && diff --git a/test/Parser/attributes.c b/test/Parser/attributes.c index dc2bb02670..cad39d382d 100644 --- a/test/Parser/attributes.c +++ b/test/Parser/attributes.c @@ -51,3 +51,4 @@ int foo42(void) { // rdar://6096491 void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void); +void d2(void) __attribute__((noreturn)), d3(void) __attribute__((noreturn)); diff --git a/test/Parser/cxx-attributes.cpp b/test/Parser/cxx-attributes.cpp new file mode 100644 index 0000000000..743d9b9ec1 --- /dev/null +++ b/test/Parser/cxx-attributes.cpp @@ -0,0 +1,9 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +class c { + virtual void f1(const char* a, ...) + __attribute__ (( __format__(__printf__,2,3) )) = 0; + virtual void f2(const char* a, ...) + __attribute__ (( __format__(__printf__,2,3) )) {} +}; + -- 2.40.0