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

Michal korgulec at gmail.com
Fri Jan 8 18:29:42 CST 2010

when clang parses such code :

enum X {
 C };

void foo(enum X)
  switch(X) {
    case A:

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?).


More information about the cfe-dev mailing list