+2013-04-11 Robert Dewar <dewar@adacore.com>
+
+ * sem_prag.adb, prj-env.adb: Minor reformatting.
+
+2013-04-11 Ben Brosgol <brosgol@adacore.com>
+
+ * gnat_ugn.texi: Clean ups.
+
+2013-04-11 Yannick Moy <moy@adacore.com>
+
+ * set_targ.adb: Minor comment update.
+
2013-04-11 Pascal Obry <obry@adacore.com>
* gnat_ugn.texi: Remove obsolete comment about DLL calling
* About This Guide::
* Getting Started with GNAT::
* The GNAT Compilation Model::
-* Compiling Using gcc::
-* Binding Using gnatbind::
-* Linking Using gnatlink::
+* Compiling With gcc::
+* Binding With gnatbind::
+* Linking With gnatlink::
* The GNAT Make Program gnatmake::
* Improving Performance::
* Renaming Files Using gnatchop::
* Performing Dimensionality Analysis in GNAT::
* Generating Ada Bindings for C and C++ headers::
* Other Utility Programs::
-* Running and Debugging Ada Programs::
@ifclear vms
* Code Coverage and Profiling::
@end ifclear
+* Running and Debugging Ada Programs::
@ifset vms
* Compatibility with HP Ada::
@end ifset
* GNU Free Documentation License::
* Index::
- --- The Detailed Node Listing ---
+ --- Detailed Contents ---
About This Guide
-
* What This Guide Contains::
* What You Should Know before Reading This Guide::
* Related Information::
* Conventions::
Getting Started with GNAT
-
* Running GNAT::
* Running a Simple Ada Program::
* Running a Program with Multiple Units::
@end ifclear
The GNAT Compilation Model
-
* Source Representation::
* Foreign Language Representation::
* File Naming Rules::
* Placement of temporary files::
@end ifset
-Foreign Language Representation
-
-* Latin-1::
-* Other 8-Bit Codes::
-* Wide Character Encodings::
-
-Compiling Ada Programs With gcc
-
+Compiling With gcc
* Compiling Programs::
* Switches for gcc::
* Search Paths and the Run-Time Library (RTL)::
* Order of Compilation Issues::
* Examples::
-Switches for gcc
-
-* Output and Error Message Control::
-* Warning Message Control::
-* Debugging and Assertion Control::
-* Validity Checking::
-* Style Checking::
-* Run-Time Checks::
-* Using gcc for Syntax Checking::
-* Using gcc for Semantic Checking::
-* Compiling Different Versions of Ada::
-* Character Set Control::
-* File Naming Control::
-* Subprogram Inlining Control::
-* Auxiliary Output Control::
-* Debugging Control::
-* Exception Handling Control::
-* Units to Sources Mapping Files::
-* Integrated Preprocessing::
-@ifset vms
-* Return Codes::
-@end ifset
-
-Binding Ada Programs With gnatbind
-
+Binding With gnatbind
* Running gnatbind::
* Switches for gnatbind::
* Command-Line Access::
* Search Paths for gnatbind::
* Examples of gnatbind Usage::
-Switches for gnatbind
-
-* Consistency-Checking Modes::
-* Binder Error Message Control::
-* Elaboration Control::
-* Output Control::
-* Binding with Non-Ada Main Programs::
-* Binding Programs with No Main Subprogram::
-
-Linking Using gnatlink
-
+Linking With gnatlink
* Running gnatlink::
* Switches for gnatlink::
The GNAT Make Program gnatmake
-
* Running gnatmake::
* Switches for gnatmake::
* Mode Switches for gnatmake::
* Reducing Size of Ada Executables with gnatelim::
* Reducing Size of Executables with unused subprogram/data elimination::
-Performance Considerations
-* Controlling Run-Time Checks::
-* Use of Restrictions::
-* Optimization Levels::
-* Debugging Optimized Code::
-* Inlining of Subprograms::
-* Vectorization of loops::
-* Other Optimization Switches::
-* Optimization and Strict Aliasing::
-@ifset vms
-* Coverage Analysis::
-@end ifset
-
-Reducing Size of Ada Executables with gnatelim
-* About gnatelim::
-* Running gnatelim::
-* Processing Precompiled Libraries::
-* Correcting the List of Eliminate Pragmas::
-* Making Your Executables Smaller::
-* Summary of the gnatelim Usage Cycle::
-
-Reducing Size of Executables with unused subprogram/data elimination
-* About unused subprogram/data elimination::
-* Compilation options::
-
Renaming Files Using gnatchop
-
* Handling Files with Multiple Units::
* Operating gnatchop in Compilation Mode::
* Command Line for gnatchop::
* Examples of gnatchop Usage::
Configuration Pragmas
-
* Handling of Configuration Pragmas::
* The Configuration Pragmas Files::
Handling Arbitrary File Naming Conventions Using gnatname
-
* Arbitrary File Naming Conventions::
* Running gnatname::
* Switches for gnatname::
* Examples of gnatname Usage::
-The Cross-Referencing Tools gnatxref and gnatfind
+GNAT Project Manager
+* Introduction::
+* Building With Projects::
+* Organizing Projects into Subsystems::
+* Scenarios in Projects::
+* Library Projects::
+* Project Extension::
+* Aggregate Projects::
+* Aggregate Library Projects::
+* Project File Reference::
+
+Tools Supporting Project Files
+* Switches Related to Project Files::
+* Switches and Project Files::
+* Specifying Configuration Pragmas::
+* Project Files and Main Subprograms::
+* Library Project Files::
+The Cross-Referencing Tools gnatxref and gnatfind
* Switches for gnatxref::
* Switches for gnatfind::
* Project Files for gnatxref and gnatfind::
* Examples of gnatfind Usage::
The GNAT Pretty-Printer gnatpp
-
* Switches for gnatpp::
* Formatting Rules::
The GNAT Metrics Tool gnatmetric
-
* Switches for gnatmetric::
File Name Krunching Using gnatkr
-
* About gnatkr::
* Using gnatkr::
* Krunching Method::
* Form of Input Text for gnatprep::
The GNAT Library Browser gnatls
-
* Running gnatls::
* Switches for gnatls::
* Examples of gnatls Usage::
Cleaning Up Using gnatclean
-
* Running gnatclean::
* Switches for gnatclean::
@c * Examples of gnatclean Usage::
@ifclear vms
-
GNAT and Libraries
-
* Introduction to Libraries in GNAT::
* General Ada Libraries::
* Stand-alone Ada Libraries::
* Rebuilding the GNAT Run-Time Library::
Using the GNU make Utility
-
* Using gnatmake in a Makefile::
* Automatically Creating a List of Directories::
* Generating the Command Line Switches::
@end ifclear
Memory Management Issues
-
* Some Useful Memory Pools::
* The GNAT Debug Pool Facility::
@ifclear vms
@end ifclear
Stack Related Facilities
-
* Stack Overflow Checking::
* Static Stack Usage Analysis::
* Dynamic Stack Usage Analysis::
Verifying Properties Using gnatcheck
-Sample Bodies Using gnatstub
-
+Creating Sample Bodies Using gnatstub
* Running gnatstub::
* Switches for gnatstub::
Creating Unit Tests Using gnattest
-
* Running gnattest::
* Switches for gnattest::
* Project Attributes for gnattest::
@end ifclear
* Current Limitations::
-Other Utility Programs
+Performing Dimensionality Analysis in GNAT
+
+Generating Ada Bindings for C and C++ headers
+* Running the binding generator::
+* Generating bindings for C++ headers::
+* Switches::
+Other Utility Programs
* Using Other Utility Programs with GNAT::
* The External Symbol Naming Scheme of GNAT::
* Converting Ada Files to html with gnathtml::
+* Installing gnathtml::
+@ifset vms
+* LSE::
+* Profiling::
+@end ifset
@ifclear vms
Code Coverage and Profiling
-
* Code Coverage of Ada Programs using gcov::
* Profiling an Ada Program using gprof::
@end ifclear
Running and Debugging Ada Programs
-
* The GNAT Debugger GDB::
* Running GDB::
* Introduction to GDB Commands::
* Stack Traceback::
@ifset vms
-* LSE::
-@end ifset
-
-@ifset vms
Compatibility with HP Ada
-
* Ada Language Compatibility::
* Differences in the Definition of Package System::
* Language-Related Features::
* Tools and Utilities::
Language-Related Features
-
* Integer Types and Representations::
* Floating-Point Types and Representations::
* Pragmas Float_Representation and Long_Float::
* Other Representation Clauses::
Tasking and Task-Related Features
-
* Implementation of Tasks in HP Ada for OpenVMS Alpha Systems::
* Assigning Task IDs::
* Task IDs and Delays::
* External Interrupts::
Pragmas and Pragma-Related Features
-
* Restrictions on the Pragma INLINE::
* Restrictions on the Pragma INTERFACE::
* Restrictions on the Pragma SYSTEM_NAME::
Library of Predefined Units
-
* Changes to DECLIB::
Bindings
-
* Shared Libraries and Options Files::
* Interfaces to C::
@end ifset
Platform-Specific Information for the Run-Time Libraries
-
* Summary of Run-Time Configurations::
* Specifying a Run-Time Library::
* Choosing the Scheduling Policy::
Example of Binder Output File
Elaboration Order Handling in GNAT
-
* Elaboration Code::
* Checking the Elaboration Order::
* Controlling the Elaboration Order::
* Preprocessing::
Inline Assembler
-
* Basic Assembler Syntax::
* A Simple Example of Inline Assembler::
* Output Variables in Inline Assembler::
* Other Asm Functionality::
Compatibility and Porting Guide
-
* Compatibility with Ada 83::
* Compatibility between Ada 95 and Ada 2005::
* Implementation-dependent characteristics::
@end ifset
Microsoft Windows Topics
-
@ifclear FSFEDITION
* Installing from the Command Line::
@end ifclear
* Setting Heap Size from gnatlink::
Mac OS Topics
-
* Codesigning the Debugger::
-* Index::
+GNU Free Documentation License
+
+Index
@end menu
@end ifnottex
by GNAT.
@item
-@ref{Compiling Using gcc}, describes how to compile
+@ref{Compiling With gcc}, describes how to compile
Ada programs with @command{gcc}, the Ada compiler.
@item
-@ref{Binding Using gnatbind}, describes how to
+@ref{Binding With gnatbind}, describes how to
perform binding of Ada programs with @code{gnatbind}, the GNAT binding
utility.
@item
-@ref{Linking Using gnatlink},
+@ref{Linking With gnatlink},
describes @command{gnatlink}, a
program that provides for linking using the GNAT run-time library to
construct a program. @command{gnatlink} can also incorporate foreign language
@end ifset
@c *************************
-@node Compiling Using gcc
-@chapter Compiling Using @command{gcc}
+@node Compiling With gcc
+@chapter Compiling With @command{gcc}
@noindent
This chapter discusses how to compile Ada programs using the @command{gcc}
Note that @option{-gnatE} is not necessary for safety, because in the
default mode, GNAT ensures statically that the checks would not fail.
For full details of the effect and use of this switch,
-@xref{Compiling Using gcc}.
+@xref{Compiling With gcc}.
@item -fstack-check
@cindex @option{-fstack-check} (@command{gcc})
mode.
@end table
-@node Binding Using gnatbind
-@chapter Binding Using @code{gnatbind}
+@node Binding With gnatbind
+@chapter Binding With @code{gnatbind}
@findex gnatbind
@menu
@end table
@c ------------------------------------
-@node Linking Using gnatlink
-@chapter Linking Using @command{gnatlink}
+@node Linking With gnatlink
+@chapter Linking With @command{gnatlink}
@c ------------------------------------
@findex gnatlink
@end group
@end smallexample
+@noindent
+Note that a variable is
+@strong{always imported with a DLL convention}. A function
+can have @code{C} or @code{Stdcall} convention.
+(@pxref{Windows Calling Conventions}).
+
@node Creating an Import Library
@subsection Creating an Import Library
@cindex Import library
-- --
------------------------------------------------------------------------------
-with Ada.Text_IO; use Ada.Text_IO;
-
with Fmap;
with Hostparm;
with Makeutl; use Makeutl;
with Sdefault;
with Tempdir;
+with Ada.Text_IO; use Ada.Text_IO;
+
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
package body Prj.Env is
Error_Msg_Name_2 := Name_Class;
Error_Msg_N
- ("aspect `%''%` can only be specified for a primitive " &
- "operation of a tagged type",
- Corresponding_Aspect (N));
+ ("aspect `%''%` can only be specified for a primitive "
+ & "operation of a tagged type", Corresponding_Aspect (N));
end if;
Replace_Type (Get_Pragma_Arg (Arg1));
and then not Is_Unchecked_Union (Etype (Subtype_Mark (Sindic)))
then
Error_Msg_N
- ("component subtype subject to per-object constraint " &
- "must be an Unchecked_Union", Comp);
+ ("component subtype subject to per-object constraint "
+ & "must be an Unchecked_Union", Comp);
-- Ada 2012 (AI05-0026): For an unchecked union type declared within
-- the body of a generic unit, or within the body of any of its
begin
if Nkind (Constr) = N_Pragma then
Error_Pragma
- ("pragma % must appear immediately within the statements " &
- "of a loop");
+ ("pragma % must appear immediately within the statements "
+ & "of a loop");
else
Error_Pragma_Arg
- ("block containing pragma % must appear immediately within " &
- "the statements of a loop", Constr);
+ ("block containing pragma % must appear immediately within "
+ & "the statements of a loop", Constr);
end if;
end Placement_Error;
and then C /= Convention (Overridden_Operation (E))
then
Error_Pragma_Arg
- ("cannot change convention for " &
- "overridden dispatching operation",
- Arg1);
+ ("cannot change convention for overridden "
+ & "dispatching operation", Arg1);
end if;
-- Set the convention
then
Error_Msg_Sloc := Sloc (Def_Id);
Error_Msg_NE
- ("cannot import&, renaming already provided for " &
- "declaration #", N, Def_Id);
+ ("cannot import&, renaming already provided for "
+ & "declaration #", N, Def_Id);
end if;
end;
(not Input_Seen and then not Output_Seen)) -- none
then
Error_Msg_N
- ("property Volatile requires exactly one Input or " &
- "Output", State);
+ ("property Volatile requires exactly one Input or "
+ & "Output", State);
end if;
-- Either Input or Output require Volatile
-- unit (RM E.4.1(4)).
Error_Pragma
- ("pragma% not in Remote_Call_Interface or " &
- "Remote_Types unit");
+ ("pragma% not in Remote_Call_Interface or Remote_Types unit");
end if;
if Ekind (Nm) = E_Procedure
and then not Is_Array_Type (Typ)
then
Error_Pragma_Arg
- ("Name parameter of pragma% must identify record or " &
- "array type", Name);
+ ("Name parameter of pragma% must identify record or "
+ & "array type", Name);
end if;
-- An explicit Component_Alignment pragma overrides an
GNAT_Pragma;
if Warn_On_Obsolescent_Feature then
- -- Following message is obsolete ???
Error_Msg_N
- ("'G'N'A'T pragma cpp'_class is now obsolete and has no " &
- "effect; replace it by pragma import?j?", N);
+ ("'G'N'A'T pragma cpp'_class is now obsolete and has no "
+ & "effect; replace it by pragma import?j?", N);
end if;
Check_Arg_Count (1);
then
if Scope (Def_Id) /= Scope (Etype (Def_Id)) then
Error_Msg_N
- ("'C'P'P constructor must be defined in the scope of " &
- "its returned type", Arg1);
+ ("'C'P'P constructor must be defined in the scope of "
+ & "its returned type", Arg1);
end if;
if Arg_Count >= 2 then
if Warn_On_Obsolescent_Feature then
Error_Msg_N
- ("'G'N'A'T pragma cpp'_virtual is now obsolete and has " &
- "no effect?j?", N);
+ ("'G'N'A'T pragma cpp'_virtual is now obsolete and has "
+ & "no effect?j?", N);
end if;
end CPP_Virtual;
if Warn_On_Obsolescent_Feature then
Error_Msg_N
- ("'G'N'A'T pragma cpp'_vtable is now obsolete and has " &
- "no effect?j?", N);
+ ("'G'N'A'T pragma cpp'_vtable is now obsolete and has "
+ & "no effect?j?", N);
end if;
end CPP_Vtable;
then
Error_Msg_Name_1 := Name_Result;
Error_Msg_N
- ("prefix of attribute % must denote the enclosing " &
- "function", Item);
+ ("prefix of attribute % must denote the enclosing "
+ & "function", Item);
-- Function'Result is allowed to appear on the output
-- side of a dependency clause.
if Is_Output and then not Is_Last then
Error_Msg_N
- ("null output list must be the last clause in " &
- "a dependency relation", Item);
+ ("null output list must be the last clause in "
+ & "a dependency relation", Item);
end if;
end if;
and then Contains (All_Inputs_Seen, Item_Id)
then
Error_Msg_N
- ("input of a null output list appears in " &
- "multiple input lists", Item);
+ ("input of a null output list appears in "
+ & "multiple input lists", Item);
else
if No (All_Inputs_Seen) then
All_Inputs_Seen := New_Elmt_List;
else
Error_Msg_N
- ("item must denote variable, state or formal " &
- "parameter", Item);
+ ("item must denote variable, state or formal "
+ & "parameter", Item);
end if;
-- All other input/output items are illegal
else
Error_Msg_N
- ("item must denote variable, state or formal " &
- "parameter", Item);
+ ("item must denote variable, state or formal "
+ & "parameter", Item);
end if;
end if;
end Analyze_Input_Output;
Present (Source_Location)
then
Error_Pragma
- ("parameter profile and source location cannot " &
- "be used together in pragma%");
+ ("parameter profile and source location cannot "
+ & "be used together in pragma%");
end if;
Process_Eliminate_Pragma
if Ekind (Item_Id) = E_Abstract_State
and then Is_Volatile_State (Item_Id)
then
- -- A global item of mode In_Out or Output cannot denote a
- -- volatile Input state.
+ -- A global item of mode In_Out or Output cannot denote
+ -- a volatile Input state.
if Is_Input_State (Item_Id)
and then (Global_Mode = Name_In_Out
Global_Mode = Name_Output)
then
Error_Msg_N
- ("global item of mode In_Out or Output cannot " &
- "reference Volatile Input state", Item);
+ ("global item of mode In_Out or Output cannot "
+ & "reference Volatile Input state", Item);
-- A global item of mode In_Out or Input cannot reference
-- a volatile Output state.
null;
else
Error_Pragma_Arg
- ("controlling formal must be of synchronized " &
- "tagged type", Arg1);
+ ("controlling formal must be of synchronized "
+ & "tagged type", Arg1);
return;
end if;
and then Is_Task_Interface (Typ)
then
Error_Pragma_Arg
- ("implementation kind By_Protected_Procedure cannot be " &
- "applied to a task interface primitive", Arg2);
+ ("implementation kind By_Protected_Procedure cannot be "
+ & "applied to a task interface primitive", Arg2);
return;
end if;
Int_Val > Expr_Value (Type_High_Bound (Int_Id))
then
Error_Pragma_Arg
- ("value not in range of type " &
- """Ada.Interrupts.Interrupt_'I'D""", Arg1);
+ ("value not in range of type "
+ & """Ada.Interrupts.Interrupt_'I'D""", Arg1);
end if;
end if;
elsif In_Private_Part (Current_Scope) then
Error_Pragma_Arg
- ("pragma% only allowed for private type " &
- "declared in visible part", Arg1);
+ ("pragma% only allowed for private type "
+ & "declared in visible part", Arg1);
else
Error_Pragma_Arg
if Ekind (Def_Id) /= E_Function then
if VM_Target = JVM_Target then
Error_Pragma_Arg
- ("pragma% requires function returning a " &
- "'Java access type", Def_Id);
+ ("pragma% requires function returning a "
+ & "'Java access type", Def_Id);
else
Error_Pragma_Arg
- ("pragma% requires function returning a " &
- "'C'I'L access type", Def_Id);
+ ("pragma% requires function returning a "
+ & "'C'I'L access type", Def_Id);
end if;
end if;
then
Error_Msg_Name_1 := Pname;
Error_Msg_N
- ("first formal of % function must be a named access" &
- " to subprogram type",
+ ("first formal of % function must be a named access "
+ & "to subprogram type",
Parameter_Type (Parent (This_Formal)));
-- Warning: We should reject anonymous access types because
then
Error_Msg_Name_1 := Pname;
Error_Msg_N
- ("first formal of % function must be a named access" &
- " type",
- Parameter_Type (Parent (This_Formal)));
+ ("first formal of % function must be a named access "
+ & " type", Parameter_Type (Parent (This_Formal)));
elsif Atree.Convention
(Designated_Type (Etype (This_Formal))) /= Convention
if Convention = Convention_Java then
Error_Msg_N
- ("pragma% requires convention 'Cil in designated" &
- " type",
- Parameter_Type (Parent (This_Formal)));
+ ("pragma% requires convention 'Cil in designated "
+ & "type", Parameter_Type (Parent (This_Formal)));
else
Error_Msg_N
- ("pragma% requires convention 'Java in designated" &
- " type",
- Parameter_Type (Parent (This_Formal)));
+ ("pragma% requires convention 'Java in designated "
+ & "type", Parameter_Type (Parent (This_Formal)));
end if;
elsif No (Expression (Parent (This_Formal)))
if Atree.Convention (Etype (Def_Id)) /= Convention then
if Convention = Convention_Java then
Error_Pragma_Arg
- ("pragma% requires function returning a " &
- "'Java access type", Arg1);
+ ("pragma% requires function returning a "
+ & "'Java access type", Arg1);
else
pragma Assert (Convention = Convention_CIL);
Error_Pragma_Arg
- ("pragma% requires function returning a " &
- "'C'I'L access type", Arg1);
+ ("pragma% requires function returning a "
+ & "'C'I'L access type", Arg1);
end if;
end if;
if Convention = Convention_Java then
Error_Pragma_Arg
- ("pragma% requires function returning a named" &
- "'Java access type", Arg1);
+ ("pragma% requires function returning a named "
+ & "'Java access type", Arg1);
else
Error_Pragma_Arg
- ("pragma% requires function returning a named" &
- "'C'I'L access type", Arg1);
+ ("pragma% requires function returning a named "
+ & "'C'I'L access type", Arg1);
end if;
end if;
end if;
loop
if No (Ent) then
Error_Pragma
- ("pragma % entity name does not match any " &
- "enumeration literal");
+ ("pragma % entity name does not match any "
+ & "enumeration literal");
elsif Chars (Ent) = Chars (Ename) then
Set_Entity (Ename, Ent);
and then not Has_Preelaborable_Initialization (Ent)
then
Error_Msg_N
- ("protected type & does not have preelaborable " &
- "initialization", Ent);
+ ("protected type & does not have preelaborable "
+ & "initialization", Ent);
-- Otherwise mark the type as definitely having preelaborable
-- initialization.
elsif Lower_Val > Upper_Val then
Error_Pragma
- ("last_priority_expression must be greater than" &
- " or equal to first_priority_expression");
+ ("last_priority_expression must be greater than "
+ & "or equal to first_priority_expression");
-- Store the new policy, but always preserve System_Location since
-- we like the error message with the run-time name.
or else In_Package_Body (Current_Scope)
then
Error_Pragma
- ("pragma% can only apply to type declared immediately " &
- "within a package declaration");
+ ("pragma% can only apply to type declared immediately"
+ & " within a package declaration");
end if;
-- A simple storage pool type must be an immutably limited record
or else Present (Next_Formal (First_Formal (Ent)))
then
Error_Pragma_Arg
- ("argument for pragma% must be" &
- " function of one argument", Arg);
+ ("argument for pragma% must be function of one argument",
+ Arg);
end if;
end Check_OK_Stream_Convert_Function;
elsif not Is_Static_String_Expression (Arg1) then
Error_Pragma_Arg
- ("argument of pragma% must be On/Off or " &
- "static string expression", Arg1);
+ ("argument of pragma% must be On/Off or "
+ & "static string expression", Arg1);
-- One argument string expression case
if not Set_Dot_Warning_Switch (Chr) then
Error_Pragma_Arg
- ("invalid warning switch character " &
- '.' & Chr, Arg1);
+ ("invalid warning switch character "
+ & '.' & Chr, Arg1);
end if;
-- Non-Dot case
elsif not Is_Static_String_Expression (Arg2) then
Error_Pragma_Arg
- ("second argument of pragma% must be entity " &
- "name or static string expression", Arg2);
+ ("second argument of pragma% must be entity "
+ & "name or static string expression", Arg2);
-- String literal case
if Err then
Error_Msg
- ("??pragma Warnings On with no " &
- "matching Warnings Off",
+ ("??pragma Warnings On with no "
+ & "matching Warnings Off",
Loc);
end if;
end if;
pragma Import (C, save_argv);
-- Saved value of argv (argument pointers), imported from misc.c
+ function Len_Arg (Arg : Pos) return Nat;
+ -- Determine length of argument number Arg on original gnat1 command
+ -- line.
+
+ -------------
+ -- Len_Arg --
+ -------------
+
+ function Len_Arg (Arg : Pos) return Nat is
+ begin
+ for J in 1 .. Nat'Last loop
+ if save_argv (Arg).all (Natural (J)) = ASCII.NUL then
+ return J - 1;
+ end if;
+ end loop;
+
+ raise Program_Error;
+ end Len_Arg;
+
begin
-- Loop through arguments looking for -gnateT, also look for -gnatd.b
for Arg in 1 .. save_argc - 1 loop
declare
Argv_Ptr : constant Big_String_Ptr := save_argv (Arg);
+ Argv_Len : constant Nat := Len_Arg (Arg);
begin
-
- -- ??? Is there no problem accessing at indices 1 to 7 or 8
- -- without first checking if the length of the underlying string
- -- may be smaller? See back_end.adb for an example where function
- -- Len_Arg is used to retrieve this length.
-
- if Argv_Ptr (1 .. 7) = "-gnateT" then
+ if Argv_Len = 7
+ and then Argv_Ptr (1 .. 7) = "-gnateT"
+ then
Opt.Target_Dependent_Info_Read := True;
- elsif Argv_Ptr (1 .. 8) = "-gnatd.b" then
+ elsif Argv_Len >= 8
+ and then Argv_Ptr (1 .. 8) = "-gnatd.b"
+ then
Debug_Flag_Dot_B := True;
end if;
end;