From 7a08b9393c7b36c4dca8fca9a5cda261594f61d6 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Fri, 21 Oct 2022 11:09:49 -0400 Subject: ada: Move warnings switches -- initial work This patch prepares to move warning switches from Opt into Warnsw. gcc/ada/ * warnsw.ads, warnsw.adb, fe.h, err_vars.ads, errout.ads: Move Warning_Doc_Switch from Err_Vars to Warnsw. Access Warn_On_Questionable_Layout on the C side via a function rather than a variable, because we plan to turn the variables into renamings, and you can't Export renamings. * erroutc.adb, switch-c.adb, errout.adb: Likewise. * gcc-interface/decl.cc: Use Get_Warn_On_Questionable_Layout instead of Warn_On_Questionable_Layout. * gcc-interface/Makefile.in (GNATMAKE_OBJS): Add warnsw.o, because it is indirectly imported via Errout. * gcc-interface/Make-lang.in (GNATBIND_OBJS): Likewise and remove restrict.o (not needed). --- gcc/ada/gcc-interface/Make-lang.in | 2 +- gcc/ada/gcc-interface/Makefile.in | 2 +- gcc/ada/gcc-interface/decl.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index 02b2d1c6f2a..45a4168e890 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -601,7 +601,6 @@ GNATBIND_OBJS = \ ada/osint-b.o \ ada/osint.o \ ada/output.o \ - ada/restrict.o \ ada/rident.o \ ada/scans.o \ ada/scil_ll.o \ @@ -629,6 +628,7 @@ GNATBIND_OBJS = \ ada/uintp.o \ ada/uname.o \ ada/urealp.o \ + ada/warnsw.o \ ada/widechar.o \ ada/gnat.o \ ada/g-dynhta.o \ diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index 6b19b8be58e..5137ebaa0c6 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -333,7 +333,7 @@ GNATMAKE_OBJS = a-except.o ali.o ali-util.o aspects.o s-casuti.o alloc.o \ s-purexc.o s-htable.o scil_ll.o sem_aux.o sinfo.o sinput.o sinput-c.o \ snames.o stand.o stringt.o styleg.o stylesw.o system.o validsw.o \ switch.o switch-m.o table.o targparm.o tempdir.o types.o uintp.o \ - uname.o urealp.o usage.o widechar.o \ + uname.o urealp.o usage.o widechar.o warnsw.o \ seinfo.o einfo-entities.o einfo-utils.o sinfo-nodes.o sinfo-utils.o \ $(EXTRA_GNATMAKE_OBJS) diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index f8c76982de5..e25ce498f2c 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -8363,7 +8363,7 @@ components_to_record (Node_Id gnat_component_list, Entity_Id gnat_record_type, && !Debug_Flag_Dot_R); const bool w_reorder = (Convention (gnat_record_type) == Convention_Ada - && Warn_On_Questionable_Layout + && Get_Warn_On_Questionable_Layout () && !(No_Reordering (gnat_record_type) && GNAT_Mode)); tree gnu_zero_list = NULL_TREE; tree gnu_self_list = NULL_TREE; -- cgit v1.2.1 From b2278f6b146595b3f80a072145a78877041cb8bc Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Tue, 18 Oct 2022 11:32:02 +0200 Subject: ada: Fix oversight in implementation of allocators for storage models When the allocator is of an unconstrained array type and has an initializing expression, the copy of the initializing expression must be done separately from that of the bounds. gcc/ada/ * gcc-interface/utils2.cc (build_allocator): For unconstrained array types with a storage model and an initializing expression, copy the initialization expression separately from the bounds. In all cases with a storage model, pass the locally computed size for the store. --- gcc/ada/gcc-interface/utils2.cc | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc index ef81f8dd56a..80d550c91e1 100644 --- a/gcc/ada/gcc-interface/utils2.cc +++ b/gcc/ada/gcc-interface/utils2.cc @@ -2439,8 +2439,8 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, tree storage_ptr_type = build_pointer_type (storage_type); tree lhs, rhs; - size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_SIZE_UNIT (storage_type), - init); + size = TYPE_SIZE_UNIT (storage_type); + size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, init); /* If the size overflows, pass -1 so Storage_Error will be raised. */ if (TREE_CODE (size) == INTEGER_CST && !valid_constant_size_p (size)) @@ -2454,8 +2454,10 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, /* If there is an initializing expression, then make a constructor for the entire object including the bounds and copy it into the object. - If there is no initializing expression, just set the bounds. */ - if (init) + If there is no initializing expression, just set the bounds. Note + that, if we have a storage model, we need to copy the initializing + expression separately from the bounds. */ + if (init && !pool_is_storage_model) { vec *v; vec_alloc (v, 2); @@ -2472,11 +2474,28 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, { lhs = build_component_ref (storage_deref, TYPE_FIELDS (storage_type), false); - rhs = build_template (template_type, type, NULL_TREE); + rhs = build_template (template_type, type, init); } if (pool_is_storage_model) - storage_init = build_storage_model_store (gnat_pool, lhs, rhs); + { + storage_init = build_storage_model_store (gnat_pool, lhs, rhs); + if (init) + { + start_stmt_group (); + add_stmt (storage_init); + lhs + = build_component_ref (storage_deref, + DECL_CHAIN (TYPE_FIELDS (storage_type)), + false); + rhs = init; + size = TYPE_SIZE_UNIT (TREE_TYPE (lhs)); + size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, init); + tree t = build_storage_model_store (gnat_pool, lhs, rhs, size); + add_stmt (t); + storage_init = end_stmt_group (); + } + } else storage_init = build_binary_op (INIT_EXPR, NULL_TREE, lhs, rhs); @@ -2520,7 +2539,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, TREE_THIS_NOTRAP (storage_deref) = 1; if (pool_is_storage_model) storage_init - = build_storage_model_store (gnat_pool, storage_deref, init); + = build_storage_model_store (gnat_pool, storage_deref, init, size); else storage_init = build_binary_op (INIT_EXPR, NULL_TREE, storage_deref, init); -- cgit v1.2.1