public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-239] [Ada] Check declare and qualified expressions for unset references Date: Tue, 10 May 2022 08:22:02 +0000 (GMT) [thread overview] Message-ID: <20220510082202.D03473836018@sourceware.org> (raw) https://gcc.gnu.org/g:3a978538036cd43d629c7b003c5ee6c8b3bf2c98 commit r13-239-g3a978538036cd43d629c7b003c5ee6c8b3bf2c98 Author: Piotr Trojanek <trojanek@adacore.com> Date: Sat Jan 22 16:32:57 2022 +0100 [Ada] Check declare and qualified expressions for unset references Detection of references to unset (uninitialized) objects requires calls to Check_Unset_Reference on every subexpression of a composite statement and expression. For declare and qualified expressions this was done only when they occurred within another composite statement/expression. gcc/ada/ * sem_res.adb (Resolve_Declare_Expression): Check expression for references to unset objects. (Resolve_Qualified_Expression): Likewise. * sem_warn.adb (Check_Unset_Reference): Remove handling of declare and qualified expressions; clarify comment for type conversions. Diff: --- gcc/ada/sem_res.adb | 2 ++ gcc/ada/sem_warn.adb | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 7d30f150e3d..5a57d62faae 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -7673,6 +7673,7 @@ package body Sem_Res is end if; Resolve (Expr, Typ); + Check_Unset_Reference (Expr); end Resolve_Declare_Expression; ----------------------------------------- @@ -10586,6 +10587,7 @@ package body Sem_Res is begin Resolve (Expr, Target_Typ); + Check_Unset_Reference (Expr); -- A qualified expression requires an exact match of the type, class- -- wide matching is not allowed. However, if the qualifying type is diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index e02f6e04947..8ca5c76a075 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -2244,13 +2244,11 @@ package body Sem_Warn is Check_Unset_Reference (Pref); end; - -- For type conversions, qualifications, or expressions with actions, - -- examine the expression. + -- Type conversions can appear in assignment statements both + -- as variable names and as expressions. We examine their own + -- expressions only when processing their parent node. - when N_Expression_With_Actions - | N_Qualified_Expression - | N_Type_Conversion - => + when N_Type_Conversion => Check_Unset_Reference (Expression (N)); -- For explicit dereference, always check prefix, which will generate
reply other threads:[~2022-05-10 8:22 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=20220510082202.D03473836018@sourceware.org \ --to=pmderodat@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).