OSDN Git Service

2011-01-21 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Jan 2011 07:11:05 +0000 (07:11 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Jan 2011 07:11:05 +0000 (07:11 +0000)
        PR fortran/47377
        * expr.c (gfc_check_pointer_assign): Reject expr data-targets
        without pointer attribute.

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

        PR fortran/47377
        * gfortran.dg/pointer_target_4.f90: New.

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

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

index 8bf90a9..7ea9603 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-21  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/47377
+       * expr.c (gfc_check_pointer_assign): Reject expr data-targets
+       without pointer attribute.
+
 2011-01-18  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/47240
index 3f1141a..bcc23fc 100644 (file)
@@ -3507,6 +3507,15 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue)
     lvalue->symtree->n.sym->attr.subref_array_pointer = 1;
 
   attr = gfc_expr_attr (rvalue);
+
+  if (rvalue->expr_type == EXPR_FUNCTION && !attr.pointer)
+    {
+      gfc_error ("Target expression in pointer assignment "
+                "at %L must deliver a pointer result",
+                &rvalue->where);
+      return FAILURE;
+    }
+
   if (!attr.target && !attr.pointer)
     {
       gfc_error ("Pointer assignment target is neither TARGET "
index 45f8ef1..cc4efe7 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-21  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/47377
+       * gfortran.dg/pointer_target_4.f90: New.
+
 2011-01-20  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/47251
diff --git a/gcc/testsuite/gfortran.dg/pointer_target_4.f90 b/gcc/testsuite/gfortran.dg/pointer_target_4.f90
new file mode 100644 (file)
index 0000000..cda3453
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+!
+! PR fortran/47377
+!
+! Contributed by <thenlich@users.sourceforge.net>
+!
+program testgferr
+    real, pointer :: y
+    y => f()  ! { dg-error "must deliver a pointer result" }
+contains
+    function f()
+      real :: f
+      f = 5
+    end function f
+end program testgferr