[Ada] Protect against potentially uninitialized source information

Arnaud Charlet charlet@adacore.com
Fri Jan 24 14:23:00 GMT 2014

Some tools that use the project manager might be creating a project
on the fly (no reference to an actual project file), which could
result in a Constraint_Error in this code.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-24  Emmanuel Briot  <briot@adacore.com>

	* prj-nmsc.adb (Check_File): Add protection when the source is
	not fully initialized.

-------------- next part --------------
Index: prj-nmsc.adb
--- prj-nmsc.adb	(revision 207032)
+++ prj-nmsc.adb	(working copy)
@@ -7051,7 +7051,9 @@
             --  Check if it is OK to have the same file name in several
             --  source directories.
-            if Source_Dir_Rank = Name_Loc.Source.Source_Dir_Rank then
+            if Name_Loc.Source /= No_Source
+              and then Source_Dir_Rank = Name_Loc.Source.Source_Dir_Rank
+            then
                Error_Msg_File_1 := File_Name;

More information about the Gcc-patches mailing list