[PATCH] D89581: [flang] Disallow pointer constants
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 16 12:34:45 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf2897b8f45c1: [flang] Disallow pointer constants (authored by PeteSteinfeld).
Changed prior to commit:
https://reviews.llvm.org/D89581?vs=298703&id=298721#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D89581/new/
https://reviews.llvm.org/D89581
Files:
flang/lib/Semantics/check-declarations.cpp
flang/test/Semantics/resolve90.f90
Index: flang/test/Semantics/resolve90.f90
===================================================================
--- flang/test/Semantics/resolve90.f90
+++ flang/test/Semantics/resolve90.f90
@@ -1,10 +1,13 @@
! RUN: %S/test_errors.sh %s %t %f18
+! Testing for pointer constant, along with :
! C751 A component shall not have both the ALLOCATABLE and POINTER attributes.
! C752 If the CONTIGUOUS attribute is specified, the component shall be an
! array with the POINTER attribute.
! C753 The * char-length option is permitted only if the component is of type
! character.
subroutine s()
+ !ERROR: 'nullint' may not have both the POINTER and PARAMETER attributes
+ integer, pointer, parameter :: nullint => null()
type derivedType
!ERROR: 'pointerallocatablefield' may not have both the POINTER and ALLOCATABLE attributes
real, pointer, allocatable :: pointerAllocatableField
Index: flang/lib/Semantics/check-declarations.cpp
===================================================================
--- flang/lib/Semantics/check-declarations.cpp
+++ flang/lib/Semantics/check-declarations.cpp
@@ -1280,6 +1280,12 @@
CheckConflicting(symbol, Attr::POINTER, Attr::TARGET);
CheckConflicting(symbol, Attr::POINTER, Attr::ALLOCATABLE); // C751
CheckConflicting(symbol, Attr::POINTER, Attr::INTRINSIC);
+ // Prohibit constant pointers. The standard does not explicitly prohibit
+ // them, but the PARAMETER attribute requires a entity-decl to have an
+ // initialization that is a constant-expr, and the only form of
+ // initialization that allows a constant-expr is the one that's not a "=>"
+ // pointer initialization. See C811, C807, and section 8.5.13.
+ CheckConflicting(symbol, Attr::POINTER, Attr::PARAMETER);
if (symbol.Corank() > 0) {
messages_.Say(
"'%s' may not have the POINTER attribute because it is a coarray"_err_en_US,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89581.298721.patch
Type: text/x-patch
Size: 1885 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201016/8d1ec115/attachment.bin>
More information about the llvm-commits
mailing list