<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi,</div><div><br></div><div>It is indeed only reachable if I try to print a literal. The following code within a ASTConsumer class triggers the error</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span style="color: #931a68">bool</span> TestAstConsumer::HandleTopLevelDecl(clang::<span style="color: #006141">DeclGroupRef</span> D)</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">{</div></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><div style="margin: 0px; ">clang::QualType type = _context->UnsignedCharTy;</div><div style="margin: 0px; ">clang::VarDecl* vd = clang::VarDecl::Create(*_context,</div><div style="margin: 0px; "> _context->getTranslationUnitDecl(),</div><div style="margin: 0px; "> clang::SourceLocation(),</div><div style="margin: 0px; "> clang::SourceLocation(),</div><div style="margin: 0px; "> &_context->Idents.get("<span style="text-decoration: underline; ">var</span>"),</div><div style="margin: 0px; "> type,</div><div style="margin: 0px; "> 0,</div><div style="margin: 0px; "> clang::SC_None);</div><div style="margin: 0px; ">llvm::APInt* val = new llvm::APInt(_context->getIntWidth(type), 10);</div><div style="margin: 0px; ">clang::Expr* init = clang::IntegerLiteral::Create(*_context,</div><div style="margin: 0px; "> *val,</div><div style="margin: 0px; "> type,</div><div style="margin: 0px; "> clang::SourceLocation());</div><div style="margin: 0px; ">vd->setInit(init);</div><div style="margin: 0px; ">clang::DeclGroupRef *dgr = new (_context) clang::DeclGroupRef(vd);</div><div style="margin: 0px; ">clang::DeclStmt *dst = new (_context) clang::DeclStmt(*dgr, clang::SourceLocation(), clang::SourceLocation());</div><div style="margin: 0px; ">dst->printPretty(llvm::outs(), 0, _context->getPrintingPolicy());</div></div></div><div>}</div><div><br></div><div>and this is the error message I get</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">unsigned char var = 10Unexpected type for integer literal!</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">UNREACHABLE executed at <path_to_llvm_source>/llvm/tools/clang/lib/AST/StmtPrinter.cpp:730!</div></div><div><br></div><div>Cheers,</div><div>Andrey Tarasevich</div><br><div><div>On Jun 8, 2013, at 12:32 AM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">On Fri, Jun 7, 2013 at 6:39 AM, Andrey Tarasevich<br><<a href="mailto:tarasevich.andrey@gmail.com">tarasevich.andrey@gmail.com</a>> wrote:<br><blockquote type="cite">Hello,<br><br>When I'm trying to pretty print statement with type signed or unsigned char I'm getting an error from the StmtPrinter - "Unexpected type for integer literal!". Is this a bug? If yes, then following small patch fixes it. At least in my case it works just fine and statements are printed correctly.<br></blockquote><br>Please provide a test case. This should only be reachable if you try<br>to print a *literal* with type SChar or UChar. How are you building<br>such a literal?<br><br><blockquote type="cite">Cheers,<br>Andrey Tarasevich<br><br>--- StmtPrinter.cpp 2013-06-07 15:17:31.000000000 +0200<br>+++ StmtPrinter.cpp 2013-06-07 15:24:43.000000000 +0200<br>@@ -731,6 +731,8 @@<br> // FIXME: The Short and UShort cases are to handle cases where a short<br> // integeral literal is formed during template instantiation. They should<br> // be removed when template instantiation no longer needs integer literals.<br>+ case BuiltinType::UChar:<br>+ case BuiltinType::SChar:<br> case BuiltinType::Short:<br> case BuiltinType::UShort:<br> case BuiltinType::Int: break; // no suffix.<br>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br></blockquote></blockquote></div><br></body></html>