* testsuite/libgomp.fortran/vla7.f90: Add -w to options.
[official-gcc.git] / gcc / ada / i-fortra.adb
blob5b37738fa5b7eb27b99978ab8ff65cca56f7b01e
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- I N T E R F A C E S . F O R T R A N --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 package body Interfaces.Fortran is
36 ------------
37 -- To_Ada --
38 ------------
40 -- Single character case
42 function To_Ada (Item : Character_Set) return Character is
43 begin
44 return Character (Item);
45 end To_Ada;
47 -- String case (function returning converted result)
49 function To_Ada (Item : Fortran_Character) return String is
50 T : String (1 .. Item'Length);
52 begin
53 for J in T'Range loop
54 T (J) := Character (Item (J - 1 + Item'First));
55 end loop;
57 return T;
58 end To_Ada;
60 -- String case (procedure copying converted string to given buffer)
62 procedure To_Ada
63 (Item : Fortran_Character;
64 Target : out String;
65 Last : out Natural)
67 begin
68 if Item'Length = 0 then
69 Last := 0;
70 return;
72 elsif Target'Length = 0 then
73 raise Constraint_Error;
75 else
76 Last := Target'First - 1;
78 for J in Item'Range loop
79 Last := Last + 1;
81 if Last > Target'Last then
82 raise Constraint_Error;
83 else
84 Target (Last) := Character (Item (J));
85 end if;
86 end loop;
87 end if;
88 end To_Ada;
90 ----------------
91 -- To_Fortran --
92 ----------------
94 -- Character case
96 function To_Fortran (Item : Character) return Character_Set is
97 begin
98 return Character_Set (Item);
99 end To_Fortran;
101 -- String case (function returning converted result)
103 function To_Fortran (Item : String) return Fortran_Character is
104 T : Fortran_Character (1 .. Item'Length);
106 begin
107 for J in T'Range loop
108 T (J) := Character_Set (Item (J - 1 + Item'First));
109 end loop;
111 return T;
112 end To_Fortran;
114 -- String case (procedure copying converted string to given buffer)
116 procedure To_Fortran
117 (Item : String;
118 Target : out Fortran_Character;
119 Last : out Natural)
121 begin
122 if Item'Length = 0 then
123 Last := 0;
124 return;
126 elsif Target'Length = 0 then
127 raise Constraint_Error;
129 else
130 Last := Target'First - 1;
132 for J in Item'Range loop
133 Last := Last + 1;
135 if Last > Target'Last then
136 raise Constraint_Error;
137 else
138 Target (Last) := Character_Set (Item (J));
139 end if;
140 end loop;
141 end if;
142 end To_Fortran;
144 end Interfaces.Fortran;