aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2008-11-03 08:20:24 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2008-11-03 08:20:24 +0100
commit0ee1b105a36031f53b989f42f7bb38fc8f2c17be (patch)
tree98fad3e4de24661c6a6e73acd3e7e4f5eb096157 /gcc
parent67cec813c625940ddf829c57f4bfd1c14fd7e563 (diff)
downloadgcc-0ee1b105a36031f53b989f42f7bb38fc8f2c17be.zip
gcc-0ee1b105a36031f53b989f42f7bb38fc8f2c17be.tar.gz
gcc-0ee1b105a36031f53b989f42f7bb38fc8f2c17be.tar.bz2
re PR fortran/37821 (gfortran is ignoring #includes with the syntax <file.h>)
2008-11-03 Tobias Burnus <burnus@net-b.de> PR fortran/37821 * cpp.c (gfc_cpp_add_include_path): Use BRACKET. * scanner.c (add_path_to_list): Argument to add at head. (gfc_add_include_path): Add new argument. (gfc_add_intrinsic_modules_path) Update call. (load_file): Print filename/line in the error message. * gfortran.h (gfc_add_include_path): Update prototype. * options.c (gfc_post_options,gfc_handle_module_path_options, gfc_handle_option): Update call. * lang-spec.h (F951_OPTIONS): Don't insert include path twice. * arith.c (arith_error): Add -fno-range-error to the message. 2008-11-03 Tobias Burnus <burnus@net-b.de> PR fortran/37821 * gfortran.dg/include_4.f90: New. * gfortran.dg/include_5.f90: New. * gfortran.dg/include_4.inc: New. From-SVN: r141544
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog15
-rw-r--r--gcc/fortran/arith.c6
-rw-r--r--gcc/fortran/cpp.c3
-rw-r--r--gcc/fortran/gfortran.h2
-rw-r--r--gcc/fortran/lang-specs.h2
-rw-r--r--gcc/fortran/options.c10
-rw-r--r--gcc/fortran/scanner.c34
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gfortran.dg/include_4.f9012
-rw-r--r--gcc/testsuite/gfortran.dg/include_4.inc4
-rw-r--r--gcc/testsuite/gfortran.dg/include_5.f9018
11 files changed, 91 insertions, 22 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 9017b79..ec83b16 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,18 @@
+2008-11-03 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/37821
+ * cpp.c (gfc_cpp_add_include_path): Use BRACKET.
+ * scanner.c (add_path_to_list): Argument to add at head.
+ (gfc_add_include_path): Add new argument.
+ (gfc_add_intrinsic_modules_path) Update call.
+ (load_file): Print filename/line in the error message.
+ * gfortran.h (gfc_add_include_path): Update prototype.
+ * options.c (gfc_post_options,gfc_handle_module_path_options,
+ gfc_handle_option): Update call.
+ * lang-spec.h (F951_OPTIONS): Don't insert include path twice.
+
+ * arith.c (arith_error): Add -fno-range-error to the message.
+
2008-11-03 Paul Thomas <pault@gcc.gnu.org>
PR fortran/37445
diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c
index 2ef34b1..c56be03 100644
--- a/gcc/fortran/arith.c
+++ b/gcc/fortran/arith.c
@@ -2065,11 +2065,13 @@ arith_error (arith rc, gfc_typespec *from, gfc_typespec *to, locus *where)
gfc_typename (from), gfc_typename (to), where);
break;
case ARITH_UNDERFLOW:
- gfc_error ("Arithmetic underflow converting %s to %s at %L",
+ gfc_error ("Arithmetic underflow converting %s to %s at %L. This check "
+ "can be disabled with the option -fno-range-check",
gfc_typename (from), gfc_typename (to), where);
break;
case ARITH_NAN:
- gfc_error ("Arithmetic NaN converting %s to %s at %L",
+ gfc_error ("Arithmetic NaN converting %s to %s at %L. This check "
+ "can be disabled with the option -fno-range-check",
gfc_typename (from), gfc_typename (to), where);
break;
case ARITH_DIV0:
diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c
index 86e0335..51c8e85 100644
--- a/gcc/fortran/cpp.c
+++ b/gcc/fortran/cpp.c
@@ -628,10 +628,9 @@ gfc_cpp_add_include_path (char *path, bool user_supplied)
{
/* CHAIN sets cpp_dir->sysp which differs from 0 if PATH is a system
include path. Fortran does not define any system include paths. */
- int chain = 0;
int cxx_aware = 0;
- add_path (path, chain, cxx_aware, user_supplied);
+ add_path (path, BRACKET, cxx_aware, user_supplied);
}
void
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 9ac6f3c..174e9af 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2093,7 +2093,7 @@ bool gfc_in_match_data (void);
void gfc_scanner_done_1 (void);
void gfc_scanner_init_1 (void);
-void gfc_add_include_path (const char *, bool);
+void gfc_add_include_path (const char *, bool, bool);
void gfc_add_intrinsic_modules_path (const char *);
void gfc_release_include_path (void);
FILE *gfc_open_included_file (const char *, bool, bool);
diff --git a/gcc/fortran/lang-specs.h b/gcc/fortran/lang-specs.h
index e4bd050..a766162 100644
--- a/gcc/fortran/lang-specs.h
+++ b/gcc/fortran/lang-specs.h
@@ -23,7 +23,7 @@
#define F951_CPP_OPTIONS "%{!nocpp: -cpp %g.f90 %(cpp_options)\
%{E|M|MM:%(cpp_debug_options) -fsyntax-only} %{E}}"
-#define F951_OPTIONS "%(cc1_options) %{J*} %{I*}\
+#define F951_OPTIONS "%(cc1_options) %{J*} %{!cpp: %{I*}}\
%{!nostdinc:-fintrinsic-modules-path finclude%s}\
%{!fsyntax-only:%(invoke_as)}"
#define F951_SOURCE_FORM "%{!ffree-form:-ffixed-form}"
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 3f49d56..7a800ce 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -265,10 +265,10 @@ gfc_post_options (const char **pfilename)
source_path = (char *) alloca (i + 1);
memcpy (source_path, canon_source_file, i);
source_path[i] = 0;
- gfc_add_include_path (source_path, true);
+ gfc_add_include_path (source_path, true, true);
}
else
- gfc_add_include_path (".", true);
+ gfc_add_include_path (".", true, true);
if (canon_source_file != gfc_source_file)
gfc_free (CONST_CAST (char *, canon_source_file));
@@ -407,7 +407,7 @@ gfc_handle_module_path_options (const char *arg)
strcpy (gfc_option.module_dir, arg);
strcat (gfc_option.module_dir, "/");
- gfc_add_include_path (gfc_option.module_dir, true);
+ gfc_add_include_path (gfc_option.module_dir, true, false);
}
@@ -639,7 +639,7 @@ gfc_handle_option (size_t scode, const char *arg, int value)
break;
case OPT_fintrinsic_modules_path:
- gfc_add_include_path (arg, false);
+ gfc_add_include_path (arg, false, false);
gfc_add_intrinsic_modules_path (arg);
break;
@@ -744,7 +744,7 @@ gfc_handle_option (size_t scode, const char *arg, int value)
break;
case OPT_I:
- gfc_add_include_path (arg, true);
+ gfc_add_include_path (arg, true, false);
break;
case OPT_J:
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index 8c702ca..c45827f 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -307,7 +307,7 @@ gfc_scanner_done_1 (void)
static void
add_path_to_list (gfc_directorylist **list, const char *path,
- bool use_for_modules)
+ bool use_for_modules, bool head)
{
gfc_directorylist *dir;
const char *p;
@@ -317,11 +317,15 @@ add_path_to_list (gfc_directorylist **list, const char *path,
if (*p++ == '\0')
return;
- dir = *list;
- if (!dir)
- dir = *list = XCNEW (gfc_directorylist);
+ if (head || *list == NULL)
+ {
+ dir = XCNEW (gfc_directorylist);
+ if (!head)
+ *list = dir;
+ }
else
{
+ dir = *list;
while (dir->next)
dir = dir->next;
@@ -329,7 +333,9 @@ add_path_to_list (gfc_directorylist **list, const char *path,
dir = dir->next;
}
- dir->next = NULL;
+ dir->next = head ? *list : NULL;
+ if (head)
+ *list = dir;
dir->use_for_modules = use_for_modules;
dir->path = XCNEWVEC (char, strlen (p) + 2);
strcpy (dir->path, p);
@@ -338,17 +344,20 @@ add_path_to_list (gfc_directorylist **list, const char *path,
void
-gfc_add_include_path (const char *path, bool use_for_modules)
+gfc_add_include_path (const char *path, bool use_for_modules, bool file_dir)
{
- add_path_to_list (&include_dirs, path, use_for_modules);
- gfc_cpp_add_include_path (xstrdup(path), true);
+ add_path_to_list (&include_dirs, path, use_for_modules, file_dir);
+
+ /* For '#include "..."' these directories are automatically searched. */
+ if (!file_dir)
+ gfc_cpp_add_include_path (xstrdup(path), true);
}
void
gfc_add_intrinsic_modules_path (const char *path)
{
- add_path_to_list (&intrinsic_modules_dirs, path, true);
+ add_path_to_list (&intrinsic_modules_dirs, path, true, false);
}
@@ -1767,7 +1776,9 @@ load_file (const char *realfilename, const char *displayedname, bool initial)
for (f = current_file; f; f = f->up)
if (strcmp (filename, f->filename) == 0)
{
- gfc_error_now ("File '%s' is being included recursively", filename);
+ fprintf (stderr, "%s:%d: Error: File '%s' is being included "
+ "recursively\n", current_file->filename, current_file->line,
+ filename);
return FAILURE;
}
@@ -1791,7 +1802,8 @@ load_file (const char *realfilename, const char *displayedname, bool initial)
input = gfc_open_included_file (realfilename, false, false);
if (input == NULL)
{
- gfc_error_now ("Can't open included file '%s'", filename);
+ fprintf (stderr, "%s:%d: Error: Can't open included file '%s'\n",
+ current_file->filename, current_file->line, filename);
return FAILURE;
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7609084..f568e4e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2008-11-03 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/37821
+ * gfortran.dg/include_4.f90: New.
+ * gfortran.dg/include_5.f90: New.
+ * gfortran.dg/include_4.inc: New.
+
2008-11-03 Paul Thomas <pault@gcc.gnu.org>
PR fortran/37445
diff --git a/gcc/testsuite/gfortran.dg/include_4.f90 b/gcc/testsuite/gfortran.dg/include_4.f90
new file mode 100644
index 0000000..cf1efb1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/include_4.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+!
+! PR fortran/37821
+!
+! Ensure that for #include "..." and for include the
+! current directory/directory of the source file is
+! included. See also include_5.f90
+
+subroutine one()
+ include "include_4.inc"
+ integer(i4) :: i
+end subroutine one
diff --git a/gcc/testsuite/gfortran.dg/include_4.inc b/gcc/testsuite/gfortran.dg/include_4.inc
new file mode 100644
index 0000000..37b6467
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/include_4.inc
@@ -0,0 +1,4 @@
+! Used by include_4.f90 and include_5.f90
+! PR fortran/37821
+!
+integer, parameter :: i4 = 4
diff --git a/gcc/testsuite/gfortran.dg/include_5.f90 b/gcc/testsuite/gfortran.dg/include_5.f90
new file mode 100644
index 0000000..2bfd2bb
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/include_5.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-cpp" }
+!
+! PR fortran/37821
+!
+! Ensure that for #include "..." and for include the
+! current directory/directory of the source file is
+! included.
+
+subroutine one()
+ include "include_4.inc"
+ integer(i4) :: i
+end subroutine one
+
+subroutine two()
+# include "include_4.inc"
+ integer(i4) :: i
+end subroutine two