aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-expr.h
diff options
context:
space:
mode:
authorYizhe <yizhe@pku.edu.cn>2021-03-17 02:03:30 +0000
committerYizhePKU <yizhe@pku.edu.cn>2021-04-02 17:10:42 +0000
commit0a63f6d619aba46abeafe9c7544756fee00e072d (patch)
tree54202c9419c6f15fa3a07feb01ebad6545c328e3 /gcc/rust/ast/rust-expr.h
parentd4f8f92142340a7e6b931bd5235486c64b7d8e22 (diff)
downloadgcc-0a63f6d619aba46abeafe9c7544756fee00e072d.zip
gcc-0a63f6d619aba46abeafe9c7544756fee00e072d.tar.gz
gcc-0a63f6d619aba46abeafe9c7544756fee00e072d.tar.bz2
Disallow nullptr in ArrayExpr
We'll maintain it as an invariant.
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r--gcc/rust/ast/rust-expr.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 3de14cc..08dc193 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -1109,7 +1109,9 @@ public:
: outer_attrs (std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)),
internal_elements (std::move (array_elems)), locus (locus)
- {}
+ {
+ rust_assert (internal_elements != nullptr);
+ }
// Copy constructor requires cloning ArrayElems for polymorphism to hold
ArrayExpr (ArrayExpr const &other)
@@ -1119,6 +1121,7 @@ public:
{
if (other.has_array_elems ())
internal_elements = other.internal_elements->clone_array_elems ();
+ rust_assert (internal_elements != nullptr);
}
// Overload assignment operator to clone internal_elements
@@ -1135,6 +1138,7 @@ public:
else
internal_elements = nullptr;
+ rust_assert (internal_elements != nullptr);
return *this;
}