diff options
author | Tobias Burnus <burnus@net-b.de> | 2008-11-03 08:20:24 +0100 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2008-11-03 08:20:24 +0100 |
commit | 0ee1b105a36031f53b989f42f7bb38fc8f2c17be (patch) | |
tree | 98fad3e4de24661c6a6e73acd3e7e4f5eb096157 /gcc/fortran/scanner.c | |
parent | 67cec813c625940ddf829c57f4bfd1c14fd7e563 (diff) | |
download | gcc-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/fortran/scanner.c')
-rw-r--r-- | gcc/fortran/scanner.c | 34 |
1 files changed, 23 insertions, 11 deletions
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; } } |