OSDN Git Service

2011-02-11 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Feb 2011 21:07:17 +0000 (21:07 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Feb 2011 21:07:17 +0000 (21:07 +0000)
        PR fortran/47550
        * resolve.c (resolve_formal_arglist): PURE with VALUE
        and no INTENT: Add -std= diagnostics.

2011-02-11  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47550
        * gfortran.dg/pure_formal_2.f90: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170060 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pure_formal_2.f90 [new file with mode: 0644]

index 80cc4da..9980d4d 100644 (file)
@@ -1,3 +1,9 @@
+2011-02-11  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/47550
+       * resolve.c (resolve_formal_arglist): PURE with VALUE
+       and no INTENT: Add -std= diagnostics.
+
 2011-02-09  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/47352
index 0fe0672..fefb643 100644 (file)
@@ -341,17 +341,31 @@ resolve_formal_arglist (gfc_symbol *proc)
       if (gfc_pure (proc) && !sym->attr.pointer
          && sym->attr.flavor != FL_PROCEDURE)
        {
-         if (proc->attr.function && sym->attr.intent != INTENT_IN
-             && !sym->attr.value)
-           gfc_error ("Argument '%s' of pure function '%s' at %L must be "
-                      "INTENT(IN) or VALUE", sym->name, proc->name,
-                      &sym->declared_at);
+         if (proc->attr.function && sym->attr.intent != INTENT_IN)
+           {
+             if (sym->attr.value)
+               gfc_notify_std (GFC_STD_F2008, "Fortran 2008: Argument '%s' "
+                               "of pure function '%s' at %L with VALUE "
+                               "attribute but without INTENT(IN)", sym->name,
+                               proc->name, &sym->declared_at);
+             else
+               gfc_error ("Argument '%s' of pure function '%s' at %L must be "
+                          "INTENT(IN) or VALUE", sym->name, proc->name,
+                          &sym->declared_at);
+           }
 
-         if (proc->attr.subroutine && sym->attr.intent == INTENT_UNKNOWN
-             && !sym->attr.value)
-           gfc_error ("Argument '%s' of pure subroutine '%s' at %L must "
+         if (proc->attr.subroutine && sym->attr.intent == INTENT_UNKNOWN)
+           {
+             if (sym->attr.value)
+               gfc_notify_std (GFC_STD_F2008, "Fortran 2008: Argument '%s' "
+                               "of pure subroutine '%s' at %L with VALUE "
+                               "attribute but without INTENT", sym->name,
+                               proc->name, &sym->declared_at);
+             else
+               gfc_error ("Argument '%s' of pure subroutine '%s' at %L must "
                       "have its INTENT specified or have the VALUE "
                       "attribute", sym->name, proc->name, &sym->declared_at);
+           }
        }
 
       if (proc->attr.implicit_pure && !sym->attr.pointer
index d680a16..996c2d9 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-11  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/47550
+       * gfortran.dg/pure_formal_2.f90: New.
+
 2011-02-11  Pat Haugen <pthaugen@us.ibm.com>
 
        PR rtl-optimization/47614
diff --git a/gcc/testsuite/gfortran.dg/pure_formal_2.f90 b/gcc/testsuite/gfortran.dg/pure_formal_2.f90
new file mode 100644 (file)
index 0000000..b3c8a0e
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-std=f2003" }
+!
+! PR fortran/47550
+! Follow up to: PR fortran/47507
+!
+! PURE procedures: Allow arguments w/o INTENT if they are VALUE
+!
+
+pure function f(x) ! { dg-error "Fortran 2008: Argument 'x' of pure function" }
+  real, VALUE :: x
+  real :: f
+  f = sin(x)
+end function f
+
+pure subroutine sub(x) ! { dg-error "Fortran 2008: Argument 'x' of pure subroutine" }
+  real, VALUE :: x
+end subroutine sub