From 6d0892636e9642e75a858c40c45acd1df79c63e1 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Thu, 6 Jan 2022 14:45:15 +0000 Subject: Add support for wildcard patterns within MatchExprs GCC CASE_LABEL_EXPR's contain operand 0 and 1, operand 0 is used for the low value of a case label and operand 1 for a high value. So with this CASE_LABEL_EXPR is is possible to support a range of values from low->high if set apropriately, but for the wildcard case this is effectively a default case which means we set both operand 0 and 1 to NULL_TREE. Fixes #853 --- gcc/rust/backend/rust-compile-pattern.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/rust/backend/rust-compile-pattern.cc') diff --git a/gcc/rust/backend/rust-compile-pattern.cc b/gcc/rust/backend/rust-compile-pattern.cc index e634dbd..27ee487 100644 --- a/gcc/rust/backend/rust-compile-pattern.cc +++ b/gcc/rust/backend/rust-compile-pattern.cc @@ -77,6 +77,15 @@ CompilePatternCaseLabelExpr::visit (HIR::TupleStructPattern &pattern) CompilePatternCaseLabelExpr::visit (pattern.get_path ()); } +void +CompilePatternCaseLabelExpr::visit (HIR::WildcardPattern &pattern) +{ + // operand 0 being NULL_TREE signifies this is the default case label see: + // tree.def for documentation for CASE_LABEL_EXPR + case_label_expr + = build_case_label (NULL_TREE, NULL_TREE, associated_case_label); +} + // setup the bindings void -- cgit v1.1