===================================================================
@@ -5014,6 +5014,10 @@ build_conditional_expr_1 (location_t loc, tree arg
&& DECL_CONTEXT (orig_arg2) == DECL_CONTEXT (orig_arg3))
/* Two enumerators from the same enumeration can have different
types when the enumeration is still being defined. */;
+ else if (TYPE_ANONYMOUS_P (arg2_type)
+ || TYPE_ANONYMOUS_P (arg3_type))
+ /* Avoid warning for anonymous enums, probably just used as
+ named constants. */;
else if (complain & tf_warning)
warning_at (loc, OPT_Wenum_compare, "enumeral mismatch in "
"conditional expression: %qT vs %qT",
===================================================================
@@ -0,0 +1,10 @@
+// PR c++/60978
+// { dg-options "-Wenum-compare" }
+
+enum { A };
+enum { B };
+
+int foo(int x)
+{
+ return x ? A : B;
+}