diff options
author | Steve Naroff <snaroff@apple.com> | 2007-11-17 21:37:36 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-11-17 21:37:36 +0000 |
commit | 9219928c7a036b65d7801a02c4de3a8283ed3124 (patch) | |
tree | 48f199807ffcd4f7dac3a9353b46a49ac2c4f147 | |
parent | 91578f3cdbabdb31ba6c5ea46441c4339d911b62 (diff) |
Now that we are passing back "free standing decls", make sure -ast-dump works like -ast-print.
Also added a cast to be safe...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44209 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | AST/StmtDumper.cpp | 10 | ||||
-rw-r--r-- | Sema/SemaDecl.cpp | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/AST/StmtDumper.cpp b/AST/StmtDumper.cpp index a30b901c1c..c6ab29880d 100644 --- a/AST/StmtDumper.cpp +++ b/AST/StmtDumper.cpp @@ -219,8 +219,16 @@ void StmtDumper::DumpDeclarator(Decl *D) { } } fprintf(F, "\""); + } else if (TagDecl *TD = dyn_cast<TagDecl>(D)) { + // print a free standing tag decl (e.g. "struct x;"). + const char *tagname; + if (const IdentifierInfo *II = TD->getIdentifier()) + tagname = II->getName(); + else + tagname = "<anonymous>"; + fprintf(F, "\"%s %s;\"", TD->getKindName(), tagname); + // FIXME: print tag bodies. } else { - // FIXME: "struct x;" assert(0 && "Unexpected decl"); } } diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index bd6307f36b..2c3b335fb7 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -347,7 +347,7 @@ Sema::DeclTy *Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) { // TODO: emit error on 'typedef int;' // if (!DS.isMissingDeclaratorOk()) Diag(...); - return DS.getTypeRep(); + return dyn_cast_or_null<TagDecl>(static_cast<Decl *>(DS.getTypeRep())); } bool Sema::CheckSingleInitializer(Expr *&Init, bool isStatic, |