* cvt.c (ocp_convert): Call mark_rvalue_use.
From-SVN: r257155
+2018-01-29 Jason Merrill <jason@redhat.com>
+
+ PR c++/83942 - wrong unused warning with static_cast.
+ * cvt.c (ocp_convert): Call mark_rvalue_use.
+
2018-01-26 Jason Merrill <jason@redhat.com>
PR c++/83956 - wrong dtor error with anonymous union
/* FIXME remove when moving to c_fully_fold model. */
if (!CLASS_TYPE_P (type))
- e = scalar_constant_value (e);
+ {
+ e = mark_rvalue_use (e);
+ e = scalar_constant_value (e);
+ }
if (error_operand_p (e))
return error_mark_node;
--- /dev/null
+// PR c++/83942
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-Wall" }
+
+enum class E { E1 };
+int main() {
+ E const e = E::E1;
+ return static_cast<int>(e);
+}