aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sinput-c.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2017-04-25 17:54:39 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2017-04-25 17:54:39 +0200
commit211e7410b32e6cb4b45d414883c5d6d5f37faa31 (patch)
tree55dae71c0ef21060e28548eed6b71f8e8f1b0965 /gcc/ada/sinput-c.adb
parentf66c70dc0392cfa06f6414a8b9fa65adb9051b58 (diff)
downloadgcc-211e7410b32e6cb4b45d414883c5d6d5f37faa31.zip
gcc-211e7410b32e6cb4b45d414883c5d6d5f37faa31.tar.gz
gcc-211e7410b32e6cb4b45d414883c5d6d5f37faa31.tar.bz2
[multiple changes]
2017-04-25 Arnaud Charlet <charlet@adacore.com> * exp_ch4.adb (Expand_N_Case_Expression): Emit error message when generating C code on complex case expressions. 2017-04-25 Arnaud Charlet <charlet@adacore.com> * sem_prag.adb (Analyze_Pragma): Generate a warning instead of silently ignoring pragma Ada_xxx in Latest_Ada_Only mode. * directio.ads, ioexcept.ads, sequenio.ads, text_io.ads: Use Ada_2012 instead of Ada_2005 to be compatible with the above change. * bindgen.adb: Silence new warning on pragma Ada_95. 2017-04-25 Hristian Kirtchev <kirtchev@adacore.com> * checks.adb (Generate_Range_Check): Revert part of previous change. 2017-04-25 Ed Schonberg <schonberg@adacore.com> * sem_ch4.adb (Try_Container_Indexing): Handle properly a container indexing operation that appears as a an actual in a parameter association in a procedure call. 2017-04-25 Olivier Ramonat <ramonat@adacore.com> * prj-proc.adb, sem_util.adb, s-stposu.adb, sem_attr.adb, prj-conf.ads: Fix spelling mistakes. 2017-04-25 Bob Duff <duff@adacore.com> * types.ads, osint.adb, sinput-c.adb, sinput-d.adb, sinput-l.adb, * sinput-p.adb: Use regular fat pointers, with bounds checking, for source buffers. Fix misc obscure bugs. * sinput.ads, sinput.adb: Use regular fat pointers, with bounds checking, for source buffers. Modify representation clause for Source_File_Record as appropriate. Move Source_File_Index_Table from spec to body, because it is not used outside the body. Move Set_Source_File_Index_Table into the private part, because it is used only in the body and in children. Use trickery to modify the dope in the generic instantiation case. It's ugly, but not as ugly as the previous method. Fix documentation. Remove obsolete code. * fname-sf.adb, targparm.adb: Fix misc out-of-bounds indexing in source buffers. * fmap.adb: Avoid conversions from one string type to another. Remove a use of global name buffer. * osint.ads, sfn_scan.ads, sfn_scan.adb, sinput-c.ads: Comment fixes. From-SVN: r247252
Diffstat (limited to 'gcc/ada/sinput-c.adb')
-rw-r--r--gcc/ada/sinput-c.adb53
1 files changed, 19 insertions, 34 deletions
diff --git a/gcc/ada/sinput-c.adb b/gcc/ada/sinput-c.adb
index 3ef0f5a..fe9285c 100644
--- a/gcc/ada/sinput-c.adb
+++ b/gcc/ada/sinput-c.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -23,7 +23,9 @@
-- --
------------------------------------------------------------------------------
+with Debug; use Debug;
with Opt; use Opt;
+with Output; use Output;
with System; use System;
with Ada.Unchecked_Conversion;
@@ -65,6 +67,14 @@ package body Sinput.C is
Source_File.Increment_Last;
X := Source_File.Last;
+ if Debug_Flag_L then
+ Write_Str ("Sinput.C.Load_File: created source ");
+ Write_Int (Int (X));
+ Write_Str (" for ");
+ Write_Str (Path);
+ Write_Line ("");
+ end if;
+
if X = Source_File.First then
Lo := First_Source_Ptr;
else
@@ -100,50 +110,24 @@ package body Sinput.C is
-- Do the actual read operation
declare
- subtype Actual_Source_Buffer is Source_Buffer (Lo .. Hi);
- -- Physical buffer allocated
-
- type Actual_Source_Ptr is access Actual_Source_Buffer;
- -- This is the pointer type for the physical buffer allocated
-
- Actual_Ptr : constant Actual_Source_Ptr := new Actual_Source_Buffer;
- -- And this is the actual physical buffer
-
- begin
+ Var_Ptr : constant Source_Buffer_Ptr_Var :=
+ new Source_Buffer (Lo .. Hi);
-- Allocate source buffer, allowing extra character at end for EOF
+ begin
-- Some systems have file types that require one read per line,
-- so read until we get the Len bytes or until there are no more
-- characters.
Hi := Lo;
loop
- Actual_Len := Read (Source_File_FD, Actual_Ptr (Hi)'Address, Len);
+ Actual_Len := Read (Source_File_FD, Var_Ptr (Hi)'Address, Len);
Hi := Hi + Source_Ptr (Actual_Len);
exit when Actual_Len = Len or else Actual_Len <= 0;
end loop;
- Actual_Ptr (Hi) := EOF;
-
- -- Now we need to work out the proper virtual origin pointer to
- -- return. This is exactly Actual_Ptr (0)'Address, but we have to
- -- be careful to suppress checks to compute this address.
-
- declare
- pragma Suppress (All_Checks);
-
- pragma Warnings (Off);
- -- The following unchecked conversion is aliased safe, since it
- -- is not used to create improperly aliased pointer values.
-
- function To_Source_Buffer_Ptr is new
- Ada.Unchecked_Conversion (Address, Source_Buffer_Ptr);
-
- pragma Warnings (On);
-
- begin
- Src := To_Source_Buffer_Ptr (Actual_Ptr (0)'Address);
- end;
+ Var_Ptr (Hi) := EOF;
+ Src := Var_Ptr.all'Access;
end;
-- Read is complete, close the file and we are done (no need to test
@@ -199,7 +183,8 @@ package body Sinput.C is
Source_Text => Src,
Template => No_Source_File,
Unit => No_Unit,
- Time_Stamp => Empty_Time_Stamp);
+ Time_Stamp => Empty_Time_Stamp,
+ Index => X);
Alloc_Line_Tables (S, Opt.Table_Factor * Alloc.Lines_Initial);
S.Lines_Table (1) := Lo;