summaryrefslogtreecommitdiff
path: root/gcc/ada/s-vallli.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-06 10:01:05 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-06 10:01:05 +0000
commit9a4463ea5a30547f306f9df07da2885d6c606161 (patch)
tree6f7793841c4e1fcde4c33c02fe46029e82f1af2e /gcc/ada/s-vallli.adb
parentfed75ba593e302369f6a01c35be1186a9731c323 (diff)
downloadgcc-9a4463ea5a30547f306f9df07da2885d6c606161.tar.gz
2015-01-06 Robert Dewar <dewar@adacore.com>
* snames.ads-tmpl: Remove entries for attribute Enum_Image. * exp_attr.adb: Remove reference to Attribute_Enum_Image. 2015-01-06 Robert Dewar <dewar@adacore.com> * s-vallli.adb (Value_Long_Long_Integer): Handle case of Str'Last = Positive'Last. * s-valllu.adb (Value_Long_Long_Unsigned): Handle case of Str'Last = Positive'Last. 2015-01-06 Robert Dewar <dewar@adacore.com> * sem_prag.adb (Process_Inline): Remove redundant construct warning (-gnatw.r) for an ineffective pragma Inline. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219244 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-vallli.adb')
-rw-r--r--gcc/ada/s-vallli.adb28
1 files changed, 23 insertions, 5 deletions
diff --git a/gcc/ada/s-vallli.adb b/gcc/ada/s-vallli.adb
index 203e475b3cf..bf0e15d1234 100644
--- a/gcc/ada/s-vallli.adb
+++ b/gcc/ada/s-vallli.adb
@@ -91,12 +91,30 @@ package body System.Val_LLI is
-----------------------------
function Value_Long_Long_Integer (Str : String) return Long_Long_Integer is
- V : Long_Long_Integer;
- P : aliased Integer := Str'First;
begin
- V := Scan_Long_Long_Integer (Str, P'Access, Str'Last);
- Scan_Trailing_Blanks (Str, P);
- return V;
+ -- We have to special case Str'Last = Positive'Last because the normal
+ -- circuit ends up setting P to Str'Last + 1 which is out of bounds. We
+ -- deal with this by converting to a subtype which fixes the bounds.
+
+ if Str'Last = Positive'Last then
+ declare
+ subtype NT is String (1 .. Str'Length);
+ begin
+ return Value_Long_Long_Integer (NT (Str));
+ end;
+
+ -- Normal case where Str'Last < Positive'Last
+
+ else
+ declare
+ V : Long_Long_Integer;
+ P : aliased Integer := Str'First;
+ begin
+ V := Scan_Long_Long_Integer (Str, P'Access, Str'Last);
+ Scan_Trailing_Blanks (Str, P);
+ return V;
+ end;
+ end if;
end Value_Long_Long_Integer;
end System.Val_LLI;