This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

Re: [fortran, patch] Fix conflict detesction for VOLATILE attribute (PR30520)


Hi Brooks,

Brooks Moses wrote:
> A few comments on this, mostly on wording in the comments and error
> messages:
Thanks for checking.

> I think this might also be somewhat clearer, both in the code and in
> the error message, if it was broken apart into one check for an
> assumed-shape actual argument and a second check for an array-section
> actual argument.
I split them now in two parts.

> Either your indentation or your parentheses are incorrect here
The spacing was only semi-correct: some tabs where missing; I checked,
but seemingly I was missing some. (I really need an editor which shows
tabs. Has anyone a vim syntax file which does this?)

> I think I would suggest wording that as "Pointer-array actual argument
> at %L requires an assumed-shape or pointer-array dummy argument".
Changed.

>> !   /* No check_used needed as 11.2.1 of the F2003 standard allows
>> !      that the local identifier, made accessible by a use statment,
>> can be
>> !      given a VOLATILE attribute.  */
>
> s/accessible/accessable/
I left the version with -i- as I couldn't find the version with -a- in MW:
http://www.m-w.com/dictionary/accessible
http://www.m-w.com/dictionary/accessable

> Also, I think that would be better without the commas.
Ah, the fruitful/-less discussion about commas in English; well, I now
removed the commas.

New version attached.

Tobias

2007-01-21  Tobias Burnus  <burnus@net-b.de>

    PR fortran/30520
    * interface.c (compare_actual_formal): Check conformance between
    actual and VOLATILE dummy arguments.
    * symbol.c (gfc_add_volatile): Allow setting of VOLATILE
    multiple times in different scopes.
    * decl.c (gfc_match_volatile): Search symbol in host association.

2007-01-21  Tobias Burnus  <burnus@net-b.de>

    PR fortran/30520
    * gfortran.dg/volatile8.f90: New argument conformance test.
    * gfortran.dg/volatile9.f90: New scope test.

Index: gcc/fortran/interface.c
===================================================================
*** gcc/fortran/interface.c	(Revision 121033)
--- gcc/fortran/interface.c	(Arbeitskopie)
*************** compare_actual_formal (gfc_actual_arglis
*** 1417,1422 ****
--- 1417,1470 ----
  	  return 0;
  	}
  
+       /* C1232 (R1221) For an actual argument which is an array section or
+ 	 an assumed-shape array, the dummy argument shall be an assumed-
+ 	 shape array, if the dummy argument has the VOLATILE attribute.  */
+ 
+       if (f->sym->attr.volatile_
+ 	  && a->expr->symtree->n.sym->as
+ 	  && a->expr->symtree->n.sym->as->type == AS_ASSUMED_SHAPE
+ 	  && !(f->sym->as && f->sym->as->type == AS_ASSUMED_SHAPE))
+ 	{
+ 	  if (where)
+ 	    gfc_error ("Assumed-shape actual argument at %L is "
+ 		       "incompatible with the non-assumed-shape "
+ 		       "dummy argument '%s' due to VOLATILE attribute",
+ 		       &a->expr->where,f->sym->name);
+ 	  return 0;
+ 	}
+ 
+       if (f->sym->attr.volatile_
+ 	  && a->expr->ref && a->expr->ref->u.ar.type == AR_SECTION
+ 	  && !(f->sym->as && f->sym->as->type == AS_ASSUMED_SHAPE))
+ 	{
+ 	  if (where)
+ 	    gfc_error ("Array-section actual argument at %L is "
+ 		       "incompatible with the non-assumed-shape "
+ 		       "dummy argument '%s' due to VOLATILE attribute",
+ 		       &a->expr->where,f->sym->name);
+ 	  return 0;
+ 	}
+ 
+       /* C1233 (R1221) For an actual argument which is a pointer array, the
+ 	 dummy argument shall be an assumed-shape or pointer array, if the
+ 	 dummy argument has the VOLATILE attribute.  */
+ 
+       if (f->sym->attr.volatile_
+ 	  && a->expr->symtree->n.sym->attr.pointer
+ 	  && a->expr->symtree->n.sym->as
+ 	  && !(f->sym->as
+ 	       && (f->sym->as->type == AS_ASSUMED_SHAPE
+ 		   || f->sym->attr.pointer)))
+ 	{
+ 	  if (where)
+ 	    gfc_error ("Pointer-array actual argument at %L requires "
+ 		       "an assumed-shape or pointer-array dummy "
+ 		       "argument '%s' due to VOLATILE attribute",
+ 		       &a->expr->where,f->sym->name);
+ 	  return 0;
+ 	}
+ 
      match:
        if (a == actual)
  	na = i;
