Make sure Sema::ParsedFreeStandingDeclSpec() returns a decl representing the type.

Adding basic printing to StmtPrinter::PrintRawDecl().

llvm-svn: 44208
This commit is contained in:
Steve Naroff 2007-11-17 21:21:01 +00:00
parent d4d45c268c
commit c1e6d60b14
3 changed files with 11 additions and 3 deletions

View File

@ -133,8 +133,16 @@ void StmtPrinter::PrintRawDecl(Decl *D) {
PrintExpr(V->getInit());
}
}
} else if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
// print a free standing tag decl (e.g. "struct x;").
OS << TD->getKindName();
OS << " ";
if (const IdentifierInfo *II = TD->getIdentifier())
OS << II->getName();
else
OS << "<anonymous>";
// FIXME: print tag bodies.
} else {
// FIXME: "struct x;"
assert(0 && "Unexpected decl");
}
}

View File

@ -536,7 +536,7 @@ namespace {
} else if (FileVarDecl *FVD = dyn_cast<FileVarDecl>(D)) {
CodeGen::CodeGenGlobalVar(Builder, FVD);
} else {
assert(isa<TypedefDecl>(D) && "Only expected typedefs here");
assert(isa<TypeDecl>(D) && "Only expected type decls here");
// don't codegen for now, eventually pass down for debug info.
//std::cerr << "Read top-level typedef decl: '" << D->getName() << "'\n";
}

View File

@ -347,7 +347,7 @@ Sema::DeclTy *Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
// TODO: emit error on 'typedef int;'
// if (!DS.isMissingDeclaratorOk()) Diag(...);
return 0;
return DS.getTypeRep();
}
bool Sema::CheckSingleInitializer(Expr *&Init, bool isStatic,