From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [Ada] Fix crash on array component with Default_Value
Date: Mon, 11 Oct 2021 13:39:03 +0000 [thread overview]
Message-ID: <20211011133903.GA1518538@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 496 bytes --]
When complaining about a compile-time constraint error within a default
initialization procedure we assumed that this procedure initializes a
record object. However, it can initialize an array object too.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* exp_util.adb (Inside_Init_Proc): Simplify.
* sem_aggr.adb (Resolve_Record_Aggregate): Fix style.
* sem_util.adb (Compile_Time_Constraint_Error): Guard against
calling Corresponding_Concurrent_Type with an array type entity.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2128 bytes --]
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -7994,10 +7994,8 @@ package body Exp_Util is
----------------------
function Inside_Init_Proc return Boolean is
- Proc : constant Entity_Id := Enclosing_Init_Proc;
-
begin
- return Proc /= Empty;
+ return Present (Enclosing_Init_Proc);
end Inside_Init_Proc;
----------------------
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -5307,8 +5307,8 @@ package body Sem_Aggr is
Add_Association
(Component => Component,
- Expr => Empty,
- Assoc_List => New_Assoc_List,
+ Expr => Empty,
+ Assoc_List => New_Assoc_List,
Is_Box_Present => True);
elsif Present (Parent (Component))
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -6589,11 +6589,16 @@ package body Sem_Util is
if Inside_Init_Proc then
declare
+ Init_Proc_Type : constant Entity_Id :=
+ Entity (Parameter_Type (First
+ (Parameter_Specifications
+ (Parent (Current_Scope_No_Loops)))));
+
Conc_Typ : constant Entity_Id :=
- Corresponding_Concurrent_Type
- (Entity (Parameter_Type (First
- (Parameter_Specifications
- (Parent (Current_Scope))))));
+ (if Present (Init_Proc_Type)
+ and then Init_Proc_Type in E_Record_Type_Id
+ then Corresponding_Concurrent_Type (Init_Proc_Type)
+ else Empty);
begin
-- Don't complain if the corresponding concurrent type
reply other threads:[~2021-10-11 13:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211011133903.GA1518538@adacore.com \
--to=derodat@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=trojanek@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).