]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ada/switch.ads
c++: Handle multiple aggregate overloads [PR95319].
[thirdparty/gcc.git] / gcc / ada / switch.ads
CommitLineData
996ae0b0
RK
1------------------------------------------------------------------------------
2-- --
3-- GNAT COMPILER COMPONENTS --
4-- --
5-- S W I T C H --
6-- --
7-- S p e c --
8-- --
1d005acc 9-- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
996ae0b0
RK
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- --
b5c84c3c 13-- ware Foundation; either version 3, or (at your option) any later ver- --
996ae0b0
RK
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 --
b5c84c3c
RD
18-- Public License distributed with GNAT; see file COPYING3. If not, go to --
19-- http://www.gnu.org/licenses for a complete copy of the license. --
996ae0b0
RK
20-- --
21-- GNAT was originally developed by the GNAT team at New York University. --
71ff80dc 22-- Extensive contributions were provided by Ada Core Technologies Inc. --
996ae0b0
RK
23-- --
24------------------------------------------------------------------------------
25
6a1cb33a 26-- This package together with a child package appropriate to the client tool
3354f96d 27-- scans switches. Note that the body of the appropriate Usage package must be
6a1cb33a
BD
28-- coordinated with the switches that are recognized by this package. These
29-- Usage packages also act as the official documentation for the switches
30-- that are recognized. In addition, package Debug documents the otherwise
31-- undocumented debug switches that are also recognized.
996ae0b0 32
41c8951a 33with Gnatvsn;
07fc65c4
GB
34with Types; use Types;
35
6a1cb33a
BD
36------------
37-- Switch --
38------------
39
996ae0b0
RK
40package Switch is
41
41c8951a 42 -- Common switches for GNU tools
996ae0b0 43
41c8951a
VC
44 Version_Switch : constant String := "--version";
45 Help_Switch : constant String := "--help";
996ae0b0
RK
46
47 -----------------
48 -- Subprograms --
49 -----------------
50
6a1cb33a
BD
51 generic
52 with procedure Usage;
53 -- Print tool-specific part of --help message
54 procedure Check_Version_And_Help_G
41c8951a
VC
55 (Tool_Name : String;
56 Initial_Year : String;
41c8951a 57 Version_String : String := Gnatvsn.Gnat_Version_String);
6a1cb33a
BD
58 -- Check if switches --version or --help is used. If one of this switch is
59 -- used, issue the proper messages and end the process.
41c8951a
VC
60
61 procedure Display_Version
62 (Tool_Name : String;
63 Initial_Year : String;
64 Version_String : String := Gnatvsn.Gnat_Version_String);
65 -- Display version of a tool when switch --version is used
66
439b6dfa
AC
67 procedure Display_Usage_Version_And_Help;
68 -- Output the two lines of usage for switches --version and --help
69
996ae0b0 70 function Is_Switch (Switch_Chars : String) return Boolean;
6a1cb33a
BD
71 -- Returns True iff Switch_Chars is at least two characters long, and the
72 -- first character is an hyphen ('-').
996ae0b0
RK
73
74 function Is_Front_End_Switch (Switch_Chars : String) return Boolean;
6a1cb33a
BD
75 -- Returns True iff Switch_Chars represents a front-end switch, i.e. it
76 -- starts with -I, -gnat or -?RTS.
996ae0b0 77
6e00e546
OH
78 function Is_Internal_GCC_Switch (Switch_Chars : String) return Boolean;
79 -- Returns True iff Switch_Chars represents an internal GCC switch to be
80 -- followed by a single argument, such as -dumpbase, --param or -auxbase.
308e6f3a 81 -- Even though passed by the "gcc" driver, these need not be stored in ALI
6e00e546
OH
82 -- files and may safely be ignored by non GCC back-ends.
83
84 function Switch_Last (Switch_Chars : String) return Natural;
85 -- Index in Switch_Chars of the last relevant character for later string
86 -- comparison purposes. This is typically 'Last, minus one if there is a
87 -- terminating ASCII.NUL.
07fc65c4 88
6e00e546 89private
07fc65c4 90 -- This section contains some common routines used by the tool dependent
6e00e546
OH
91 -- child packages (there is one such child package for each tool that uses
92 -- Switches to scan switches - Compiler/gnatbind/gnatmake/.
07fc65c4 93
fbf5a39b 94 Switch_Max_Value : constant := 999_999;
07fc65c4
GB
95 -- Maximum value permitted in switches that take a value
96
f7d7bb51
AC
97 function Nat_Present
98 (Switch_Chars : String;
99 Max : Integer;
100 Ptr : Integer) return Boolean;
101 -- Returns True if an integer is at the current scan location or an equal
102 -- sign. This is used as a guard for calling Scan_Nat. Switch_Chars is the
103 -- string containing the switch, and Ptr points just past the switch
308e6f3a 104 -- character. Max is the maximum allowed value of Ptr.
f7d7bb51 105
07fc65c4
GB
106 procedure Scan_Nat
107 (Switch_Chars : String;
108 Max : Integer;
109 Ptr : in out Integer;
d4deddd7
VC
110 Result : out Nat;
111 Switch : Character);
6a1cb33a
BD
112 -- Scan natural integer parameter for switch. On entry, Ptr points just
113 -- past the switch character, on exit it points past the last digit of the
c27f2f15 114 -- integer value. Max is the maximum allowed value of Ptr, so the scan is
308e6f3a 115 -- restricted to Switch_Chars (Ptr .. Max). It is possible for Ptr to be
f7d7bb51
AC
116 -- one greater than Max on return if the entire string is digits. Scan_Nat
117 -- will skip an optional equal sign if it is present. Nat_Present must be
118 -- True, or an error will be signalled.
07fc65c4
GB
119
120 procedure Scan_Pos
121 (Switch_Chars : String;
122 Max : Integer;
123 Ptr : in out Integer;
d4deddd7
VC
124 Result : out Pos;
125 Switch : Character);
1f163ef7
AC
126 -- Scan positive integer parameter for switch. Identical to Scan_Nat with
127 -- same parameters except that zero is considered out of range.
996ae0b0 128
d4deddd7 129 procedure Bad_Switch (Switch : Character);
61dddae4 130 procedure Bad_Switch (Switch : String);
6e6636ec 131 pragma No_Return (Bad_Switch);
d4deddd7
VC
132 -- Fail with an appropriate message when a switch is not recognized
133
996ae0b0 134end Switch;