File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -1280,6 +1280,12 @@ void CheckHelper::CheckPointer(const Symbol &symbol) { // C852
1280
1280
CheckConflicting (symbol, Attr::POINTER, Attr::TARGET);
1281
1281
CheckConflicting (symbol, Attr::POINTER, Attr::ALLOCATABLE); // C751
1282
1282
CheckConflicting (symbol, Attr::POINTER, Attr::INTRINSIC);
1283
+ // Prohibit constant pointers. The standard does not explicitly prohibit
1284
+ // them, but the PARAMETER attribute requires a entity-decl to have an
1285
+ // initialization that is a constant-expr, and the only form of
1286
+ // initialization that allows a constant-expr is the one that's not a "=>"
1287
+ // pointer initialization. See C811, C807, and section 8.5.13.
1288
+ CheckConflicting (symbol, Attr::POINTER, Attr::PARAMETER);
1283
1289
if (symbol.Corank () > 0 ) {
1284
1290
messages_.Say (
1285
1291
" '%s' may not have the POINTER attribute because it is a coarray" _err_en_US,
Original file line number Diff line number Diff line change 1
1
! RUN: %S/test_errors.sh %s %t %f18
2
+ ! Testing for pointer constant, along with :
2
3
! C751 A component shall not have both the ALLOCATABLE and POINTER attributes.
3
4
! C752 If the CONTIGUOUS attribute is specified, the component shall be an
4
5
! array with the POINTER attribute.
5
6
! C753 The * char-length option is permitted only if the component is of type
6
7
! character.
7
8
subroutine s ()
9
+ ! ERROR: 'nullint' may not have both the POINTER and PARAMETER attributes
10
+ integer , pointer , parameter :: nullint = > null ()
8
11
type derivedType
9
12
! ERROR: 'pointerallocatablefield' may not have both the POINTER and ALLOCATABLE attributes
10
13
real , pointer , allocatable :: pointerAllocatableField
You can’t perform that action at this time.
0 commit comments