aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst17
-rw-r--r--gcc/ada/gnat_ugn.texi27
-rw-r--r--gcc/ada/sem_ch3.adb34
-rw-r--r--gcc/ada/warnsw.adb3
-rw-r--r--gcc/ada/warnsw.ads7
5 files changed, 86 insertions, 2 deletions
diff --git a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
index ce3ed0c..07ca2ea 100644
--- a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
+++ b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
@@ -3430,6 +3430,23 @@ of the pragma in the :title:`GNAT_Reference_manual`).
This switch suppresses listing of inherited aspects.
+.. index:: -gnatw_l (gcc)
+
+:switch:`-gnatw_l`
+ *Activate warnings on inheritely limited types.*
+
+ This switch causes the compiler trigger warnings on record types that do not
+ have a limited keyword but contain a component that is a limited type.
+
+
+.. index:: -gnatw_L (gcc)
+
+:switch:`-gnatw_L`
+ *Suppress warnings on inheritely limited types.*
+
+ This switch suppresses warnings on inheritely limited types.
+
+
.. index:: -gnatwm (gcc)
:switch:`-gnatwm`
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
index 0e3ee93..dcde9ea 100644
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -19,7 +19,7 @@
@copying
@quotation
-GNAT User's Guide for Native Platforms , Jul 29, 2024
+GNAT User's Guide for Native Platforms , Aug 19, 2024
AdaCore
@@ -11671,6 +11671,31 @@ Pre’Class, and Post’Class aspects. Also list inherited subtype predicates.
This switch suppresses listing of inherited aspects.
@end table
+@geindex -gnatw_l (gcc)
+
+
+@table @asis
+
+@item @code{-gnatw_l}
+
+`Activate warnings on inheritely limited types.'
+
+This switch causes the compiler trigger warnings on record types that do not
+have a limited keyword but contain a component that is a limited type.
+@end table
+
+@geindex -gnatw_L (gcc)
+
+
+@table @asis
+
+@item @code{-gnatw_L}
+
+`Suppress warnings on inheritely limited types.'
+
+This switch suppresses warnings on inheritely limited types.
+@end table
+
@geindex -gnatwm (gcc)
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 3b44f0a..4dac4ee 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -741,6 +741,11 @@ package body Sem_Ch3 is
-- Check that an entity in a list of progenitors is an interface,
-- emit error otherwise.
+ procedure Warn_On_Inherently_Limited_Type (E : Entity_Id);
+ -- Emit a warning if a record type that does not have a limited keyword in
+ -- its definition has any components that are limited (which implicitly
+ -- make the type limited).
+
-----------------------
-- Access_Definition --
-----------------------
@@ -22924,6 +22929,8 @@ package body Sem_Ch3 is
Derive_Progenitor_Subprograms (T, T);
end if;
+ Warn_On_Inherently_Limited_Type (T);
+
Check_Function_Writable_Actuals (N);
end Record_Type_Declaration;
@@ -23396,4 +23403,31 @@ package body Sem_Ch3 is
Set_Is_Constrained (T);
end Signed_Integer_Type_Declaration;
+ -------------------------------------
+ -- Warn_On_Inherently_Limited_Type --
+ -------------------------------------
+
+ procedure Warn_On_Inherently_Limited_Type (E : Entity_Id) is
+ C : Entity_Id;
+ begin
+ if Warnsw.Warn_On_Inherently_Limited_Type
+ and then not Is_Limited_Record (E)
+ then
+ C := First_Component (Base_Type (E));
+ while Present (C) loop
+ if Is_Inherently_Limited_Type (Etype (C)) then
+ Error_Msg_Node_2 := E;
+ Error_Msg_NE
+ ("?_l?limited component & makes & limited", E, C);
+ Error_Msg_N
+ ("\\?_l?consider annotating the record type "
+ & "with a LIMITED keyword", E);
+ exit;
+ end if;
+
+ Next_Component (C);
+ end loop;
+ end if;
+ end Warn_On_Inherently_Limited_Type;
+
end Sem_Ch3;
diff --git a/gcc/ada/warnsw.adb b/gcc/ada/warnsw.adb
index ea7e94c..2bfb56e 100644
--- a/gcc/ada/warnsw.adb
+++ b/gcc/ada/warnsw.adb
@@ -92,13 +92,14 @@ package body Warnsw is
'z' => X.Warn_On_Size_Alignment),
'_' =>
- ('b' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'k' | 'l' | 'm' |
+ ('b' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'k' | 'm' |
'n' | 'o' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' =>
No_Such_Warning,
'a' => X.Warn_On_Anonymous_Allocators,
'c' => X.Warn_On_Unknown_Compile_Time_Warning,
'j' => X.Warn_On_Non_Dispatching_Primitives,
+ 'l' => X.Warn_On_Inherently_Limited_Type,
'p' => X.Warn_On_Pedantic_Checks,
'q' => X.Warn_On_Ignored_Equality,
'r' => X.Warn_On_Component_Order,
diff --git a/gcc/ada/warnsw.ads b/gcc/ada/warnsw.ads
index 10ec8a5..0ca0f68 100644
--- a/gcc/ada/warnsw.ads
+++ b/gcc/ada/warnsw.ads
@@ -72,6 +72,7 @@ package Warnsw is
Warn_On_Hiding,
Warn_On_Ignored_Equality,
Warn_On_Ineffective_Predicate_Test,
+ Warn_On_Inherently_Limited_Type,
Warn_On_Late_Primitives,
Warn_On_Modified_Unread,
Warn_On_No_Value_Assigned,
@@ -158,6 +159,7 @@ package Warnsw is
Warn_On_Hiding |
Warn_On_Ignored_Equality |
Warn_On_Ineffective_Predicate_Test |
+ Warn_On_Inherently_Limited_Type |
Warn_On_Late_Primitives |
Warn_On_Modified_Unread |
Warn_On_Non_Dispatching_Primitives |
@@ -342,6 +344,11 @@ package Warnsw is
-- values that do not belong to the parent subtype. Modified by use of
-- -gnatw_s/S.
+ Warn_On_Inherently_Limited_Type : Boolean renames F (X.Warn_On_Inherently_Limited_Type);
+ -- Set to True to generate warnings if a record type does not have a
+ -- limited keyword, but is inherently limited. Modified by use of
+ -- -gnatw_l/L.
+
Warn_On_Late_Primitives : Boolean renames F (X.Warn_On_Late_Primitives);
-- Warn when tagged type public primitives are defined after its private
-- extensions.