This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] Fix ICE on constant declared as weak
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 23 Nov 2009 19:58:03 +0100
- Subject: [Ada] Fix ICE on constant declared as weak
The ICE occurs when gigi asks the middle-end to declare a CONST_DECL as weak.
Fixed by making it declare the corresponding VAR_DECL as weak instead.
Tested on i586-suse-linux, applied on the mainline.
2009-11-23 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Pass the list
of attributes when building the corresponding variable of a constant.
* gcc-interface/utils.c (create_var_decl_1): Do not process attributes
for constants.
2009-11-23 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/specs/weak1.ads: New test.
--
Eric Botcazou
Index: gcc-interface/utils.c
===================================================================
--- gcc-interface/utils.c (revision 154431)
+++ gcc-interface/utils.c (working copy)
@@ -1404,10 +1404,12 @@ create_var_decl_1 (tree var_name, tree a
!= null_pointer_node)
DECL_IGNORED_P (var_decl) = 1;
- if (asm_name && VAR_OR_FUNCTION_DECL_P (var_decl))
- SET_DECL_ASSEMBLER_NAME (var_decl, asm_name);
-
- process_attributes (var_decl, attr_list);
+ if (TREE_CODE (var_decl) == VAR_DECL)
+ {
+ if (asm_name)
+ SET_DECL_ASSEMBLER_NAME (var_decl, asm_name);
+ process_attributes (var_decl, attr_list);
+ }
/* Add this decl to the current binding level. */
gnat_pushdecl (var_decl, gnat_node);
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c (revision 154431)
+++ gcc-interface/decl.c (working copy)
@@ -1366,7 +1366,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
tree gnu_corr_var
= create_true_var_decl (gnu_entity_name, gnu_ext_name, gnu_type,
gnu_expr, true, Is_Public (gnat_entity),
- !definition, static_p, NULL,
+ !definition, static_p, attr_list,
gnat_entity);
SET_DECL_CONST_CORRESPONDING_VAR (gnu_decl, gnu_corr_var);
package Weak1 is
Myconst : constant Integer := 1234;
pragma Export (C, Myconst, "myconst");
pragma Weak_External (Myconst);
end Weak1;