[cfe-commits] r38915 - in /cfe/cfe/trunk: Parse/DeclSpec.cpp Parse/ParseDecl.cpp Parse/ParseStmt.cpp include/clang/Parse/DeclSpec.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:25:43 PDT 2007
Author: sabre
Date: Wed Jul 11 11:25:43 2007
New Revision: 38915
URL: http://llvm.org/viewvc/llvm-project?rev=38915&view=rev
Log:
Fix the last remaining FIXME's in the parser by asking the actions module
whether or not an identifier is a typedef name.
Modified:
cfe/cfe/trunk/Parse/DeclSpec.cpp
cfe/cfe/trunk/Parse/ParseDecl.cpp
cfe/cfe/trunk/Parse/ParseStmt.cpp
cfe/cfe/trunk/include/clang/Parse/DeclSpec.h
Modified: cfe/cfe/trunk/Parse/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/DeclSpec.cpp?rev=38915&r1=38914&r2=38915&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/DeclSpec.cpp (original)
+++ cfe/cfe/trunk/Parse/DeclSpec.cpp Wed Jul 11 11:25:43 2007
@@ -101,6 +101,7 @@
case DeclSpec::TST_enum: return "enum";
case DeclSpec::TST_union: return "union";
case DeclSpec::TST_struct: return "struct";
+ case DeclSpec::TST_typedef: return "typedef";
}
}
Modified: cfe/cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseDecl.cpp?rev=38915&r1=38914&r2=38915&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:25:43 2007
@@ -173,7 +173,7 @@
/// 'unsigned'
/// struct-or-union-specifier
/// enum-specifier
-/// typedef-name [TODO]
+/// typedef-name
/// [C99] '_Bool'
/// [C99] '_Complex'
/// [C99] '_Imaginary' // Removed in TC2?
@@ -197,6 +197,17 @@
int isInvalid = false;
const char *PrevSpec = 0;
switch (Tok.getKind()) {
+ // typedef-name
+ case tok::identifier:
+ // This identifier can only be a typedef name if we haven't already seen
+ // a typename. This avoids the virtual method call on things like
+ // 'int foo'.
+ if (DS.TypeSpecType == DeclSpec::TST_unspecified &&
+ Actions.isTypedefName(*Tok.getIdentifierInfo(), CurScope)) {
+ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typedef, PrevSpec);
+ break;
+ }
+ // FALL THROUGH.
default:
// If this is not a declaration specifier token, we're done reading decl
// specifiers. First verify that DeclSpec's are consistent.
@@ -290,9 +301,6 @@
ParseEnumSpecifier(DS);
continue;
- //case tok::identifier:
- // TODO: handle typedef names.
-
// type-qualifier
case tok::kw_const:
isInvalid = DS.SetTypeQual(DeclSpec::TQ_const , PrevSpec, getLang())*2;
@@ -548,8 +556,7 @@
// typedef-name
case tok::identifier:
- // FIXME: if this is a typedef return true.
- return false;
+ return Actions.isTypedefName(*Tok.getIdentifierInfo(), CurScope);
// TODO: Attributes.
}
@@ -602,8 +609,7 @@
// typedef-name
case tok::identifier:
- // FIXME: if this is a typedef return true.
- return false;
+ return Actions.isTypedefName(*Tok.getIdentifierInfo(), CurScope);
// TODO: Attributes.
}
}
Modified: cfe/cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseStmt.cpp?rev=38915&r1=38914&r2=38915&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseStmt.cpp Wed Jul 11 11:25:43 2007
@@ -196,7 +196,8 @@
}
// declaration
- if (!OnlyStatement && 0/*Is typedef name!*/) {
+ if (!OnlyStatement &&
+ Actions.isTypedefName(*IdentTok.getIdentifierInfo(), CurScope)) {
// Handle this. Warn/disable if in middle of block and !C99.
DeclSpec DS;
Modified: cfe/cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=38915&r1=38914&r2=38915&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/DeclSpec.h Wed Jul 11 11:25:43 2007
@@ -74,7 +74,8 @@
TST_decimal128, // _Decimal128
TST_enum,
TST_union,
- TST_struct
+ TST_struct,
+ TST_typedef
} TypeSpecType : 4;
// type-qualifiers
More information about the cfe-commits
mailing list