aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/expr.cc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2019-01-15 23:02:43 +0000
committerIain Buclaw <ibuclaw@gcc.gnu.org>2019-01-15 23:02:43 +0000
commit5e95646e734c1c64ea4e1a761b414581534e1d8c (patch)
treee0b659e37a70ed3996d8c7a6fee4ea09e1587cd2 /gcc/d/expr.cc
parent37879e01616f2031866ddbbeff5f30e562e7baac (diff)
downloadgcc-5e95646e734c1c64ea4e1a761b414581534e1d8c.zip
gcc-5e95646e734c1c64ea4e1a761b414581534e1d8c.tar.gz
gcc-5e95646e734c1c64ea4e1a761b414581534e1d8c.tar.bz2
[D] Move building of typeof(null) values to a common function.
gcc/d/ChangeLog: * d-codegen.cc (build_typeof_null_value): New function. * d-tree.h (build_typeof_null_value): Declare. * d-convert.cc (convert_expr): Use build_typeof_null_value. * expr.cc (ExprVisitor::visit(NullExp)): Likewise. From-SVN: r267955
Diffstat (limited to 'gcc/d/expr.cc')
-rw-r--r--gcc/d/expr.cc28
1 files changed, 1 insertions, 27 deletions
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index fecdffd..15754a1 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -2941,33 +2941,7 @@ public:
void visit (NullExp *e)
{
- Type *tb = e->type->toBasetype ();
- tree value;
-
- /* Handle certain special case conversions, where the underlying type is an
- aggregate with a nullable interior pointer. */
- if (tb->ty == Tarray)
- {
- /* For dynamic arrays, set length and pointer fields to zero. */
- value = d_array_value (build_ctype (e->type), size_int (0),
- null_pointer_node);
- }
- else if (tb->ty == Taarray)
- {
- /* For associative arrays, set the pointer field to null. */
- value = build_constructor (build_ctype (e->type), NULL);
- }
- else if (tb->ty == Tdelegate)
- {
- /* For delegates, set the frame and function pointer to null. */
- value = build_delegate_cst (null_pointer_node,
- null_pointer_node, e->type);
- }
- else
- value = d_convert (build_ctype (e->type), integer_zero_node);
-
- TREE_CONSTANT (value) = 1;
- this->result_ = value;
+ this->result_ = build_typeof_null_value (e->type);
}
/* Build a vector literal. */