2009-08-07 Robert Dewar <dewar@adacore.com>
+ * sem_warn.adb (Warn_On_Unreferenced_Entity): Fix obvious typo.
+
+2009-08-07 Vincent Celier <celier@adacore.com>
+
+ * gnatcmd.adb (GNATCmd): If -U is not used, one and only one main is
+ specified on the command line and there are switches in the Compiler
+ package of the project file, use these compilation switches to invoke
+ the tool.
+
+2009-08-07 Ben Brosgol <brosgol@adacore.com>
+
+ * gnat_ugn.texi: Wordsmithing edits at beginning of gnatcheck chapter.
+
+2009-08-07 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch10.adb (Analyze_Proper_Body): Indicate name of missing subunit
+ even if not in main unit, to simplify debugging.
+
+2009-08-07 Arnaud Charlet <charlet@adacore.com>
+
+ * gcc-interface/Makefile.in: Fix handling of GCC_FOR_TARGET.
+ * gcc-interface/Make-lang.in: Update dependencies.
+
+2009-08-07 Robert Dewar <dewar@adacore.com>
+
* types.ads: Minor reformatting
* sem_ch12.ads (Check_Generic_Child_Unit): Add missing documentation.
* frontend.adb, sem_warn.adb, sem_warn.ads: Fix spelling of
ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads ada/output.ads \
ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/rtsfind.adb \
ada/sem.ads ada/sem_aux.ads ada/sem_ch13.ads ada/sem_ch13.adb \
- ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_dist.ads ada/sem_eval.ads \
- ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads ada/sem_warn.ads \
- ada/sinfo.ads ada/sinfo.adb ada/sinput.ads ada/snames.ads ada/stand.ads \
- ada/stringt.ads ada/system.ads ada/s-exctab.ads ada/s-htable.ads \
- ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads \
- ada/s-rident.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \
- ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads \
- ada/s-unstyp.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \
- ada/targparm.ads ada/tbuild.ads ada/tbuild.adb ada/tree_io.ads \
- ada/ttypes.ads ada/types.ads ada/uintp.ads ada/uintp.adb ada/uname.ads \
- ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/urealp.adb
+ ada/sem_ch3.ads ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_dist.ads \
+ ada/sem_eval.ads ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads \
+ ada/sem_warn.ads ada/sinfo.ads ada/sinfo.adb ada/sinput.ads \
+ ada/snames.ads ada/stand.ads ada/stringt.ads ada/system.ads \
+ ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads \
+ ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads ada/s-soflin.ads \
+ ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb \
+ ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads ada/s-wchcon.ads \
+ ada/table.ads ada/table.adb ada/targparm.ads ada/tbuild.ads \
+ ada/tbuild.adb ada/tree_io.ads ada/ttypes.ads ada/types.ads \
+ ada/uintp.ads ada/uintp.adb ada/uname.ads ada/unchconv.ads \
+ ada/unchdeal.ads ada/urealp.ads ada/urealp.adb
ada/sem_ch2.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \
ada/a-uncdea.ads ada/alloc.ads ada/atree.ads ada/atree.adb \
gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../stamp-gnatlib2-$(RTSDIR)
$(MAKE) -C $(RTSDIR) \
CC="`echo \"$(GCC_FOR_TARGET)\" \
- | sed -e 's,^\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
+ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \
CFLAGS="$(GNATLIBCFLAGS_FOR_C)" \
FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
-f ../Makefile $(LIBGNAT_OBJS)
$(MAKE) -C $(RTSDIR) \
CC="`echo \"$(GCC_FOR_TARGET)\" \
- | sed -e 's,^\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
+ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
ADA_INCLUDES="" \
CFLAGS="$(GNATLIBCFLAGS)" \
ADAFLAGS="$(GNATLIBFLAGS)" \
@end itemize
@noindent
-Either a @file{@var{filename}} or an @file{@var{arg_list_filename}} must be supplied.
+Either a @file{@var{filename}} or an @file{@var{arg_list_filename}} must be
+supplied.
@menu
* Format of the Report File::
The @command{gnatcheck} tool outputs on @file{stdout} all messages concerning
rule violations.
It also creates a text file that
-contains the complete report of the last gnatcheck run. By default this file is
-named named @file{^gnatcheck.out^GNATCHECK.OUT^} and it is located in the current
-directory, @option{^-o^/OUTPUT^} option can be used to change the name and/or
-location of the report file. This report contains:
+contains the complete report of the last gnatcheck run. By default this file
+is named named @file{^gnatcheck.out^GNATCHECK.OUT^} and it is located in the
+current directory; the @option{^-o^/OUTPUT^} option can be used to change the
+name and/or location of the report file. This report contains:
@itemize @bullet
@item date and time of @command{gnatcheck} run, the version of
-the tool that has generated this report and the full paarmeters
+the tool that has generated this report and the full parameters
of the @command{gnatcheck} invocation;
-@item the list of enabled rules;
-@item the total number of detected violations;
-@item list of source files for that rule violations have been detected;
-@item list of source files with no violations detected;
+@item list of enabled rules;
+@item total number of detected violations;
+@item list of source files where rule violations have been detected;
+@item list of source files where no violations have been detected.
@end itemize
@node General gnatcheck Switches
@cindex @option{^-a^/ALL^} (@command{gnatcheck})
@item ^-a^/ALL^
Process all units including those with read-only ALI files such as
-those from GNAT Run-Time library.
+those from the GNAT Run-Time library.
@ifclear vms
@ignore
@cindex @option{-dd} (@command{gnatcheck})
@item -dd
-Progress indicator mode (for use in GPS)
+Progress indicator mode (for use in GPS).
@end ifclear
@cindex @option{^-h^/HELP^} (@command{gnatcheck})
@cindex @option{^-log^/LOG^} (@command{gnatcheck})
@item ^-log^/LOG^
-Duplicate all the output sent to Stderr into a log file. The log file is
-named @var{gnatcheck.log} and is located in the current directory.
+Duplicate all the output sent to @file{stderr} into a log file. The log file
+is named @file{gnatcheck.log} and is located in the current directory.
@cindex @option{^-m^/DIAGNOSTIC_LIMIT^} (@command{gnatcheck})
-@item ^-m@i{nnn}^/DIAGNOSTIC_LIMIT=@i{nnn}^
-Maximum number of diagnoses to be sent to Stdout, @i{nnn} from o@dots{}1000,
+@item ^-m@i{nnnn}^/DIAGNOSTIC_LIMIT=@i{nnnn}^
+Maximum number of diagnostics to be sent to @file{stdout}, where @i{nnnn} is in
+the range 0@dots{}1000;
the default value is 500. Zero means that there is no limitation on
-the number of diagnostic messages to be printed into Stdout.
+the number of diagnostic messages to be output.
@cindex @option{^-q^/QUIET^} (@command{gnatcheck})
@item ^-q^/QUIET^
-Quiet mode. All the diagnoses about rule violations are placed in the
-@command{gnatcheck} report file only, without duplicating in @file{stdout}.
+Quiet mode. All the diagnostics about rule violations are placed in the
+@command{gnatcheck} report file only, without duplication on @file{stdout}.
@cindex @option{^-s^/SHORT^} (@command{gnatcheck})
@item ^-s^/SHORT^
@cindex @option{^-s2^/BY_RULES^} (@command{gnatcheck})
@item ^-s2^/BY_RULES^
-Include the section containing diagnoses ordered by rules in the report file
+Include the section containing diagnostics ordered by rules in the report file
@cindex @option{^-s3^/BY_FILES_BY_RULES^} (@command{gnatcheck})
@item ^-s3^/BY_FILES_BY_RULES^
-Include the section containing diagnoses ordered by files and then by rules
+Include the section containing diagnostics ordered by files and then by rules
in the report file
@cindex @option{^-t^/TIME^} (@command{gnatcheck})
@table @option
@item Restrictions
-To record restrictions violations (that are performed by the compiler if the
+To record restrictions violations (which are performed by the compiler if the
pragma @code{Restrictions} or @code{Restriction_Warnings} are given),
-use the rule named
-@code{Restrictions} with the same parameters as pragma
+use the @code{Restrictions} rule
+with the same parameters as pragma
@code{Restrictions} or @code{Restriction_Warnings}.
@item Style_Checks
-To record compiler style checks(@pxref{Style Checking}), use the rule named
-@code{Style_Checks}. A parameter of this rule can be either @code{All_Checks},
-which enables all the standard style checks that corresponds to @option{-gnatyy}
-GNAT style check option, or a string that has exactly the same
-structure and semantics as the @code{string_LITERAL} parameter of GNAT pragma
-@code{Style_Checks} (for further information about this pragma,
-@pxref{Pragma Style_Checks,,, gnat_rm, GNAT Reference Manual}). For example,
-@code{+RStyle_Checks:O} rule option activates and adds to @command{gnatcheck}
-output the compiler style check that corresponds to
+To record compiler style checks (@pxref{Style Checking}), use the
+@code{Style_Checks} rule.
+This rule takes a parameter in one of the following forms:
+@itemize
+@item
+@code{All_Checks},
+which enables the standard style checks corresponding to the @option{-gnatyy}
+GNAT style check option, or
+
+@item
+a string with the same
+structure and semantics as the @code{string_LITERAL} parameter of the
+GNAT pragma @code{Style_Checks}
+(for further information about this pragma,
+@pxref{Pragma Style_Checks,,, gnat_rm, GNAT Reference Manual}).
+@end itemize
+
+@noindent
+For example, the
+@code{+RStyle_Checks:O} rule option activates
+the compiler style check that corresponds to
@code{-gnatyO} style check option.
@item Warnings
-To record compiler warnings (@pxref{Warning Message Control}), use the rule
-named @code{Warnings} with a parameter that is a valid
-@i{static_string_expression} argument of GNAT pragma @code{Warnings}
-(for further information about this pragma, @pxref{Pragma Warnings,,,
-gnat_rm, GNAT Reference Manual}). Note, that in case of gnatcheck
+To record compiler warnings (@pxref{Warning Message Control}), use the
+@code{Warnings} rule with a parameter that is a valid
+@i{static_string_expression} argument of the GNAT pragma @code{Warnings}
+(for further information about this pragma,
+@pxref{Pragma Warnings,,,gnat_rm, GNAT Reference Manual}).
+Note that in case of gnatcheck
's' parameter, that corresponds to the GNAT @option{-gnatws} option, disables
all the specific warnings, but not suppresses the warning mode,
and 'e' parameter, corresponding to @option{-gnatwe} that means
@end smallexample
@noindent
-When a @command{gnatcheck} annotatation has more then four arguments,
+When a @command{gnatcheck} annotation has more then four arguments,
@command{gnatcheck} issues a warning and ignores the additional arguments.
If the additional arguments do not follow the syntax above,
@command{gnatcheck} emits a warning and ignores the annotation.
Normalize_Pathname
(Command (Command'First .. Index));
- PATH : constant String :=
- Absolute_Dir &
- Path_Separator &
- Getenv ("PATH").all;
+ PATH : constant String :=
+ Absolute_Dir & Path_Separator & Getenv ("PATH").all;
begin
Setenv ("PATH", PATH);
begin
if The_Command = Stack then
+
-- Never call gnatstack with a prefix
Program := new String'(Command_List (The_Command).Unixcmd.all);
end loop;
end if;
- -- For BIND, CHECK, ELIM, FIND, LINK, LIST, PRETTY, STACK, STUB,
- -- METRIC ad XREF, look for project file related switches.
-
- if The_Command = Bind
- or else The_Command = Check
- or else The_Command = Sync
- or else The_Command = Elim
- or else The_Command = Find
- or else The_Command = Link
- or else The_Command = List
- or else The_Command = Xref
- or else The_Command = Pretty
- or else The_Command = Stack
- or else The_Command = Stub
- or else The_Command = Metric
- then
- case The_Command is
- when Bind =>
- Tool_Package_Name := Name_Binder;
- Packages_To_Check := Packages_To_Check_By_Binder;
- when Check =>
- Tool_Package_Name := Name_Check;
- Packages_To_Check := Packages_To_Check_By_Check;
- when Sync =>
- Tool_Package_Name := Name_Synchronize;
- Packages_To_Check := Packages_To_Check_By_Sync;
- when Elim =>
- Tool_Package_Name := Name_Eliminate;
- Packages_To_Check := Packages_To_Check_By_Eliminate;
- when Find =>
- Tool_Package_Name := Name_Finder;
- Packages_To_Check := Packages_To_Check_By_Finder;
- when Link =>
- Tool_Package_Name := Name_Linker;
- Packages_To_Check := Packages_To_Check_By_Linker;
- when List =>
- Tool_Package_Name := Name_Gnatls;
- Packages_To_Check := Packages_To_Check_By_Gnatls;
- when Metric =>
- Tool_Package_Name := Name_Metrics;
- Packages_To_Check := Packages_To_Check_By_Metric;
- when Pretty =>
- Tool_Package_Name := Name_Pretty_Printer;
- Packages_To_Check := Packages_To_Check_By_Pretty;
- when Stack =>
- Tool_Package_Name := Name_Stack;
- Packages_To_Check := Packages_To_Check_By_Stack;
- when Stub =>
- Tool_Package_Name := Name_Gnatstub;
- Packages_To_Check := Packages_To_Check_By_Gnatstub;
- when Xref =>
- Tool_Package_Name := Name_Cross_Reference;
- Packages_To_Check := Packages_To_Check_By_Xref;
- when others =>
- null;
- end case;
+ -- For BIND, CHECK, ELIM, FIND, LINK, LIST, METRIC, PRETTY, STACK, STUB,
+ -- SYNC and XREF, look for project file related switches.
+
+ case The_Command is
+ when Bind =>
+ Tool_Package_Name := Name_Binder;
+ Packages_To_Check := Packages_To_Check_By_Binder;
+ when Check =>
+ Tool_Package_Name := Name_Check;
+ Packages_To_Check := Packages_To_Check_By_Check;
+ when Elim =>
+ Tool_Package_Name := Name_Eliminate;
+ Packages_To_Check := Packages_To_Check_By_Eliminate;
+ when Find =>
+ Tool_Package_Name := Name_Finder;
+ Packages_To_Check := Packages_To_Check_By_Finder;
+ when Link =>
+ Tool_Package_Name := Name_Linker;
+ Packages_To_Check := Packages_To_Check_By_Linker;
+ when List =>
+ Tool_Package_Name := Name_Gnatls;
+ Packages_To_Check := Packages_To_Check_By_Gnatls;
+ when Metric =>
+ Tool_Package_Name := Name_Metrics;
+ Packages_To_Check := Packages_To_Check_By_Metric;
+ when Pretty =>
+ Tool_Package_Name := Name_Pretty_Printer;
+ Packages_To_Check := Packages_To_Check_By_Pretty;
+ when Stack =>
+ Tool_Package_Name := Name_Stack;
+ Packages_To_Check := Packages_To_Check_By_Stack;
+ when Stub =>
+ Tool_Package_Name := Name_Gnatstub;
+ Packages_To_Check := Packages_To_Check_By_Gnatstub;
+ when Sync =>
+ Tool_Package_Name := Name_Synchronize;
+ Packages_To_Check := Packages_To_Check_By_Sync;
+ when Xref =>
+ Tool_Package_Name := Name_Cross_Reference;
+ Packages_To_Check := Packages_To_Check_By_Xref;
+ when others =>
+ Tool_Package_Name := No_Name;
+ end case;
+
+ if Tool_Package_Name /= No_Name then
-- Check that the switches are consistent. Detect project file
-- related switches.
- Inspect_Switches :
- declare
+ Inspect_Switches : declare
Arg_Num : Positive := 1;
Argv : String_Access;
Element : Package_Element;
- Default_Switches_Array : Array_Element_Id;
+ Switches_Array : Array_Element_Id;
The_Switches : Prj.Variable_Value;
Current : Prj.String_List_Id;
The_String : String_Element;
+ Main : String_Access := null;
+ Main_Id : Name_Id;
+
begin
if Pkg /= No_Package then
+
+ -- First, check if there is a single main specified.
+
+ for J in 1 .. Last_Switches.Last loop
+ if Last_Switches.Table (J) (1) /= '-' then
+ if Main = null then
+ Main := Last_Switches.Table (J);
+
+ else
+ Main := null;
+ exit;
+ end if;
+ end if;
+ end loop;
+
Element := Project_Tree.Packages.Table (Pkg);
- Default_Switches_Array :=
- Prj.Util.Value_Of
- (Name => Name_Default_Switches,
- In_Arrays => Element.Decl.Arrays,
- In_Tree => Project_Tree);
- The_Switches := Prj.Util.Value_Of
- (Index => Name_Ada,
- Src_Index => 0,
- In_Array => Default_Switches_Array,
- In_Tree => Project_Tree);
-
- -- If there are switches specified in the package of the
- -- project file corresponding to the tool, scan them.
+ -- If there is a single main and there is compilation
+ -- switches specified in the project file, use them.
+
+ if Main /= null and then not All_Projects then
+ Name_Len := Main'Length;
+ Name_Buffer (1 .. Name_Len) := Main.all;
+ Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
+ Main_Id := Name_Find;
+
+ Switches_Array :=
+ Prj.Util.Value_Of
+ (Name => Name_Switches,
+ In_Arrays => Element.Decl.Arrays,
+ In_Tree => Project_Tree);
+ The_Switches := Prj.Util.Value_Of
+ (Index => Main_Id,
+ Src_Index => 0,
+ In_Array => Switches_Array,
+ In_Tree => Project_Tree);
+ end if;
+
+ -- Otherwise, get the Default_Switches ("Ada")
+
+ if The_Switches.Kind = Undefined then
+ Switches_Array :=
+ Prj.Util.Value_Of
+ (Name => Name_Default_Switches,
+ In_Arrays => Element.Decl.Arrays,
+ In_Tree => Project_Tree);
+ The_Switches := Prj.Util.Value_Of
+ (Index => Name_Ada,
+ Src_Index => 0,
+ In_Array => Switches_Array,
+ In_Tree => Project_Tree);
+ end if;
+
+ -- If there are switches specified, put them in the
+ -- Carg_Switches table.
case The_Switches.Kind is
when Prj.Undefined =>
Error_Node => N);
-- Give message if we did not get the unit
+ -- Emit warning even if missing subunit is not
+ -- within main unit, to simplify debugging.
if Original_Operating_Mode = Generate_Code
and then Unum = No_Unit
Error_Msg_File_1 :=
Get_File_Name (Subunit_Name, Subunit => True);
Error_Msg_N
- ("subunit$$ in file{ not found?", N);
+ ("subunit$$ in file{ not found?!!", N);
Subunits_Missing := True;
end if;
if Ekind (E) = E_In_Parameter
or else not Referenced_As_LHS_Check_Spec (E)
- or else Is_Scalar_Type (E)
+ or else Is_Scalar_Type (Etype (E))
then
if Present (Body_E) then
E := Body_E;