[cfe-dev] SwitchStmt cond type and EnumConstantDecl type problems

Michal korgulec at gmail.com
Fri Jan 8 16:29:42 PST 2010


Hi,
when clang parses such code :

enum X {
 A,
 B,
 C };

void foo(enum X)
{
  switch(X) {
    case A:
      break;
   }
}

value of switch condition expr and CaseStmt->getLHS->evaluateAsInt()
for each case stmt is ASPInt holding an unsigned value, but type of
EnumConstantDecl->getInitVal() representing A,B,C is ASPInt holding a
signed value.

Is this intentional?

I am trying to implement gcc's -Wswitch warning and this type mismatch
forbids comparisons between case stmts and enum values. I don't know
clang/llvm enough to know how to convert safely between ASPInts (how
should I, if at all?).


Michal.



More information about the cfe-dev mailing list