Index: gcc/fortran/symbol.c
===================================================================
*** gcc/fortran/symbol.c	(Revision 121033)
--- gcc/fortran/symbol.c	(Arbeitskopie)
*************** try
*** 877,886 ****
  gfc_add_volatile (symbol_attribute * attr, const char *name, locus * where)
  {
  
!   if (check_used (attr, name, where))
!     return FAILURE;
! 
!   if (attr->volatile_)
      {
  	if (gfc_notify_std (GFC_STD_LEGACY, 
  			    "Duplicate VOLATILE attribute specified at %L",
--- 877,890 ----
  gfc_add_volatile (symbol_attribute * attr, const char *name, locus * where)
  {
  
!   /* No check_used needed as 11.2.1 of the F2003 standard allows
!      that the local identifier made accessible by a use statement can be
!      given a VOLATILE attribute.  */
! 
!   /* TODO: The following allows multiple VOLATILE statements for
!      use-associated variables and it prevents to set VOLATILE for a host-
!      associated variable which is already marked as VOLATILE in the host.  */
!   if (attr->volatile_ && !attr->use_assoc)
      {
  	if (gfc_notify_std (GFC_STD_LEGACY, 
  			    "Duplicate VOLATILE attribute specified at %L",
Index: gcc/fortran/decl.c
===================================================================
*** gcc/fortran/decl.c	(Revision 121033)
--- gcc/fortran/decl.c	(Arbeitskopie)
*************** gfc_match_volatile (void)
*** 4221,4227 ****
  
    for(;;)
      {
!       m = gfc_match_symbol (&sym, 0);
        switch (m)
  	{
  	case MATCH_YES:
--- 4221,4229 ----
  
    for(;;)
      {
!       /* VOLATILE is special because it can be added to host-associated 
! 	 symbols locally.  */
!       m = gfc_match_symbol (&sym, 1);
        switch (m)
  	{
  	case MATCH_YES:
Index: gcc/testsuite/gfortran.dg/volatile8.f90
===================================================================
*** gcc/testsuite/gfortran.dg/volatile8.f90	(Revision 0)
--- gcc/testsuite/gfortran.dg/volatile8.f90	(Revision 0)
***************
*** 0 ****
--- 1,58 ----
+ ! Check for compatibily of actual arguments
+ ! with dummy arguments marked as volatile
+ ! 
+ ! Contributed by Steven Correll.
+ !
+ ! PR fortran/30520
+ 
+ ! { dg-do compile }
+ 
+    subroutine s8()
+     implicit none
+     interface
+       subroutine sub8(dummy8)
+         integer, volatile, dimension(3) :: dummy8
+       end subroutine sub8
+       subroutine sub8a(dummy8a)
+         integer, volatile, dimension(:) :: dummy8a
+       end subroutine sub8a
+     end interface
+     integer, dimension(8) :: a
+     call sub8 (a(1:5:2)) ! { dg-error "Array-section actual argument" }
+     call sub8a(a(1:5:2))
+   end subroutine s8 
+ 
+   subroutine s9(s9dummy)
+     implicit none
+     integer, dimension(:) :: s9dummy
+     interface
+       subroutine sub9(dummy9)
+         integer, volatile, dimension(3) :: dummy9
+       end subroutine sub9
+       subroutine sub9a(dummy9a)
+         integer, volatile, dimension(:) :: dummy9a
+       end subroutine sub9a
+     end interface
+     integer, dimension(9) :: a
+     call sub9 (s9dummy) ! { dg-error "Assumed-shape actual argument" }
+     call sub9a(s9dummy)
+   end subroutine s9 
+ 
+   subroutine s10()
+     implicit none
+     interface
+       subroutine sub10(dummy10)
+         integer, volatile, dimension(3) :: dummy10
+       end subroutine sub10
+       subroutine sub10a(dummy10a)
+         integer, volatile, dimension(:) :: dummy10a
+       end subroutine sub10a
+       subroutine sub10b(dummy10b)
+         integer, volatile, dimension(:), pointer :: dummy10b
+       end subroutine sub10b
+     end interface
+     integer, dimension(:), pointer :: a
+     call sub10 (a) ! { dg-error "Pointer-array actual argument" }
+     call sub10a(a)
+     call sub10b(a)
+   end subroutine s10 
Index: gcc/testsuite/gfortran.dg/volatile9.f90
===================================================================
*** gcc/testsuite/gfortran.dg/volatile9.f90	(Revision 0)
--- gcc/testsuite/gfortran.dg/volatile9.f90	(Revision 0)
***************
*** 0 ****
--- 1,44 ----
+ ! Check for valid VOLATILE uses
+ !
+ ! Contributed by Steven Correll.
+ !
+ ! PR fortran/30520
+ 
+ ! { dg-do compile }
+  
+   function f() result(fr)
+     integer, volatile :: fr
+     fr = 5
+   end function f 
+ 
+   module mod13
+     implicit none
+     integer :: v13
+   end module mod13 
+ 
+   module mod13a
+    use mod13
+    implicit none
+    volatile :: v13
+    real :: v14
+   contains
+    subroutine s13()
+      volatile :: v13
+      volatile :: v14
+    end subroutine s13 
+   end module mod13a 
+ 
+   module mod13b
+    use mod13a
+    implicit none
+    volatile :: v13
+   end module mod13b 
+ 
+ 
+   subroutine s14()
+     use mod13a
+     implicit none
+     volatile :: v13
+   end subroutine s14 
+ 
+ ! { dg-final { cleanup-modules "mod13 mod13a mod13b" } }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]