aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8/gcc/testsuite/gfortran.dg/protected_4.f90
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2013-03-28 11:14:20 -0700
committerBen Cheng <bccheng@google.com>2013-03-28 12:40:33 -0700
commitaf0c51ac87ab2a87caa03fa108f0d164987a2764 (patch)
tree4b8b470f7c5b69642fdab8d0aa1fbc148d02196b /gcc-4.8/gcc/testsuite/gfortran.dg/protected_4.f90
parentd87cae247d39ebf4f5a6bf25c932a14d2fdb9384 (diff)
downloadtoolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.tar.gz
toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.tar.bz2
toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.zip
[GCC 4.8] Initial check-in of GCC 4.8.0
Change-Id: I0719d8a6d0f69b367a6ab6f10eb75622dbf12771
Diffstat (limited to 'gcc-4.8/gcc/testsuite/gfortran.dg/protected_4.f90')
-rw-r--r--gcc-4.8/gcc/testsuite/gfortran.dg/protected_4.f9056
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc-4.8/gcc/testsuite/gfortran.dg/protected_4.f90 b/gcc-4.8/gcc/testsuite/gfortran.dg/protected_4.f90
new file mode 100644
index 000000000..2834680a9
--- /dev/null
+++ b/gcc-4.8/gcc/testsuite/gfortran.dg/protected_4.f90
@@ -0,0 +1,56 @@
+! { dg-do compile }
+! { dg-shouldfail "Invalid Fortran 2003 code" }
+! { dg-options "-std=f2003 -fall-intrinsics" }
+! PR fortran/23994
+!
+! Test PROTECTED attribute. Within the module everything is allowed.
+! Outside (use-associated): For pointers, their association status
+! may not be changed. For nonpointers, their value may not be changed.
+!
+! Test of a invalid code
+
+module protmod
+ implicit none
+ integer :: a
+ integer, target :: at
+ integer, pointer :: ap
+ protected :: a, at, ap
+end module protmod
+
+program main
+ use protmod
+ implicit none
+ integer :: j
+ logical :: asgnd
+ protected :: j ! { dg-error "only allowed in specification part of a module" }
+ a = 43 ! { dg-error "variable definition context" }
+ ap => null() ! { dg-error "pointer association context" }
+ nullify(ap) ! { dg-error "pointer association context" }
+ ap => at ! { dg-error "pointer association context" }
+ ap = 3 ! OK
+ allocate(ap) ! { dg-error "pointer association context" }
+ ap = 73 ! OK
+ call increment(a,at) ! { dg-error "variable definition context" }
+ call pointer_assignments(ap) ! { dg-error "pointer association context" }
+ asgnd = pointer_check(ap)
+contains
+ subroutine increment(a1,a3)
+ integer, intent(inout) :: a1, a3
+ a1 = a1 + 1
+ a3 = a3 + 1
+ end subroutine increment
+ subroutine pointer_assignments(p)
+ integer, pointer,intent(out) :: p
+ p => null()
+ end subroutine pointer_assignments
+ function pointer_check(p)
+ integer, pointer,intent(in) :: p
+ logical :: pointer_check
+ pointer_check = associated(p)
+ end function pointer_check
+end program main
+
+module test
+ real :: a
+ protected :: test ! { dg-error "MODULE attribute conflicts with PROTECTED" }
+end module test