[cfe-commits] r38903 - in /cfe/cfe/trunk: Parse/DeclSpec.cpp Parse/ParseDecl.cpp include/clang/Parse/DeclSpec.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:25:38 PDT 2007
Author: sabre
Date: Wed Jul 11 11:25:38 2007
New Revision: 38903
URL: http://llvm.org/viewvc/llvm-project?rev=38903&view=rev
Log:
Recognize struct/union/enum as TypeSpecType's
Modified:
cfe/cfe/trunk/Parse/DeclSpec.cpp
cfe/cfe/trunk/Parse/ParseDecl.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=38903&r1=38902&r2=38903&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/DeclSpec.cpp (original)
+++ cfe/cfe/trunk/Parse/DeclSpec.cpp Wed Jul 11 11:25:38 2007
@@ -98,6 +98,9 @@
case DeclSpec::TST_decimal32: return "_Decimal32";
case DeclSpec::TST_decimal64: return "_Decimal64";
case DeclSpec::TST_decimal128: return "_Decimal128";
+ case DeclSpec::TST_enum: return "enum";
+ case DeclSpec::TST_union: return "union";
+ case DeclSpec::TST_struct: return "struct";
}
}
Modified: cfe/cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseDecl.cpp?rev=38903&r1=38902&r2=38903&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:25:38 2007
@@ -329,6 +329,7 @@
void Parser::ParseStructUnionSpecifier(DeclSpec &DS) {
assert((Tok.getKind() == tok::kw_struct ||
Tok.getKind() == tok::kw_union) && "Not a struct/union specifier");
+ SourceLocation Start = Tok.getLocation();
bool isUnion = Tok.getKind() == tok::kw_union;
ConsumeToken();
@@ -410,6 +411,11 @@
}
MatchRHSPunctuation(tok::r_brace, LBraceLoc, "{",diag::err_expected_rbrace);
+
+ const char *PrevSpec = 0;
+ if (DS.SetTypeSpecType(isUnion ? DeclSpec::TST_union : DeclSpec::TST_struct,
+ PrevSpec))
+ Diag(Start, diag::err_invalid_decl_spec_combination, PrevSpec);
}
@@ -431,6 +437,7 @@
///
void Parser::ParseEnumSpecifier(DeclSpec &DS) {
assert(Tok.getKind() == tok::kw_enum && "Not an enum specifier");
+ SourceLocation Start = Tok.getLocation();
ConsumeToken();
// Must have either 'enum name' or 'enum {...}'.
@@ -475,6 +482,11 @@
MatchRHSPunctuation(tok::r_brace, LBraceLoc, "{",
diag::err_expected_rbrace);
// TODO: semantic analysis on the declspec for enums.
+
+
+ const char *PrevSpec = 0;
+ if (DS.SetTypeSpecType(DeclSpec::TST_enum, PrevSpec))
+ Diag(Start, diag::err_invalid_decl_spec_combination, PrevSpec);
}
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=38903&r1=38902&r2=38903&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/DeclSpec.h Wed Jul 11 11:25:38 2007
@@ -71,7 +71,10 @@
TST_bool, // _Bool
TST_decimal32, // _Decimal32
TST_decimal64, // _Decimal64
- TST_decimal128 // _Decimal128
+ TST_decimal128, // _Decimal128
+ TST_enum,
+ TST_union,
+ TST_struct
} TypeSpecType : 4;
// type-qualifiers
More information about the cfe-commits
mailing list