From: Steve Naroff Date: Sat, 17 Nov 2007 21:21:01 +0000 (+0000) Subject: Make sure Sema::ParsedFreeStandingDeclSpec() returns a decl representing the type. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91578f3cdbabdb31ba6c5ea46441c4339d911b62;p=clang Make sure Sema::ParsedFreeStandingDeclSpec() returns a decl representing the type. Adding basic printing to StmtPrinter::PrintRawDecl(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44208 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/StmtPrinter.cpp b/AST/StmtPrinter.cpp index d96a0486cf..fa3eb84b52 100644 --- a/AST/StmtPrinter.cpp +++ b/AST/StmtPrinter.cpp @@ -133,8 +133,16 @@ void StmtPrinter::PrintRawDecl(Decl *D) { PrintExpr(V->getInit()); } } + } else if (TagDecl *TD = dyn_cast(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 << ""; + // FIXME: print tag bodies. } else { - // FIXME: "struct x;" assert(0 && "Unexpected decl"); } } diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp index e347ccb832..9175a08314 100644 --- a/Driver/ASTConsumers.cpp +++ b/Driver/ASTConsumers.cpp @@ -536,7 +536,7 @@ namespace { } else if (FileVarDecl *FVD = dyn_cast(D)) { CodeGen::CodeGenGlobalVar(Builder, FVD); } else { - assert(isa(D) && "Only expected typedefs here"); + assert(isa(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"; } diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 2c016df781..bd6307f36b 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 0; + return DS.getTypeRep(); } bool Sema::CheckSingleInitializer(Expr *&Init, bool isStatic,