[cfe-commits] r38924 - in /cfe/cfe/trunk: Parse/ParseDecl.cpp include/clang/Parse/Parser.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:25:49 PDT 2007
Author: sabre
Date: Wed Jul 11 11:25:49 2007
New Revision: 38924
URL: http://llvm.org/viewvc/llvm-project?rev=38924&view=rev
Log:
Parse (and ignore) attributes on global decls.
Modified:
cfe/cfe/trunk/Parse/ParseDecl.cpp
cfe/cfe/trunk/include/clang/Parse/Parser.h
Modified: cfe/cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseDecl.cpp?rev=38924&r1=38923&r2=38924&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:25:49 2007
@@ -33,6 +33,38 @@
ParseDeclarator(DeclaratorInfo);
}
+/// ParseAttributes - Parse a non-empty attributes list.
+///
+/// [GNU] attributes:
+/// attribute
+/// attributes attribute
+///
+/// [GNU] attribute:
+/// '__attribute__' '(' '(' attribute-list ')' ')'
+///
+/// [GNU] attribute-list:
+/// attrib
+/// attribute_list ',' attrib
+///
+/// [GNU] attrib:
+/// empty
+/// any-word
+/// any-word '(' identifier ')'
+/// any-word '(' identifier ',' nonempty-expr-list ')'
+/// any-word '(' expr-list ')'
+///
+void Parser::ParseAttributes() {
+ assert(Tok.getKind() == tok::kw___attribute && "Not an attribute list!");
+ ConsumeToken();
+
+ if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
+ "attribute"))
+ return;
+
+ // TODO: Parse the attributes.
+ SkipUntil(tok::r_paren, false);
+}
+
/// ParseDeclaration - Parse a full 'declaration', which consists of
/// declaration-specifiers, some number of declarators, and a semicolon.
@@ -85,7 +117,9 @@
if (Tok.getKind() == tok::kw_asm)
ParseSimpleAsm();
- // TODO: parse attributes.
+ // If attributes are present, parse them.
+ if (Tok.getKind() == tok::kw___attribute)
+ ParseAttributes();
// Parse declarator '=' initializer.
ExprResult Init;
Modified: cfe/cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/Parser.h?rev=38924&r1=38923&r2=38924&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/Parser.h Wed Jul 11 11:25:49 2007
@@ -271,6 +271,7 @@
bool isTypeSpecifierQualifier() const;
void ParseTypeName();
+ void ParseAttributes();
/// ParseDeclarator - Parse and verify a newly-initialized declarator.
void ParseDeclarator(Declarator &D);
More information about the cfe-commits
mailing list