[cfe-dev] wrong printing of typedefs?

Maximilian Odendahl maxodendahl at gmail.com
Wed Jun 9 13:00:33 PDT 2010


Hi,

I have such a typedef in my source file:


typedef struct { int var1; int var2; } type1;


Using this code:

DeclContext *DC = TranslationUnitDecl::castToDeclContext(D);
DeclContext::decl_iterator it = DC->decls_begin(), end = DC->decls_end();
   while (it != end) {
     switch (it->getKind()) {
       case Decl::Typedef:
         if (it->getLocation().isValid() && 
s.getSourceManager().isFromMainFile(it->getLocation())) {
           it->print (OutFile);

I would have expected to get the same thing back, but I actually get

struct {
     int var1;
     int var2;
};
typedef type1 type1;

which does not compile of course. Using dump returns the same issue.

Is this a bug in clang somewhere?

Thanks for any help,
Max





More information about the cfe-dev mailing list