aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-04-20 17:52:59 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-04-20 18:02:22 +0100
commit03ec66cf1162f139ba873e5d8237a1dfad989937 (patch)
treebad5e9e33366a3c8979a3aa0e22575724ab645e2 /gcc
parent14dbac9a8bbc7f3cf37679e91ea56e449a64bde7 (diff)
downloadgcc-03ec66cf1162f139ba873e5d8237a1dfad989937.zip
gcc-03ec66cf1162f139ba873e5d8237a1dfad989937.tar.gz
gcc-03ec66cf1162f139ba873e5d8237a1dfad989937.tar.bz2
Remove bad has-minus flag which should be contained within AST::Literal
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-ast-full-test.cc7
-rw-r--r--gcc/rust/ast/rust-pattern.h24
-rw-r--r--gcc/rust/parse/rust-parse-impl.h2
3 files changed, 11 insertions, 22 deletions
diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc
index e6bad4b..5c6a754 100644
--- a/gcc/rust/ast/rust-ast-full-test.cc
+++ b/gcc/rust/ast/rust-ast-full-test.cc
@@ -2819,12 +2819,7 @@ StructPattern::as_string () const
std::string
LiteralPattern::as_string () const
{
- std::string str;
-
- if (has_minus)
- str += "-";
-
- return str + lit.as_string ();
+ return lit.as_string ();
}
std::string
diff --git a/gcc/rust/ast/rust-pattern.h b/gcc/rust/ast/rust-pattern.h
index 5d937d7..62456e8 100644
--- a/gcc/rust/ast/rust-pattern.h
+++ b/gcc/rust/ast/rust-pattern.h
@@ -27,14 +27,6 @@ namespace AST {
class LiteralPattern : public Pattern
{
Literal lit;
- /* make literal have a type given by enum, etc. rustc uses an extended form of
- * its literal token implementation */
- // TODO: literal representation - use LiteralExpr? or another thing?
-
- // Minus prefixed to literal (if integer or floating-point)
- bool has_minus;
- // Actually, this might be a good place to use a template.
-
Location locus;
NodeId node_id;
@@ -42,16 +34,14 @@ public:
std::string as_string () const override;
// Constructor for a literal pattern
- LiteralPattern (Literal lit, Location locus, bool has_minus = false)
- : lit (std::move (lit)), has_minus (has_minus), locus (locus),
+ LiteralPattern (Literal lit, Location locus)
+ : lit (std::move (lit)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
- LiteralPattern (std::string val, Literal::LitType type, Location locus,
- bool has_minus = false)
+ LiteralPattern (std::string val, Literal::LitType type, Location locus)
: lit (Literal (std::move (val), type, PrimitiveCoreType::CORETYPE_STR)),
- has_minus (has_minus), locus (locus),
- node_id (Analysis::Mappings::get ()->get_next_node_id ())
+ locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
Location get_locus () const override final { return locus; }
@@ -62,6 +52,10 @@ public:
NodeId get_pattern_node_id () const override final { return node_id; }
+ Literal &get_literal () { return lit; }
+
+ const Literal &get_literal () const { return lit; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -1110,7 +1104,7 @@ public:
TupleStructPattern (TupleStructPattern &&other) = default;
TupleStructPattern &operator= (TupleStructPattern &&other) = default;
- Location get_locus () const { return path.get_locus (); }
+ Location get_locus () const override { return path.get_locus (); }
void accept_vis (ASTVisitor &vis) override;
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index c95afd6..0198bfa3 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -10400,7 +10400,7 @@ Parser<ManagedTokenSource>::parse_literal_or_range_pattern ()
// literal pattern
return std::unique_ptr<AST::LiteralPattern> (
new AST::LiteralPattern (range_lower->get_str (), type,
- range_lower->get_locus (), has_minus));
+ range_lower->get_locus ()));
}
}