Bug 32633 - bogus error
Summary: bogus error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Daniel Franke
URL:
Keywords: rejects-valid
Depends on:
Blocks: 29975
  Show dependency treegraph
 
Reported: 2007-07-05 14:38 UTC by Joost VandeVondele
Modified: 2007-07-06 12:52 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.0
Known to fail: 4.3.0
Last reconfirmed: 2007-07-05 15:03:43


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2007-07-05 14:38:52 UTC
MODULE test
  IMPLICIT NONE
  CHARACTER(len=1), PARAMETER :: backslash = '\\'
  PUBLIC :: backslash
END MODULE

> gfortran  test.f90
test.f90:4.21:

  PUBLIC :: backslash
                    1
Error: PARAMETER attribute conflicts with SAVE attribute in 'backslash' at (1)
Comment 1 Daniel Franke 2007-07-05 14:56:59 UTC
Haven't updated yet, but ...

symbol.c(check_conflict):493:
  [...]
  switch (attr->flavor)
    case FL_PARAMETER:
      conf2 (save);
  [...]

with
  #define conf2(a) if (attr->a) { a2 = a; goto conflict; }

should probably be 
  if (attr->flavor == FL_PARAMETER && attr->save == SAVE_EXPLICIT)

instead.
Comment 2 Daniel Franke 2007-07-05 15:03:43 UTC
Testing patch ...
Comment 3 Daniel Franke 2007-07-05 15:09:57 UTC
The patch below fixes the current problem. There are other checks against attrib->save in check_conflict() which might trigger the same problem. I'll have a closer later this evening. 

Index: symbol.c
===================================================================
--- symbol.c    (revision 126369)
+++ symbol.c    (working copy)
@@ -630,12 +630,17 @@
       conf2 (target);
       conf2 (dummy);
       conf2 (in_common);
-      conf2 (save);
       conf2 (value);
       conf2 (volatile_);
       conf2 (threadprivate);
       /* TODO: hmm, double check this.  */
       conf2 (value);
+
+      if (attr->save == SAVE_EXPLICIT)
+       {
+         a2 = save;
+         goto conflict;
+       }
       break;

     default:
Comment 4 Francois-Xavier Coudert 2007-07-05 16:11:05 UTC
(In reply to comment #3)
> The patch below fixes the current problem. There are other checks against
> attrib->save in check_conflict() which might trigger the same problem. I'll
> have a closer later this evening.

This patch is OK to commit. Please review all other uses of attr->save (in check_conflict() and possibly in other functions and files) for this type of error. I'm sorry that I wasn't able to spot that possible issue during my review of your patch :(
Comment 5 patchapp@dberlin.org 2007-07-05 21:15:27 UTC
Subject: Bug number PR32633

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-07/msg00511.html
Comment 6 Daniel Franke 2007-07-06 12:37:36 UTC
Subject: Bug 32633

Author: dfranke
Date: Fri Jul  6 12:37:22 2007
New Revision: 126413

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126413
Log:
gcc/fortran:
2007-05-06  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/32633
        * symbol.c (save_status): New.
        * gfortran.h (save_status): Added external declaration.
        (check_conflict): Check for conflicting explicite SAVE statements
        only.
        (gen_special_c_interop_ptr): Use SAVE_EXPLICIT constant.
        * module.c (ab_attribute, attr_bits): Removed enumerator value 
	AB_SAVE for save attribute.
        (mio_symbol_attribute): Import/export the full SAVE status,
        removed usage of AB_SAVE.
        * dump-parse-tree.c (gfc_show_attr): Dump full SAVE status.
        * decl.c (add_init_expr_to_sym): Set SAVE_IMPLICIT only if not
        already explicit.

gcc/testsuite:
2007-07-06  Daniel Franke  <franke.daniel@gmail.com>

        * gfortran.dg/save_parameter.f90: New test.
        * gfortran.dg/module_md5_1.f90: Updated MD5 sum.


Added:
    trunk/gcc/testsuite/gfortran.dg/save_parameter.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/dump-parse-tree.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/module.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/module_md5_1.f90

Comment 7 Daniel Franke 2007-07-06 12:52:07 UTC
Joost, thanks for reporting!
Closing as fixed.