From 77f983ae738583dfce7c3c3aaab5efde16519af0 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sun, 21 Feb 2016 07:56:25 +0100 Subject: ortho: add new_default_value to initialize a variable. --- src/ortho/gcc/ortho-lang.c | 7 ++++++- src/ortho/gcc/ortho_gcc.ads | 5 +++++ src/ortho/gcc/ortho_gcc.private.ads | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/ortho/gcc') diff --git a/src/ortho/gcc/ortho-lang.c b/src/ortho/gcc/ortho-lang.c index b4fdbe388..fc86d799f 100644 --- a/src/ortho/gcc/ortho-lang.c +++ b/src/ortho/gcc/ortho-lang.c @@ -1376,7 +1376,6 @@ finish_array_aggr (struct o_array_aggr_list *list, tree *res) *res = build_constructor (list->atype, list->elts); } - tree new_union_aggr (tree atype, tree field, tree value) { @@ -1387,6 +1386,12 @@ new_union_aggr (tree atype, tree field, tree value) return res; } +tree +new_default_value (tree atype) +{ + return build_constructor (atype, NULL); +} + tree new_indexed_element (tree arr, tree index) { diff --git a/src/ortho/gcc/ortho_gcc.ads b/src/ortho/gcc/ortho_gcc.ads index ab7e0e3d0..7332ceb21 100644 --- a/src/ortho/gcc/ortho_gcc.ads +++ b/src/ortho/gcc/ortho_gcc.ads @@ -138,6 +138,10 @@ package Ortho_Gcc is -- Create a null access literal. function New_Null_Access (Ltype : O_Tnode) return O_Cnode; + -- Create a literal with default (null) values. Can only be used to + -- define the initial value of a static decalaration. + function New_Default_Value (Ltype : O_Tnode) return O_Cnode; + -- Build a record/array aggregate. -- The aggregate is constant, and therefore can be only used to initialize -- constant declaration. @@ -634,6 +638,7 @@ private pragma Import (C, New_Array_Aggr_El); pragma Import (C, Finish_Array_Aggr); pragma Import (C, New_Union_Aggr); + pragma Import (C, New_Default_Value); pragma Import (C, New_Indexed_Element); pragma Import (C, New_Slice); diff --git a/src/ortho/gcc/ortho_gcc.private.ads b/src/ortho/gcc/ortho_gcc.private.ads index 615c8aa13..fcbc59129 100644 --- a/src/ortho/gcc/ortho_gcc.private.ads +++ b/src/ortho/gcc/ortho_gcc.private.ads @@ -202,6 +202,7 @@ private pragma Import (C, New_Array_Aggr_El); pragma Import (C, Finish_Array_Aggr); pragma Import (C, New_Union_Aggr); + pragma Import (C, New_Default_Value); pragma Import (C, New_Indexed_Element); pragma Import (C, New_Slice); -- cgit v1.2.3