gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc: Evaluate the enum's discriminant in a const context
gcc/testsuite/ChangeLog:
* rust/compile/enum_discriminant1.rs: New test.
Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
// make the ctor for the union
HIR::Expr &discrim_expr = variant->get_discriminant ();
+ ctx->push_const_context ();
tree discrim_expr_node = CompileExpr::Compile (discrim_expr, ctx);
+ ctx->pop_const_context ();
tree folded_discrim_expr = fold_expr (discrim_expr_node);
tree qualifier = folded_discrim_expr;
--- /dev/null
+enum Foo {
+ Bar = 3 + 12,
+}
+
+fn test() -> Foo { // { dg-warning "function is never used" }
+ return Foo::Bar;
+}
\ No newline at end of file