aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index df81369..d3ddda2 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -1215,10 +1215,38 @@ build_sym (const char *name, gfc_charlen *cl, bool cl_deferred,
{
symbol_attribute attr;
gfc_symbol *sym;
+ int upper;
if (gfc_get_symbol (name, NULL, &sym))
return false;
+ /* Check if the name has already been defined as a type. The
+ first letter of the symtree will be in upper case then. Of
+ course, this is only necessary if the upper case letter is
+ actually different. */
+
+ upper = TOUPPER(name[0]);
+ if (upper != name[0])
+ {
+ char u_name[GFC_MAX_SYMBOL_LEN + 1];
+ gfc_symtree *st;
+ int nlen;
+
+ nlen = strlen(name);
+ gcc_assert (nlen <= GFC_MAX_SYMBOL_LEN);
+ strncpy (u_name, name, nlen + 1);
+ u_name[0] = upper;
+
+ st = gfc_find_symtree (gfc_current_ns->sym_root, u_name);
+
+ if (st != 0)
+ {
+ gfc_error ("Symbol %qs at %C also declared as a type at %L", name,
+ &st->n.sym->declared_at);
+ return false;
+ }
+ }
+
/* Start updating the symbol table. Add basic type attribute if present. */
if (current_ts.type != BT_UNKNOWN
&& (sym->attr.implicit_type == 0