Tobias Burnus - [Fortran, patch] Disallow character(*) dummy arguments with VALUE attri (original) (raw)
This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
- From: Tobias Burnus
- To: "'fortran at gcc dot gnu dot org'" , gcc-patches
- Date: Wed, 14 Feb 2007 09:51:45 +0100
- Subject: [Fortran, patch] Disallow character(*) dummy arguments with VALUE attribute (PR30783)
:ADDPATCH fortran:
As found when reading the VALUE implementation by Chris.
gfortran currently accepts "character(*), value", but it shouldn't:
a) the created programs crash
b) the standard disallows it: C528 (R501) If the VALUE attribute is specified, the length type parameter values shall be omitted or specified by initialization expressions.
The question is whether "character(10), value" is allowed. xlf, NAG f95 and sunf95 reject it; gfortran, g95 and ifort accept it.
I couldn't find anything which disallows "(10)" and as gfortran produces the right result (both visually and according to valgrind), I think one can allow it. (g95 and ifort both produce wrong code; ifort crashes with SIGILL and g95 prints out only the first letter correctly [and valgrind complains about access to uninitialized memory].)
I didn't add a test case, if needed I could create one from my PR30783 example.
Bootstrapped and regression tested on x86_64-unknown-linux-gnu.
Ok for the trunk (only as it is not in 4.2)?
Tobias
2007-02-13 Tobias Burnus burnus@net-b.de
PR fortran/30783
- resolve.c (resolve_symbol): Add character dummy VALUE check.
Index: gcc/fortran/resolve.c
--- gcc/fortran/resolve.c (Revision 121891) +++ gcc/fortran/resolve.c (Arbeitskopie) @@ -6157,6 +6157,18 @@ return; }
- if (sym->attr.value && sym->ts.type == BT_CHARACTER)
- {
gfc_charlen *cl = sym->ts.cl;
if (!cl || !cl->length || cl->length->expr_type != EXPR_CONSTANT)
- {
gfc_error ("Character dummy variable '%s' at %L with VALUE "
"attribute must have constant length",
sym->name, &sym->declared_at);
return;
- }
- }
- /* If a derived type symbol has reached this point, without its type being declared, we have an error. Notice that most conditions that produce undefined derived types have already
- Follow-Ups:
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |