]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/fortran/module.c
Update copyright years.
[thirdparty/gcc.git] / gcc / fortran / module.c
index 3e1ffedd8ee8c23cb121a42d8b34e92fcf4b6cd8..4487f65eafd252a7111a864ba59ea615a500bcd4 100644 (file)
@@ -1,6 +1,6 @@
 /* Handle modules, which amounts to loading and saving symbols and
    their attendant structures.
-   Copyright (C) 2000-2019 Free Software Foundation, Inc.
+   Copyright (C) 2000-2020 Free Software Foundation, Inc.
    Contributed by Andy Vaught
 
 This file is part of GCC.
@@ -187,6 +187,8 @@ pointer_info;
 /* The gzFile for the module we're reading or writing.  */
 static gzFile module_fp;
 
+/* Fully qualified module path */
+static char *module_fullpath = NULL;
 
 /* The name of the module we're reading (USE'ing) or writing.  */
 static const char *module_name;
@@ -525,6 +527,8 @@ gfc_match_use (void)
   gfc_intrinsic_op op;
   match m;
   gfc_use_list *use_list;
+  gfc_symtree *st;
+  locus loc;
 
   use_list = gfc_get_use_list ();
 
@@ -632,6 +636,8 @@ gfc_match_use (void)
        case INTERFACE_USER_OP:
        case INTERFACE_GENERIC:
        case INTERFACE_DTIO:
+         loc = gfc_current_locus;
+
          m = gfc_match (" =>");
 
          if (type == INTERFACE_USER_OP && m == MATCH_YES
@@ -642,6 +648,18 @@ gfc_match_use (void)
          if (type == INTERFACE_USER_OP)
            new_use->op = INTRINSIC_USER;
 
+         st = gfc_find_symtree (gfc_current_ns->sym_root, name);
+         if (st && type != INTERFACE_USER_OP)
+           {
+             if (m == MATCH_YES)
+               gfc_error ("Symbol %qs at %L conflicts with the rename symbol "
+                          "at %L", name, &st->n.sym->declared_at, &loc);
+             else
+               gfc_error ("Symbol %qs at %L conflicts with the symbol "
+                          "at %L", name, &st->n.sym->declared_at, &loc);
+             goto cleanup;
+           }
+
          if (use_list->only_flag)
            {
              if (m != MATCH_YES)
@@ -1085,6 +1103,8 @@ gzopen_included_file_1 (const char *name, gfc_directorylist *list,
          if (gfc_cpp_makedep ())
            gfc_cpp_add_dep (fullname, system);
 
+        free (module_fullpath);
+        module_fullpath = xstrdup (fullname);
          return f;
        }
     }
@@ -1100,8 +1120,14 @@ gzopen_included_file (const char *name, bool include_cwd, bool module)
   if (IS_ABSOLUTE_PATH (name) || include_cwd)
     {
       f = gzopen (name, "r");
-      if (f && gfc_cpp_makedep ())
-       gfc_cpp_add_dep (name, false);
+      if (f)
+       {
+         if (gfc_cpp_makedep ())
+           gfc_cpp_add_dep (name, false);
+
+         free (module_fullpath);
+         module_fullpath = xstrdup (name);
+       }
     }
 
   if (!f)
@@ -1118,8 +1144,14 @@ gzopen_intrinsic_module (const char* name)
   if (IS_ABSOLUTE_PATH (name))
     {
       f = gzopen (name, "r");
-      if (f && gfc_cpp_makedep ())
-        gfc_cpp_add_dep (name, true);
+      if (f)
+       {
+         if (gfc_cpp_makedep ())
+           gfc_cpp_add_dep (name, true);
+
+         free (module_fullpath);
+         module_fullpath = xstrdup (name);
+       }
     }
 
   if (!f)
@@ -1165,7 +1197,7 @@ bad_module (const char *msgid)
     {
     case IO_INPUT:
       gfc_fatal_error ("Reading module %qs at line %d column %d: %s",
-                      module_name, module_line, module_column, msgid);
+                      module_fullpath, module_line, module_column, msgid);
       break;
     case IO_OUTPUT:
       gfc_fatal_error ("Writing module %qs at line %d column %d: %s",
@@ -3311,7 +3343,7 @@ mio_gmp_integer (mpz_t *integer)
 static void
 mio_gmp_real (mpfr_t *real)
 {
-  mp_exp_t exponent;
+  mpfr_exp_t exponent;
   char *p;
 
   if (iomode == IO_INPUT)
@@ -4729,7 +4761,7 @@ load_commons (void)
 
   while (peek_atom () != ATOM_RPAREN)
     {
-      int flags;
+      int flags = 0;
       char* label;
       mio_lparen ();
       mio_internal_string (name);
@@ -5227,8 +5259,8 @@ read_module (void)
          for (c = sym->components; c; c = c->next)
            {
              pointer_info *p;
-             const char *comp_name;
-             int n;
+             const char *comp_name = NULL;
+             int n = 0;
 
              mio_lparen (); /* component opening.  */
              mio_integer (&n);
@@ -6052,6 +6084,9 @@ write_module (void)
 {
   int i;
 
+  /* Initialize the column counter. */
+  module_column = 1;
+  
   /* Write the operator interfaces.  */
   mio_lparen ();
 
@@ -7122,7 +7157,7 @@ gfc_use_module (gfc_use_list *module)
       if ((start == 1 && strcmp (atom_name, "GFORTRAN") != 0)
          || (start == 2 && strcmp (atom_name, " module") != 0))
        gfc_fatal_error ("File %qs opened at %C is not a GNU Fortran"
-                        " module file", filename);
+                        " module file", module_fullpath);
       if (start == 3)
        {
          if (strcmp (atom_name, " version") != 0
@@ -7131,7 +7166,7 @@ gfc_use_module (gfc_use_list *module)
              || strcmp (atom_string, MOD_VERSION))
            gfc_fatal_error ("Cannot read module file %qs opened at %C,"
                             " because it was created by a different"
-                            " version of GNU Fortran", filename);
+                            " version of GNU Fortran", module_fullpath);
 
          free (atom_string);
        }