aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/trans.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-10-11 08:19:03 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2019-10-11 08:19:03 +0000
commit104099b897fe28c5d28b81a83d7655ea3b91c0c8 (patch)
treeb9d711df9dcd97928a740c08d713f196d23cdb21 /gcc/ada/gcc-interface/trans.c
parent848830dcf75bf887e7ff59a50a0be1463b7a8570 (diff)
downloadgcc-104099b897fe28c5d28b81a83d7655ea3b91c0c8.zip
gcc-104099b897fe28c5d28b81a83d7655ea3b91c0c8.tar.gz
gcc-104099b897fe28c5d28b81a83d7655ea3b91c0c8.tar.bz2
decl.c (gnat_to_gnu_entity): New case to deal with the definition of named numbers.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Named_{Integer|Real}>: New case to deal with the definition of named numbers. <E_Variable>: Minor tweaks. Set DECL_IGNORED_P on the CONST_DECL if a corresponding variable is built. * gcc-interface/trans.c (gnat_to_gnu) <N_Integer_Literal>: Return error_mark_node instead of aborting on overflow for named numbers. <N_Number_Declaration>: Reuse the <N_Object_Declaration> case and deal with error_mark_node specifically. * gcc-interface/utils.c (create_var_decl): Do not set DECL_IGNORED_P on CONST_DECLs. (gnat_write_global_declarations): Output global constants. From-SVN: r276864
Diffstat (limited to 'gcc/ada/gcc-interface/trans.c')
-rw-r--r--gcc/ada/gcc-interface/trans.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 7b842d4..1ee9732 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -6881,11 +6881,17 @@ gnat_to_gnu (Node_Id gnat_node)
gnu_result = UI_To_gnu (Intval (gnat_node), gnu_type);
/* If the result overflows (meaning it doesn't fit in its base type),
- abort. We would like to check that the value is within the range
- of the subtype, but that causes problems with subtypes whose usage
- will raise Constraint_Error and with biased representation, so
- we don't. */
- gcc_assert (!TREE_OVERFLOW (gnu_result));
+ abort, unless this is for a named number because that's not fatal.
+ We would like to check that the value is within the range of the
+ subtype, but that causes problems with subtypes whose usage will
+ raise Constraint_Error and also with biased representation. */
+ if (TREE_OVERFLOW (gnu_result))
+ {
+ if (Nkind (Parent (gnat_node)) == N_Number_Declaration)
+ gnu_result = error_mark_node;
+ else
+ gcc_unreachable ();
+ }
}
break;
@@ -7030,6 +7036,7 @@ gnat_to_gnu (Node_Id gnat_node)
break;
case N_Object_Declaration:
+ case N_Number_Declaration:
case N_Exception_Declaration:
gnat_temp = Defining_Entity (gnat_node);
gnu_result = alloc_stmt_list ();
@@ -7052,8 +7059,15 @@ gnat_to_gnu (Node_Id gnat_node)
gnu_expr = gnat_to_gnu (Expression (gnat_node));
- if (type_annotate_only && TREE_CODE (gnu_expr) == ERROR_MARK)
- gnu_expr = NULL_TREE;
+ if (TREE_CODE (gnu_expr) == ERROR_MARK)
+ {
+ /* If this is a named number for which we cannot manipulate
+ the value, just skip the declaration altogether. */
+ if (kind == N_Number_Declaration)
+ break;
+ else if (type_annotate_only)
+ gnu_expr = NULL_TREE;
+ }
}
else
gnu_expr = NULL_TREE;
@@ -7163,7 +7177,6 @@ gnat_to_gnu (Node_Id gnat_node)
gnu_result = alloc_stmt_list ();
break;
- case N_Number_Declaration:
case N_Package_Renaming_Declaration:
/* These are fully handled in the front end. */
/* ??? For package renamings, find a way to use GENERIC namespaces so