OLD | NEW |
1 ! { dg-do compile } | 1 ! { dg-do compile } |
2 ! Test for errors when setting private components inside a structure constructor | 2 ! Test for errors when setting private components inside a structure constructor |
3 ! or when constructing a private structure. | 3 ! or when constructing a private structure. |
4 | 4 |
5 MODULE privmod | 5 MODULE privmod |
6 IMPLICIT NONE | 6 IMPLICIT NONE |
7 | 7 |
8 TYPE :: haspriv_t | 8 TYPE :: haspriv_t |
9 INTEGER :: a | 9 INTEGER :: a |
10 INTEGER, PRIVATE :: b = 42 | 10 INTEGER, PRIVATE :: b = 42 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 ! This should succeed, not giving value to private component | 45 ! This should succeed, not giving value to private component |
46 struct1 = haspriv_t (5) | 46 struct1 = haspriv_t (5) |
47 struct2 = allpriv_t () | 47 struct2 = allpriv_t () |
48 | 48 |
49 ! These should fail | 49 ! These should fail |
50 struct1 = haspriv_t (1, 2) ! { dg-error "is a PRIVATE component" } | 50 struct1 = haspriv_t (1, 2) ! { dg-error "is a PRIVATE component" } |
51 struct1 = haspriv_t (b = 2, a = 1) ! { dg-error "is a PRIVATE component" } | 51 struct1 = haspriv_t (b = 2, a = 1) ! { dg-error "is a PRIVATE component" } |
52 | 52 |
53 ! This should fail as all components are private | 53 ! This should fail as all components are private |
54 struct2 = allpriv_t (5) ! { dg-error "of 'allpriv_t' are PRIVATE" } | 54 struct2 = allpriv_t (5) ! { dg-error "is a PRIVATE component" } |
55 | 55 |
56 ! This should fail as the type itself is private, and the expression should | 56 ! This should fail as the type itself is private, and the expression should |
57 ! be deduced as call to an undefined function. | 57 ! be deduced as call to an undefined function. |
58 WRITE (*,*) ispriv_t (5) ! { dg-error "has no IMPLICIT type" } | 58 WRITE (*,*) ispriv_t (5) ! { dg-error "has no IMPLICIT type" } |
59 | 59 |
60 END PROGRAM test | 60 END PROGRAM test |
61 ! { dg-final { cleanup-modules "privmod" } } | 61 ! { dg-final { cleanup-modules "privmod" } } |
OLD | NEW |