public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1269] ada: Fix iteration over component items with pragmas
@ 2023-05-26  7:36 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2023-05-26  7:36 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:16c320507774ca38e0eb3d1c4116c9dcb3f2e598

commit r14-1269-g16c320507774ca38e0eb3d1c4116c9dcb3f2e598
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Tue Mar 21 09:46:57 2023 +0100

    ada: Fix iteration over component items with pragmas
    
    Component items in a record declaration might include pragmas, which
    must be ignored when detecting components with default expressions.
    
    More a code cleanup than a bugfix, as it only affects artificial corner
    cases. Found while fixing missing legality checks for variant component
    declarations.
    
    gcc/ada/
    
            * sem_ch3.adb (Check_CPP_Type_Has_No_Defaults): Iterate with
            First_Non_Pragma and Next_Non_Pragma.
            * exp_dist.adb (Append_Record_Traversal): Likewise.

Diff:
---
 gcc/ada/exp_dist.adb | 4 ++--
 gcc/ada/sem_ch3.adb  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/exp_dist.adb b/gcc/ada/exp_dist.adb
index 8f62bef2c64..f025b5656c6 100644
--- a/gcc/ada/exp_dist.adb
+++ b/gcc/ada/exp_dist.adb
@@ -8304,7 +8304,7 @@ package body Exp_Dist is
             CI := Component_Items (Clist);
             VP := Variant_Part (Clist);
 
-            Item := First (CI);
+            Item := First_Non_Pragma (CI);
             while Present (Item) loop
                Def := Defining_Identifier (Item);
 
@@ -8313,7 +8313,7 @@ package body Exp_Dist is
                     (Stmts, Container, Counter, Rec, Def);
                end if;
 
-               Next (Item);
+               Next_Non_Pragma (Item);
             end loop;
 
             if Present (VP) then
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 9e32dea5c02..fb4f5badd4e 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -12312,7 +12312,7 @@ package body Sem_Ch3 is
       --  Check all components to ensure no default expressions
 
       if Present (Clist) then
-         Comp := First (Component_Items (Clist));
+         Comp := First_Non_Pragma (Component_Items (Clist));
          while Present (Comp) loop
             if Present (Expression (Comp)) then
                Error_Msg_N
@@ -12320,7 +12320,7 @@ package body Sem_Ch3 is
                   & "default expression", Expression (Comp));
             end if;
 
-            Next (Comp);
+            Next_Non_Pragma (Comp);
          end loop;
       end if;
    end Check_CPP_Type_Has_No_Defaults;

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

only message in thread, other threads:[~2023-05-26  7:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-26  7:36 [gcc r14-1269] ada: Fix iteration over component items with pragmas 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).