S = Ex->IgnoreParenCasts();
switch (S->getStmtClass()) {
+ case Stmt::DeclRefExprClass: {
+ const DeclRefExpr *DR = cast<DeclRefExpr>(S);
+ const EnumConstantDecl *ED = dyn_cast<EnumConstantDecl>(DR->getDecl());
+ return ED ? isConfigurationValue(ED->getInitExpr()) : false;
+ }
case Stmt::IntegerLiteralClass:
return isExpandedFromConfigurationMacro(S);
case Stmt::UnaryExprOrTypeTraitExprClass:
return 2; // no-warning
}
+enum MyEnum {
+ ME_A = CONFIG_CONSTANT,
+ ME_B = 1
+};
+
+int test_MyEnum() {
+ if (!ME_A)
+ return 1; // no-warning
+ if (ME_A)
+ return 2; // no-warning
+ if (ME_B)
+ return 3;
+ // FIXME: we should only need one diagnostic here.
+ if (!ME_B) // expected-warning {{will never be executed}}
+ return 4;// expected-warning {{will never be executed}}
+ return 5;
+}
+