public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-7787] Fortran: Fix directory stat check for '.' [PR103560]
@ 2022-03-23 15:55 Tobias Burnus
0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2022-03-23 15:55 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:5e33fea21957c97d63e3738be6056ae2a94e3284
commit r12-7787-g5e33fea21957c97d63e3738be6056ae2a94e3284
Author: Tobias Burnus <tobias@codesourcery.com>
Date: Wed Mar 23 16:54:12 2022 +0100
Fortran: Fix directory stat check for '.' [PR103560]
MinGW does not like a call to 'stat' for './' via gfc_do_check_include_dir.
Solution: Only append '/' when concatenating the path with the filename.
gcc/fortran/ChangeLog:
PR fortran/103560
* scanner.cc (add_path_to_list): Don't append '/' to the
save include path.
(open_included_file): Use '/' in concatenating path + file name.
* module.cc (gzopen_included_file_1): Likewise.
gcc/testsuite/ChangeLog:
PR fortran/103560
* gfortran.dg/include_14.f90: Update dg-warning.
* gfortran.dg/include_17.f90: Likewise.
* gfortran.dg/include_18.f90: Likewise.
* gfortran.dg/include_6.f90: Update dg-*.
Diff:
---
gcc/fortran/module.cc | 3 ++-
gcc/fortran/scanner.cc | 7 +++----
gcc/testsuite/gfortran.dg/include_14.f90 | 4 ++--
gcc/testsuite/gfortran.dg/include_17.f90 | 4 ++--
gcc/testsuite/gfortran.dg/include_18.f90 | 4 ++--
gcc/testsuite/gfortran.dg/include_6.f90 | 2 +-
6 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc
index 281b1b17fbf..85aa153bd77 100644
--- a/gcc/fortran/module.cc
+++ b/gcc/fortran/module.cc
@@ -1095,8 +1095,9 @@ gzopen_included_file_1 (const char *name, gfc_directorylist *list,
if (module && !p->use_for_modules)
continue;
- fullname = (char *) alloca(strlen (p->path) + strlen (name) + 1);
+ fullname = (char *) alloca(strlen (p->path) + strlen (name) + 2);
strcpy (fullname, p->path);
+ strcat (fullname, "/");
strcat (fullname, name);
f = gzopen (fullname, "r");
diff --git a/gcc/fortran/scanner.cc b/gcc/fortran/scanner.cc
index b52282b687b..2dff2514700 100644
--- a/gcc/fortran/scanner.cc
+++ b/gcc/fortran/scanner.cc
@@ -409,9 +409,7 @@ add_path_to_list (gfc_directorylist **list, const char *path,
*list = dir;
dir->use_for_modules = use_for_modules;
dir->warn = warn;
- dir->path = XCNEWVEC (char, strlen (p) + 2);
- strcpy (dir->path, p);
- strcat (dir->path, "/"); /* make '/' last character */
+ dir->path = xstrdup (p);
}
/* defer_warn is set to true while parsing the commandline. */
@@ -476,8 +474,9 @@ open_included_file (const char *name, gfc_directorylist *list,
if (module && !p->use_for_modules)
continue;
- fullname = (char *) alloca(strlen (p->path) + strlen (name) + 1);
+ fullname = (char *) alloca(strlen (p->path) + strlen (name) + 2);
strcpy (fullname, p->path);
+ strcat (fullname, "/");
strcat (fullname, name);
f = gfc_open_file (fullname);
diff --git a/gcc/testsuite/gfortran.dg/include_14.f90 b/gcc/testsuite/gfortran.dg/include_14.f90
index 8110e49bf43..39acf69b1b4 100644
--- a/gcc/testsuite/gfortran.dg/include_14.f90
+++ b/gcc/testsuite/gfortran.dg/include_14.f90
@@ -1,6 +1,6 @@
! { dg-additional-options "-cpp -idirafter /fdaf/ -I bar -J foo/bar" }
end
! default: warn for -I and -J but ignore other options.
-! { dg-warning "Nonexistent include directory 'bar/'" "" { target *-*-* } 0 }
-! { dg-warning "Nonexistent include directory 'foo/bar/'" "" { target *-*-* } 0 }
+! { dg-warning "Nonexistent include directory 'bar'" "" { target *-*-* } 0 }
+! { dg-warning "Nonexistent include directory 'foo/bar'" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/gfortran.dg/include_17.f90 b/gcc/testsuite/gfortran.dg/include_17.f90
index 06677590be3..f09b22f079a 100644
--- a/gcc/testsuite/gfortran.dg/include_17.f90
+++ b/gcc/testsuite/gfortran.dg/include_17.f90
@@ -1,6 +1,6 @@
! { dg-do compile }
! { dg-options "-I foo-bar -J foo/bar" }
end
-! { dg-warning "Nonexistent include directory 'foo-bar/'" "" { target *-*-* } 0 }
-! { dg-warning "Nonexistent include directory 'foo/bar/'" "" { target *-*-* } 0 }
+! { dg-warning "Nonexistent include directory 'foo-bar'" "" { target *-*-* } 0 }
+! { dg-warning "Nonexistent include directory 'foo/bar'" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/gfortran.dg/include_18.f90 b/gcc/testsuite/gfortran.dg/include_18.f90
index b74a585bf1b..7ca0e48f091 100644
--- a/gcc/testsuite/gfortran.dg/include_18.f90
+++ b/gcc/testsuite/gfortran.dg/include_18.f90
@@ -1,5 +1,5 @@
! { dg-do compile }
! { dg-options "-I nothere -J neither/here -Wmissing-include-dirs" }
end
-! { dg-warning "Nonexistent include directory 'nothere/'" "" { target *-*-* } 0 }
-! { dg-warning "Nonexistent include directory 'neither/here/'" "" { target *-*-* } 0 }
+! { dg-warning "Nonexistent include directory 'nothere'" "" { target *-*-* } 0 }
+! { dg-warning "Nonexistent include directory 'neither/here'" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/gfortran.dg/include_6.f90 b/gcc/testsuite/gfortran.dg/include_6.f90
index 3e3be1b7bd5..2cea47390f4 100644
--- a/gcc/testsuite/gfortran.dg/include_6.f90
+++ b/gcc/testsuite/gfortran.dg/include_6.f90
@@ -1,6 +1,6 @@
! { dg-do compile }
! { dg-options "-I gfortran.log" }
-! { dg-warning "Include directory 'gfortran.log/': Not a directory" "" { target *-*-* } 0 }
+! { dg-error "'gfortran.log' is not a directory" "" { target *-*-* } 0 }
! { dg-prune-output "compilation terminated." }
end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-23 15:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23 15:55 [gcc r12-7787] Fortran: Fix directory stat check for '.' [PR103560] Tobias Burnus
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).