public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-3028] ada: Spurious error on class-wide preconditions
@ 2023-08-07 11:16 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2023-08-07 11:16 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3ad67df218bf6073f4c783df54cdf0e20fa5e42a

commit r14-3028-g3ad67df218bf6073f4c783df54cdf0e20fa5e42a
Author: Javier Miranda <miranda@adacore.com>
Date:   Thu Jul 27 11:02:20 2023 +0000

    ada: Spurious error on class-wide preconditions
    
    The compiler reports an spurious error when a class-wide precondition
    expression has a class-wide type conversion.
    
    gcc/ada/
    
            * sem_res.adb (Resolve_Type_Conversion): Do not warn on conversion
            to class-wide type on internally build helpers of class-wide
            preconditions.

Diff:
---
 gcc/ada/sem_res.adb | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index d3a0192fb09..ac0c60f5f22 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -12455,6 +12455,18 @@ package body Sem_Res is
             elsif Orig_T = Base_Type (Standard_Long_Long_Integer) then
                null;
 
+            --  Do not warn on conversion to class-wide type on helpers of
+            --  class-wide preconditions because in this context the warning
+            --  would be spurious (since the class-wide precondition has been
+            --  installed in the return statement of the helper, which has a
+            --  class-wide formal type instead of a regular tagged type).
+
+            elsif Is_Class_Wide_Type (Orig_T)
+              and then Is_Subprogram_Or_Generic_Subprogram (Current_Scope)
+              and then Present (Class_Preconditions_Subprogram (Current_Scope))
+            then
+               null;
+
             --  Here we give the redundant conversion warning. If it is an
             --  entity, give the name of the entity in the message. If not,
             --  just mention the expression.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-07 11:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 11:16 [gcc r14-3028] ada: Spurious error on class-wide preconditions Marc Poulhi?s

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).