summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-04-13 21:30:24 +0000
committerDouglas Gregor <dgregor@apple.com>2008-04-13 21:30:24 +0000
commit556877c1e677a33052662a1879616129fa11559e (patch)
treec3e8933deb10c3cd6e86bc0596c2b0f567c4cab2 /clang/lib/Parse/ParseDecl.cpp
parent83a586ec19dd0db7fe4bc3b8e881173ae07f74f4 (diff)
downloadbcm5719-llvm-556877c1e677a33052662a1879616129fa11559e.tar.gz
bcm5719-llvm-556877c1e677a33052662a1879616129fa11559e.zip
This patch adds very basic support for parsing and type-checking class
inheritance in C++. It'll parse the base-specifier list, e.g., class D : public B1, virtual public B2 { }; and do some of the simpler semantic checks (B1 and B2 are classes; they aren't unions or incomplete types, etc). llvm-svn: 49623
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp40
1 files changed, 2 insertions, 38 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 8a0dcce31c8..65f1124e632 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -519,7 +519,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS) {
case tok::kw_class:
case tok::kw_struct:
case tok::kw_union:
- ParseStructUnionSpecifier(DS);
+ ParseClassSpecifier(DS);
continue;
case tok::kw_enum:
ParseEnumSpecifier(DS);
@@ -608,42 +608,6 @@ bool Parser::ParseTag(DeclTy *&Decl, unsigned TagType, SourceLocation StartLoc){
return false;
}
-
-/// ParseStructUnionSpecifier
-/// struct-or-union-specifier: [C99 6.7.2.1]
-/// struct-or-union identifier[opt] '{' struct-contents '}'
-/// struct-or-union identifier
-/// [GNU] struct-or-union attributes[opt] identifier[opt] '{' struct-contents
-/// '}' attributes[opt]
-/// [GNU] struct-or-union attributes[opt] identifier
-/// struct-or-union:
-/// 'struct'
-/// 'union'
-///
-void Parser::ParseStructUnionSpecifier(DeclSpec &DS) {
- assert((Tok.is(tok::kw_class) ||
- Tok.is(tok::kw_struct) ||
- Tok.is(tok::kw_union)) &&
- "Not a class/struct/union specifier");
- DeclSpec::TST TagType =
- Tok.is(tok::kw_class) ? DeclSpec::TST_class :
- Tok.is(tok::kw_union) ? DeclSpec::TST_union : DeclSpec::TST_struct;
- SourceLocation StartLoc = ConsumeToken();
-
- // Parse the tag portion of this.
- DeclTy *TagDecl;
- if (ParseTag(TagDecl, TagType, StartLoc))
- return;
-
- // If there is a body, parse it and inform the actions module.
- if (Tok.is(tok::l_brace))
- ParseStructUnionBody(StartLoc, TagType, TagDecl);
-
- const char *PrevSpec = 0;
- if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, TagDecl))
- Diag(StartLoc, diag::err_invalid_decl_spec_combination, PrevSpec);
-}
-
/// ParseStructDeclaration - Parse a struct declaration without the terminating
/// semicolon.
///
@@ -736,7 +700,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
// Empty structs are an extension in C (C99 6.7.2.1p7), but are allowed in
// C++.
- if (Tok.is(tok::r_brace))
+ if (Tok.is(tok::r_brace) && !getLang().CPlusPlus)
Diag(Tok, diag::ext_empty_struct_union_enum,
DeclSpec::getSpecifierName((DeclSpec::TST)TagType));
OpenPOWER on IntegriCloud