public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/96038] New: Confirming implicitly type parameter causes an invalid error
@ 2020-07-02 19:48 kargl at gcc dot gnu.org
  2020-07-02 19:49 ` [Bug fortran/96038] " kargl at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-07-02 19:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96038

            Bug ID: 96038
           Summary: Confirming implicitly type parameter causes an invalid
                    error
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kargl at gcc dot gnu.org
  Target Milestone: ---

Consider the following fixed-form source code:

      function ifoo()
      parameter (n = 50)
      integer n
      ifoo = n
      end

Everything is implicitly type.  Gfortran gives

      function ifoo()
      parameter (n = 50)
      integer n
      ifoo = n
      end

% gfortran -c a.f
a.f:3:15:

    3 |       integer n
      |               1
Error: PARAMETER at (1) is missing an initializer

which is wrong.  The code should compile as an implicitly type
entity can appear in a declaration statement if that declaration
statement confirms the implicit type.

The patch is straight forward.  This is against svn revision 280156.
The patch has not been regression tested.

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c  (revision 280157)
+++ gcc/fortran/decl.c  (working copy)
@@ -1864,13 +1864,16 @@ add_init_expr_to_sym (const char *name, gfc_expr **ini

   /* If this symbol is confirming an implicit parameter type,
      then an initialization expression is not allowed.  */
-  if (attr.flavor == FL_PARAMETER
-      && sym->value != NULL
-      && *initp != NULL)
+  if (attr.flavor == FL_PARAMETER && sym->value != NULL)
     {
-      gfc_error ("Initializer not allowed for PARAMETER %qs at %C",
-                sym->name);
-      return false;
+      if (*initp != NULL)
+       {
+         gfc_error ("Initializer not allowed for PARAMETER %qs at %C",
+                    sym->name);
+         return false;
+       }
+      else
+       return true;
     }

   if (init == NULL)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/96038] Confirming implicitly type parameter causes an invalid error
  2020-07-02 19:48 [Bug fortran/96038] New: Confirming implicitly type parameter causes an invalid error kargl at gcc dot gnu.org
@ 2020-07-02 19:49 ` kargl at gcc dot gnu.org
  2020-07-14  7:41 ` cvs-commit at gcc dot gnu.org
  2020-07-14  8:01 ` markeggleston at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-07-02 19:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96038

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-07-02
     Ever confirmed|0                           |1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/96038] Confirming implicitly type parameter causes an invalid error
  2020-07-02 19:48 [Bug fortran/96038] New: Confirming implicitly type parameter causes an invalid error kargl at gcc dot gnu.org
  2020-07-02 19:49 ` [Bug fortran/96038] " kargl at gcc dot gnu.org
@ 2020-07-14  7:41 ` cvs-commit at gcc dot gnu.org
  2020-07-14  8:01 ` markeggleston at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-14  7:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96038

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Mark Eggleston
<markeggleston@gcc.gnu.org>:

https://gcc.gnu.org/g:9ad19a66d751ab48515ef61f830e192ae4078b93

commit r11-2075-g9ad19a66d751ab48515ef61f830e192ae4078b93
Author: Mark Eggleston <markeggleston@gcc.gnu.org>
Date:   Mon Jul 6 07:14:59 2020 +0100

    Fortran  : Implicitly type parameter causes an invalid error PR96038

    If a paramter to declared and initialised before its type is
    declared a bogus error is output at the type declaration
    idicating that initialisation is missing.

    2020-07-14  Steven G. Kargl  <kargl@gcc.gnu.org>

    gcc/fortran/

            PR fortran/96038
            * decl.c (add_init_expr_sym):  For a symbol that is a
            parameter accept an initialisation if it does not have a
            value otherwise output a error and reject.

    2020-07-14  Mark Eggleston  <markeggleston@gcc.gnu.org>

    gcc/testsuite/

            PR fortran/96038
            * gfortran.dg/pr96038.f90: New test.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/96038] Confirming implicitly type parameter causes an invalid error
  2020-07-02 19:48 [Bug fortran/96038] New: Confirming implicitly type parameter causes an invalid error kargl at gcc dot gnu.org
  2020-07-02 19:49 ` [Bug fortran/96038] " kargl at gcc dot gnu.org
  2020-07-14  7:41 ` cvs-commit at gcc dot gnu.org
@ 2020-07-14  8:01 ` markeggleston at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: markeggleston at gcc dot gnu.org @ 2020-07-14  8:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96038

markeggleston at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
                 CC|                            |markeggleston at gcc dot gnu.org

--- Comment #2 from markeggleston at gcc dot gnu.org ---
committed to master

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-14  8:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02 19:48 [Bug fortran/96038] New: Confirming implicitly type parameter causes an invalid error kargl at gcc dot gnu.org
2020-07-02 19:49 ` [Bug fortran/96038] " kargl at gcc dot gnu.org
2020-07-14  7:41 ` cvs-commit at gcc dot gnu.org
2020-07-14  8:01 ` markeggleston at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).