diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-05-28 23:31:59 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-05-28 23:31:59 +0000 |
| commit | d6ab8744dc68e7dec176a5899e1d68a4a8de91f0 (patch) | |
| tree | e89c1975579fc2878073be045572ebe378d8baa5 /clang/lib/Parse/ParseDecl.cpp | |
| parent | 2a69547f387883603eaad8467af97a864ed37299 (diff) | |
| download | bcm5719-llvm-d6ab8744dc68e7dec176a5899e1d68a4a8de91f0.tar.gz bcm5719-llvm-d6ab8744dc68e7dec176a5899e1d68a4a8de91f0.zip | |
When we parse a tag specifier, keep track of whether that tag
specifier resulted in the creation of a new TagDecl node, which
happens either when the tag specifier was a definition or when the tag
specifier was the first declaration of that tag type. This information
has several uses, the first of which is implemented in this commit:
1) In C++, one is not allowed to define tag types within a type
specifier (e.g., static_cast<struct S { int x; } *>(0) is
ill-formed) or within the result or parameter types of a
function. We now diagnose this.
2) We can extend DeclGroups to contain information about any tags
that are declared/defined within the declaration specifiers of a
variable, e.g.,
struct Point { int x, y, z; } p;
This will help improve AST printing and template instantiation,
among other things.
3) For C99, we can keep track of whether a tag type is defined
within the type of a parameter, to properly cope with cases like,
e.g.,
int bar(struct T2 { int x; } y) {
struct T2 z;
}
We can also do similar things wherever there is a type specifier,
e.g., to keep track of where the definition of S occurs in this
legal C99 code:
(struct S { int x, y; } *)0
llvm-svn: 72555
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
| -rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 59e9555a889..54e70be16ec 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1460,8 +1460,10 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS, TK = Action::TK_Declaration; else TK = Action::TK_Reference; + bool Owned = false; DeclPtrTy TagDecl = Actions.ActOnTag(CurScope, DeclSpec::TST_enum, TK, - StartLoc, SS, Name, NameLoc, Attr, AS); + StartLoc, SS, Name, NameLoc, Attr, AS, + Owned); if (Tok.is(tok::l_brace)) ParseEnumBody(StartLoc, TagDecl); @@ -1469,7 +1471,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS, // TODO: semantic analysis on the declspec for enums. const char *PrevSpec = 0; if (DS.SetTypeSpecType(DeclSpec::TST_enum, StartLoc, PrevSpec, - TagDecl.getAs<void>())) + TagDecl.getAs<void>(), Owned)) Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec; } |

