aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/types.ads
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2024-04-01 14:05:14 -0400
committerMarc Poulhiès <poulhies@adacore.com>2024-05-20 09:47:06 +0200
commitb3cfe6e88ffcc636d83e4ac5708065c3131e1766 (patch)
tree5fc61bea87459d131e3e49dc2a2ce84d1aa015b1 /gcc/ada/types.ads
parent49eb34ea61c6e8fbb10d3a36484cbf5468580fba (diff)
downloadgcc-b3cfe6e88ffcc636d83e4ac5708065c3131e1766.zip
gcc-b3cfe6e88ffcc636d83e4ac5708065c3131e1766.tar.gz
gcc-b3cfe6e88ffcc636d83e4ac5708065c3131e1766.tar.bz2
ada: Allow 'others' in formal packages with overloaded formals
If a generic package has two or more generic formal parameters with the same defining name (which can happen only for formal subprograms), then RM-12.7(4.1/3) disallows named associations in a corresponding formal package. This is not intended to cover "others => <>". This patch allows "others => <>" even when it applies to such formals. Previously, the compiler incorrectly gave an error. Minor related cleanups involving type Text_Ptr. gcc/ada/ * sem_ch12.adb: Misc cleanups and comment fixes. (Check_Overloaded_Formal_Subprogram): Remove the Others_Choice error message. (Others_Choice): Remove this variable; no longer needed. * types.ads (Text_Ptr): Add a range constraint limiting the subtype to values that are actually used. This has the advantage that when the compiler is compiled with validity checks, uninitialized values of subtypes Text_Ptr and Source_Ptr will be caught. * sinput.ads (Sloc_Adjust): Use the base subtype; this is used as an offset, so we need to allow arbitrary negative values.
Diffstat (limited to 'gcc/ada/types.ads')
-rw-r--r--gcc/ada/types.ads7
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/ada/types.ads b/gcc/ada/types.ads
index 8a1d905..4fd75d4 100644
--- a/gcc/ada/types.ads
+++ b/gcc/ada/types.ads
@@ -145,9 +145,8 @@ package Types is
-- standard 32-bit integer as an index value, since we count on all index
-- values being the same size.
- type Text_Ptr is new Int;
- -- Type used for subscripts in text buffer
-
+ type Text_Ptr is new Int range -4 .. Int'Last;
+ -- -4 .. -1 are special; see constants below
type Text_Buffer is array (Text_Ptr range <>) of Character;
-- Text buffer used to hold source file or library information file
@@ -265,7 +264,7 @@ package Types is
-- the location is in System, but we don't know exactly what line.
First_Source_Ptr : constant Source_Ptr := 0;
- -- Starting source pointer index value for first source program
+ -- Starting source pointer index value for first source file
-------------------------------------
-- Range Definitions for Tree Data --