|
|
840d93 |
From f96f2f273741ea19311c6e7a6f556c09b6ff9415 Mon Sep 17 00:00:00 2001
|
|
|
840d93 |
From: Mark Doffman <mark.doffman@codethink.co.uk>
|
|
|
840d93 |
Date: Tue, 23 Jun 2015 22:59:08 +0000
|
|
|
840d93 |
Subject: [PATCH 01/23] Allow repeated compatible type specifications.
|
|
|
840d93 |
|
|
|
840d93 |
Add a check to see if a repeated type specification is compatible
|
|
|
840d93 |
with the previous specification. Only create an error on incompatible
|
|
|
840d93 |
type specifications for the same symbol.
|
|
|
840d93 |
|
|
|
840d93 |
Some fixes by Jim MacArthur <jim.macarthur@codethink.co.uk>
|
|
|
840d93 |
---
|
|
|
840d93 |
|
|
|
840d93 |
0001-Allow-repeated-compatible-type-specifications.patch
|
|
|
840d93 |
|
|
|
840d93 |
0015-Allow-redefinition-of-types-for-procedures.patch
|
|
|
840d93 |
|
|
|
840d93 |
0021-Correct-internal-fault-in-select_type_9.f90.patch
|
|
|
840d93 |
|
|
|
840d93 |
|
|
|
840d93 |
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
|
|
|
840d93 |
index ec43e63..67ad504 100644
|
|
|
840d93 |
--- a/gcc/fortran/symbol.c
|
|
|
840d93 |
+++ b/gcc/fortran/symbol.c
|
|
|
840d93 |
@@ -1877,6 +1877,8 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
|
|
|
840d93 |
if (sym->attr.result && type == BT_UNKNOWN && sym->ns->proc_name)
|
|
|
840d93 |
type = sym->ns->proc_name->ts.type;
|
|
|
840d93 |
|
|
|
840d93 |
+ flavor = sym->attr.flavor;
|
|
|
840d93 |
+
|
|
|
840d93 |
if (type != BT_UNKNOWN && !(sym->attr.function && sym->attr.implicit_type)
|
|
|
840d93 |
&& !(gfc_state_stack->previous && gfc_state_stack->previous->previous
|
|
|
840d93 |
&& gfc_state_stack->previous->previous->state == COMP_SUBMODULE)
|
|
|
840d93 |
@@ -1886,6 +1888,20 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
|
|
|
840d93 |
gfc_error ("Symbol %qs at %L conflicts with symbol from module %qs, "
|
|
|
840d93 |
"use-associated at %L", sym->name, where, sym->module,
|
|
|
840d93 |
&sym->declared_at);
|
|
|
840d93 |
+ else if (gfc_option.allow_std & GFC_STD_EXTRA_LEGACY)
|
|
|
840d93 |
+ {
|
|
|
840d93 |
+ /* Ignore temporaries and class/procedure names */
|
|
|
840d93 |
+ if (sym->ts.type == BT_DERIVED || sym->ts.type == BT_CLASS || sym->ts.type == BT_PROCEDURE)
|
|
|
840d93 |
+ return false;
|
|
|
840d93 |
+
|
|
|
840d93 |
+ if (gfc_compare_types (&sym->ts, ts)
|
|
|
840d93 |
+ && (flavor == FL_UNKNOWN || flavor == FL_VARIABLE || flavor == FL_PROCEDURE))
|
|
|
840d93 |
+ {
|
|
|
840d93 |
+ return gfc_notify_std (GFC_STD_LEGACY,
|
|
|
840d93 |
+ "Symbol '%qs' at %L already has basic type of %s", sym->name,
|
|
|
840d93 |
+ where, gfc_basic_typename (type));
|
|
|
840d93 |
+ }
|
|
|
840d93 |
+ }
|
|
|
840d93 |
else
|
|
|
840d93 |
gfc_error ("Symbol %qs at %L already has basic type of %s", sym->name,
|
|
|
840d93 |
where, gfc_basic_typename (type));
|
|
|
840d93 |
@@ -1899,8 +1915,6 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
|
|
|
840d93 |
return false;
|
|
|
840d93 |
}
|
|
|
840d93 |
|
|
|
840d93 |
- flavor = sym->attr.flavor;
|
|
|
840d93 |
-
|
|
|
840d93 |
if (flavor == FL_PROGRAM || flavor == FL_BLOCK_DATA || flavor == FL_MODULE
|
|
|
840d93 |
|| flavor == FL_LABEL
|
|
|
840d93 |
|| (flavor == FL_PROCEDURE && sym->attr.subroutine)
|
|
|
840d93 |
diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_4.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_4.f90
|
|
|
840d93 |
new file mode 100644
|
|
|
840d93 |
index 0000000..cdd29ea
|
|
|
840d93 |
--- /dev/null
|
|
|
840d93 |
+++ b/gcc/testsuite/gfortran.dg/duplicate_type_4.f90
|
|
|
840d93 |
@@ -0,0 +1,13 @@
|
|
|
840d93 |
+! { dg-do compile }
|
|
|
840d93 |
+! { dg-options "-std=f95" }
|
|
|
840d93 |
+
|
|
|
840d93 |
+! PR fortran/30239
|
|
|
840d93 |
+! Check for errors when a symbol gets declared a type twice, even if it
|
|
|
840d93 |
+! is the same.
|
|
|
840d93 |
+
|
|
|
840d93 |
+INTEGER FUNCTION foo ()
|
|
|
840d93 |
+ IMPLICIT NONE
|
|
|
840d93 |
+ INTEGER :: x
|
|
|
840d93 |
+ INTEGER :: x ! { dg-error "basic type of" }
|
|
|
840d93 |
+ x = 42
|
|
|
840d93 |
+END FUNCTION foo
|