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-1529] [Ada] Spurious non-callable warning on prefixed call in class condition Date: Wed, 6 Jul 2022 13:31:07 +0000 (GMT) [thread overview] Message-ID: <20220706133107.B7197385801C@sourceware.org> (raw) https://gcc.gnu.org/g:0d7fbcf10f0d2b375a29fc6c184142f68c7f7da7 commit r13-1529-g0d7fbcf10f0d2b375a29fc6c184142f68c7f7da7 Author: Justin Squirek <squirek@adacore.com> Date: Wed Jun 15 01:14:31 2022 +0000 [Ada] Spurious non-callable warning on prefixed call in class condition This patch corrects an error in the compiler whereby a function call in prefix notation within a class condition causes a spurious error claiming the name in the call is a non-callable entity when there exists a type extension in the same unit extended with a component featuring the same name as the function in question. gcc/ada/ * sem_ch4.adb (Analyze_Selected_Component): Add condition to avoid interpreting derived type components as candidates for selected components in preanalysis of inherited class conditions. Diff: --- gcc/ada/sem_ch4.adb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 4bc3696f673..54974832c39 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -5158,11 +5158,26 @@ package body Sem_Ch4 is elsif Is_Record_Type (Prefix_Type) then - -- Find component with given name. In an instance, if the node is - -- known as a prefixed call, do not examine components whose - -- visibility may be accidental. + -- Find a component with the given name. If the node is a prefixed + -- call, do not examine components whose visibility may be + -- accidental. - while Present (Comp) and then not Is_Prefixed_Call (N) loop + while Present (Comp) + and then not Is_Prefixed_Call (N) + + -- When the selector has been resolved to a function then we may be + -- looking at a prefixed call which has been preanalyzed already as + -- part of a class condition. In such cases it is possible for a + -- derived type to declare a component which has the same name as + -- a primitive used in a parent's class condition. + + -- Avoid seeing components as possible interpretations of the + -- selected component when this is true. + + and then not (Inside_Class_Condition_Preanalysis + and then Present (Entity (Sel)) + and then Ekind (Entity (Sel)) = E_Function) + loop if Chars (Comp) = Chars (Sel) and then Is_Visible_Component (Comp, N) then
reply other threads:[~2022-07-06 13:31 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=20220706133107.B7197385801C@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).