public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Crash on illegal specification for a configuration file.
@ 2017-04-25  9:22 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2017-04-25  9:22 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ed Schonberg

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

The -gnatec switch is used to specify configuration files containing that
contain configuration pragmas. With This patch the compiler rejects properly
a name for a configuration file that designates a directory rather than
crashing.

Executing

  gcc -c pkg.ads -gnatec=.

must yield: 

gnat1: cannot find configuration pragmas file . 

---
package pkg is
private
end;

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

2017-04-25  Ed Schonberg  <schonberg@adacore.com>

	* osint.adb (Find_File): Handle properly a request for a
	configuration file whose name is a directory.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1461 bytes --]

Index: osint.adb
===================================================================
--- osint.adb	(revision 247135)
+++ osint.adb	(working copy)
@@ -1189,16 +1189,25 @@
             Found := N;
             Attr.all  := Unknown_Attributes;
 
-            if T = Config and then Full_Name then
-               declare
-                  Full_Path : constant String :=
-                                Normalize_Pathname (Get_Name_String (N));
-                  Full_Size : constant Natural := Full_Path'Length;
-               begin
-                  Name_Buffer (1 .. Full_Size) := Full_Path;
-                  Name_Len := Full_Size;
-                  Found := Name_Find;
-               end;
+            if T = Config then
+               if Full_Name then
+                  declare
+                     Full_Path : constant String :=
+                                   Normalize_Pathname (Get_Name_String (N));
+                     Full_Size : constant Natural := Full_Path'Length;
+
+                  begin
+                     Name_Buffer (1 .. Full_Size) := Full_Path;
+                     Name_Len := Full_Size;
+                     Found := Name_Find;
+                  end;
+               end if;
+
+               --  Check that it is a file, not a directory
+
+               if not Is_Regular_File (Get_Name_String (Found)) then
+                  Found := No_File;
+               end if;
             end if;
 
             return;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-25  9:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-25  9:22 [Ada] Crash on illegal specification for a configuration file Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).