]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/50547 (dummy procedure argument of PURE shall be PURE)
authorJanus Weil <janus@gcc.gnu.org>
Thu, 29 Sep 2011 11:57:35 +0000 (13:57 +0200)
committerJanus Weil <janus@gcc.gnu.org>
Thu, 29 Sep 2011 11:57:35 +0000 (13:57 +0200)
2011-09-29  Janus Weil  <janus@gcc.gnu.org>

PR fortran/50547
* resolve.c (resolve_formal_arglist): Fix pureness check for dummy
functions.

PR fortran/50553
* symbol.c (check_conflict): Forbid TARGET attribute for statement
functions.

2011-09-29  Janus Weil  <janus@gcc.gnu.org>

PR fortran/50547
* gfortran.dg/pure_formal_proc_3.f90: New.

PR fortran/50553
* gfortran.dg/stfunc_7.f90: New.

From-SVN: r179345

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

index 99d2d3c812ad0b92b7afceea15c124744a90794c..ecd9fa3a740a256726e834f4aa7b74babd33bc80 100644 (file)
@@ -1,3 +1,13 @@
+2011-09-29  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/50547
+       * resolve.c (resolve_formal_arglist): Fix pureness check for dummy
+       functions.
+
+       PR fortran/50553
+       * symbol.c (check_conflict): Forbid TARGET attribute for statement
+       functions.
+
 2011-09-27  Jakub Jelinek  <jakub@redhat.com>
 
        * trans-types.c (gfc_type_for_size): Return wider type
index 13ecf1c2bf6af7f5d0077e14f4e383c8da8bd241..84db3ddb019f0aa46d970f26b095dc21de788176 100644 (file)
@@ -269,18 +269,21 @@ resolve_formal_arglist (gfc_symbol *proc)
       if (sym->attr.if_source != IFSRC_UNKNOWN)
        resolve_formal_arglist (sym);
 
+      /* F08:C1279.  */
+      if (gfc_pure (proc)
+         && sym->attr.flavor == FL_PROCEDURE && !gfc_pure (sym))
+       {
+         gfc_error ("Dummy procedure '%s' of PURE procedure at %L must "
+                    "also be PURE", sym->name, &sym->declared_at);
+         continue;
+       }
+      
       if (sym->attr.subroutine || sym->attr.external || sym->attr.intrinsic)
        {
-         if (gfc_pure (proc) && !gfc_pure (sym))
-           {
-             gfc_error ("Dummy procedure '%s' of PURE procedure at %L must "
-                        "also be PURE", sym->name, &sym->declared_at);
-             continue;
-           }
-
          if (proc->attr.implicit_pure && !gfc_pure(sym))
            proc->attr.implicit_pure = 0;
 
+         /* F08:C1289.  */
          if (gfc_elemental (proc))
            {
              gfc_error ("Dummy procedure at %L not allowed in ELEMENTAL "
@@ -382,7 +385,7 @@ resolve_formal_arglist (gfc_symbol *proc)
 
       if (gfc_elemental (proc))
        {
-         /* F2008, C1289.  */
+         /* F08:C1289.  */
          if (sym->attr.codimension)
            {
              gfc_error ("Coarray dummy argument '%s' at %L to elemental "
index 25186c977ad9b92f65074c2095040a8a5cdffe70..46eccb46abab59ebfda9800173d11f9952d2e2a2 100644 (file)
@@ -684,6 +684,7 @@ check_conflict (symbol_attribute *attr, const char *name, locus *where)
        {
        case PROC_ST_FUNCTION:
          conf2 (dummy);
+         conf2 (target);
          break;
 
        case PROC_MODULE:
index 59aefbc933894adc192b74f443396f5bb6c9416b..fb41e555112a59470cc1b3289cccc9bbb428bea3 100644 (file)
@@ -1,3 +1,11 @@
+2011-09-29  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/50547
+       * gfortran.dg/pure_formal_proc_3.f90: New.
+
+       PR fortran/50553
+       * gfortran.dg/stfunc_7.f90: New.
+
 2011-09-29  Artjoms Sinkarovs <artyom.shinkaroff@gmail.com>
 
        * gcc.c-torture/execute/vector-compare-1.c: New testcase.
diff --git a/gcc/testsuite/gfortran.dg/pure_formal_proc_3.f90 b/gcc/testsuite/gfortran.dg/pure_formal_proc_3.f90
new file mode 100644 (file)
index 0000000..38d4552
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do compile }
+!
+! PR 50547: dummy procedure argument of PURE shall be PURE
+!
+! Contributed by Vittorio Zecca <zeccav@gmail.com>
+
+pure function f(proc)
+  interface
+    function proc()  ! { dg-error "must also be PURE" }
+    end
+  end interface
+end
diff --git a/gcc/testsuite/gfortran.dg/stfunc_7.f90 b/gcc/testsuite/gfortran.dg/stfunc_7.f90
new file mode 100644 (file)
index 0000000..1e11646
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! { dg-options "-std=legacy" }
+!
+! PR 50553: statement function cannot be target (r178939)
+!
+! Contributed by Vittorio Zecca <zeccav@gmail.com>
+
+f(x)=x
+target f  ! { dg-error "attribute conflicts with" }
+end