aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2011-08-23 14:13:34 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2011-08-23 14:13:34 +0200
commit0fcbc86b5586c3c3bc370d43b2dea98108fd9796 (patch)
tree116c2a6560f78acac051d2c08b8498111d4cd9b6 /gcc/fortran
parent336ecb6550395820cea7c0bbc13c0b7bb5045e91 (diff)
downloadgcc-0fcbc86b5586c3c3bc370d43b2dea98108fd9796.zip
gcc-0fcbc86b5586c3c3bc370d43b2dea98108fd9796.tar.gz
gcc-0fcbc86b5586c3c3bc370d43b2dea98108fd9796.tar.bz2
re PR fortran/31600 (Better error message for redeclation of USEd symbols)
2011-08-23 Tobias Burnus <burnus@net-b.de> PR fortran/31600 * symbol.c (gfc_add_type): Better diagnostic if redefining use-associated symbol. * module.c (gfc_use_module): Use module name as locus. 2011-08-23 Tobias Burnus <burnus@net-b.de> PR fortran/31600 * gfortran.dg/use_16.f90: New. From-SVN: r177985
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/module.c7
-rw-r--r--gcc/fortran/symbol.c7
3 files changed, 20 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 075c366..80cee08 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2011-08-23 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/31600
+ * symbol.c (gfc_add_type): Better diagnostic if redefining
+ use-associated symbol.
+ * module.c (gfc_use_module): Use module name as locus.
+
2011-08-22 Gabriel Charette <gchare@google.com>
* cpp.c (gfc_cpp_init): Force BUILTINS_LOCATION for tokens
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index aef3404..4250a17 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -5727,6 +5727,9 @@ gfc_use_module (void)
int c, line, start;
gfc_symtree *mod_symtree;
gfc_use_list *use_stmt;
+ locus old_locus = gfc_current_locus;
+
+ gfc_current_locus = use_locus;
filename = (char *) alloca (strlen (module_name) + strlen (MODULE_EXTENSION)
+ 1);
@@ -5748,6 +5751,7 @@ gfc_use_module (void)
"intrinsic module at %C") != FAILURE)
{
use_iso_fortran_env_module ();
+ gfc_current_locus = old_locus;
return;
}
@@ -5756,6 +5760,7 @@ gfc_use_module (void)
"ISO_C_BINDING module at %C") != FAILURE)
{
import_iso_c_binding_module();
+ gfc_current_locus = old_locus;
return;
}
@@ -5845,6 +5850,8 @@ gfc_use_module (void)
gfc_rename_list = NULL;
use_stmt->next = gfc_current_ns->use_stmts;
gfc_current_ns->use_stmts = use_stmt;
+
+ gfc_current_locus = old_locus;
}
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index 4463460..126a52b 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -1672,7 +1672,12 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
if (type != BT_UNKNOWN && !(sym->attr.function && sym->attr.implicit_type))
{
- gfc_error ("Symbol '%s' at %L already has basic type of %s", sym->name,
+ if (sym->attr.use_assoc)
+ gfc_error ("Symbol '%s' at %L conflicts with symbol from module '%s', "
+ "use-associated at %L", sym->name, where, sym->module,
+ &sym->declared_at);
+ else
+ gfc_error ("Symbol '%s' at %L already has basic type of %s", sym->name,
where, gfc_basic_typename (type));
return FAILURE;
}