Change Expr::isIntegerConstantExpr in two ways:
1. Compute and return the value of the i-c-e if the expression is one. 2. Use this computation to correctly track whether subexprs are being evaluated, and use this to guide diagnostics appropriately. This allows us to correctly handle all the cases in: void bar() { int foo(); switch (1) { case 1 ? 0 : foo(): // bad case 0 ? 0 : foo(): // bad case 0 ? 1/0 : 14 : // ok case 1 ? 1/0 : 14 : // bad ; } switch (1) { case 1 ? 2: (2, 3): // ok case 0 ? 2: (2, 3): // invalid comma. ; } } This code has numerous todo items. Specifically, we need to: 1. Pass in target info, so we know the size of the integers we are producing. 2. Model type sizes and alignments correctly, so we can eval sizeof/alignof 3. Handle promotions (need to talk to steve about this). 4. Return an enum that can be used to better diagnose problems with i-c-e's. instead of just saying "this isn't valid" we should be able to say why. 5. Various other miscellanea, like handling enums and character literals properly. llvm-svn: 39585
Loading
Please register or sign in to comment