================
@@ -72,3 +72,15 @@ enum E1 comma4(void) {
return ((void)1, 2); // expected-warning {{implicit conversion from 'int' to
enumeration type 'enum E1' is invalid in C++}} \
cxx-error {{cannot initialize return object of type
'enum E1' with an rvalue of type 'int'}}
}
+
+// The branches of a conditional operand are each converted to the context
+// type, so a conditional between enumerators of the target type is fine in
+// C++ and must not be diagnosed here either.
+enum E1 comma5(int c) {
+ return ((void)0, c ? E1_One : E1_Zero);
+}
----------------
flash1729 wrote:
the comma path only runs under `!S.getLangOpts().CPlusPlus`, so this change
doesn't reach C++ at all. The third RUN line already compiles this file as C++
and comma5 passes clean there (comma6 keeps its `cxx-error`), do we still need
a separate test then ?
https://github.com/llvm/llvm-project/pull/220573
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits