diff options
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 163 |
2 files changed, 85 insertions, 84 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 41af09a..2851ff1 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,11 @@ 2015-05-25 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: Move around. + <E_Exception>: Merge with E_Variable case. + <E_Variable>: Remove 'object' label. + +2015-05-25 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/decl.c (gnat_to_gnu_entity): Minor tweak. * gcc-interface/trans.c (finalize_nrv_unc_r): Use CONSTRUCTOR_ELT. * gcc-interface/utils.c (convert): Likewise and simplify. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 501b076..e8cacb4 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -448,87 +448,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) switch (kind) { - case E_Constant: - /* If this is a use of a deferred constant without address clause, - get its full definition. */ - if (!definition - && No (Address_Clause (gnat_entity)) - && Present (Full_View (gnat_entity))) - { - gnu_decl - = gnat_to_gnu_entity (Full_View (gnat_entity), gnu_expr, 0); - saved = true; - break; - } - - /* If we have an external constant that we are not defining, get the - expression that is was defined to represent. We may throw it away - later if it is not a constant. But do not retrieve the expression - if it is an allocator because the designated type might be dummy - at this point. */ - if (!definition - && !No_Initialization (Declaration_Node (gnat_entity)) - && Present (Expression (Declaration_Node (gnat_entity))) - && Nkind (Expression (Declaration_Node (gnat_entity))) - != N_Allocator) - { - bool went_into_elab_proc = false; - int save_force_global = force_global; - - /* The expression may contain N_Expression_With_Actions nodes and - thus object declarations from other units. In this case, even - though the expression will eventually be discarded since not a - constant, the declarations would be stuck either in the global - varpool or in the current scope. Therefore we force the local - context and create a fake scope that we'll zap at the end. */ - if (!current_function_decl) - { - current_function_decl = get_elaboration_procedure (); - went_into_elab_proc = true; - } - force_global = 0; - gnat_pushlevel (); - - gnu_expr = gnat_to_gnu (Expression (Declaration_Node (gnat_entity))); - - gnat_zaplevel (); - force_global = save_force_global; - if (went_into_elab_proc) - current_function_decl = NULL_TREE; - } - - /* Ignore deferred constant definitions without address clause since - they are processed fully in the front-end. If No_Initialization - is set, this is not a deferred constant but a constant whose value - is built manually. And constants that are renamings are handled - like variables. */ - if (definition - && !gnu_expr - && No (Address_Clause (gnat_entity)) - && !No_Initialization (Declaration_Node (gnat_entity)) - && No (Renamed_Object (gnat_entity))) - { - gnu_decl = error_mark_node; - saved = true; - break; - } - - /* Ignore constant definitions already marked with the error node. See - the N_Object_Declaration case of gnat_to_gnu for the rationale. */ - if (definition - && gnu_expr - && present_gnu_tree (gnat_entity) - && get_gnu_tree (gnat_entity) == error_mark_node) - { - maybe_present = true; - break; - } - - goto object; - - case E_Exception: - goto object; - case E_Component: case E_Discriminant: { @@ -596,12 +515,88 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) gcc_unreachable (); } + case E_Constant: + /* Ignore constant definitions already marked with the error node. See + the N_Object_Declaration case of gnat_to_gnu for the rationale. */ + if (definition + && gnu_expr + && present_gnu_tree (gnat_entity) + && get_gnu_tree (gnat_entity) == error_mark_node) + { + maybe_present = true; + break; + } + + /* Ignore deferred constant definitions without address clause since + they are processed fully in the front-end. If No_Initialization + is set, this is not a deferred constant but a constant whose value + is built manually. And constants that are renamings are handled + like variables. */ + if (definition + && !gnu_expr + && No (Address_Clause (gnat_entity)) + && !No_Initialization (Declaration_Node (gnat_entity)) + && No (Renamed_Object (gnat_entity))) + { + gnu_decl = error_mark_node; + saved = true; + break; + } + + /* If this is a use of a deferred constant without address clause, + get its full definition. */ + if (!definition + && No (Address_Clause (gnat_entity)) + && Present (Full_View (gnat_entity))) + { + gnu_decl + = gnat_to_gnu_entity (Full_View (gnat_entity), gnu_expr, 0); + saved = true; + break; + } + + /* If we have an external constant that we are not defining, get the + expression that is was defined to represent. We may throw it away + later if it is not a constant. But do not retrieve the expression + if it is an allocator because the designated type might be dummy + at this point. */ + if (!definition + && !No_Initialization (Declaration_Node (gnat_entity)) + && Present (Expression (Declaration_Node (gnat_entity))) + && Nkind (Expression (Declaration_Node (gnat_entity))) + != N_Allocator) + { + bool went_into_elab_proc = false; + int save_force_global = force_global; + + /* The expression may contain N_Expression_With_Actions nodes and + thus object declarations from other units. In this case, even + though the expression will eventually be discarded since not a + constant, the declarations would be stuck either in the global + varpool or in the current scope. Therefore we force the local + context and create a fake scope that we'll zap at the end. */ + if (!current_function_decl) + { + current_function_decl = get_elaboration_procedure (); + went_into_elab_proc = true; + } + force_global = 0; + gnat_pushlevel (); + + gnu_expr = gnat_to_gnu (Expression (Declaration_Node (gnat_entity))); + + gnat_zaplevel (); + force_global = save_force_global; + if (went_into_elab_proc) + current_function_decl = NULL_TREE; + } + + /* ... fall through ... */ + + case E_Exception: case E_Loop_Parameter: case E_Out_Parameter: case E_Variable: - - /* Simple variables, loop variables, Out parameters and exceptions. */ - object: { /* Always create a variable for volatile objects and variables seen constant but with a Linker_Section pragma. */ |