In principle, I like the patch. However, I think one should
replace

gfc_error ("Attribute at %L is not allowed in a %s definition",
          …, state_name

by something like:

bool is_type = gfc_current_state () == COMP_DERIVED;
gfc_error (is_type ? G_("Attribute at %L is not allowed in a TYPE definition")
                  : G_("Attribute at %L is not allowed in a STRUCTURE 
definition"),
          …

Reason: (a) This makes translation simpler; e.g. 'structure' and 'type' have
different gender in several European languages. (Albeit in this case the
gender of 'definition' dominates in the cases I checked.)
(b) For TYPE, the string won't change such that the existing translations
still work – even if the update for STRUCTURE won't make it for the release.

Otherwise it looks good to me, including the test case in your follow-up email.

Cheers,

Tobias

On 4/1/20 7:19 PM, Fritz Reese via Fortran wrote:

This simple patch was submitted some time ago (over 1 year), but got
lost without review. I have lately rebased and tested, and the patch
is still good. Is this OK to commit to trunk and for backport? I'd
like to port as far back as 7.

---
Fritz Reese

gcc/ChangeLog:
2020-04-01  Fritz Reese  <fore...@gcc.gnu.org>

        PR fortran/85982
        * fortran/decl.c (match_attr_spec): Lump COMP_STRUCTURE/COMP_MAP into
        attribute checking used by TYPE.

gcc/testsuite/ChangeLog:
2020-04-01  Fritz Reese  <fore...@gcc.gnu.org>

        PR fortran/85982
        * gfortran.dg/dec_structure_28.f90: New test.
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter

Reply via email to