C99 6.7.2.2-1 syntax says the grammar is: enumerator: enumeration-constant enumeration-constant = constant-expression And C99 6.6 says: constant-expression: conditional-expression This works --- enum constant_expression { ce_first, ce_second = ce_first == 0 ? 1 : 0, }; --- And yet, this fails: --- enum constant_expression { ce_first, ce_second = (ce_first == 0) ? 1 : 0, }; --- With the message: --- Error: found `==` when expecting `)` Error: found `)` when expecting `}` Error: `=`, `;` or `,` expected
Likewise, this fails to compile: --- enum constant_expression { ce_first, ce_second = (int) ((1UL << (ce_first)) << 24), };
This is the full example from `wctype.h`. --- enum { __ISwupper = 0, _ISwupper = ((__ISwupper) < 8 ? (int) ((1UL << (__ISwupper)) << 24) : ((__ISwupper) < 16 ? (int) ((1UL << (__ISwupper)) << 8) : ((__ISwupper) < 24 ? (int) ((1UL << (__ISwupper)) >> 8) : (int) ((1UL << (__ISwupper)) >> 24)))), }; ---
@WalterBright updated dlang/dmd pull request #12627 "fix Issue 21976 - importC: does not distinguish between cast-expression and unary-expression correctly" fixing this issue: - fix Issue 21976 ImportC: does not distinguish between cast-expression and unary-expression correctly https://github.com/dlang/dmd/pull/12627
dlang/dmd pull request #12627 "fix Issue 21976 - importC: does not distinguish between cast-expression and unary-expression correctly" was merged into master: - 36d2635f2212cba91c737a87710602e800f25e5e by Walter Bright: fix Issue 21976 ImportC: does not distinguish between cast-expression and unary-expression correctly https://github.com/dlang/dmd/pull/12627