-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang] Fix parsing and semantics for array element substring%KIND/%LEN
A type-param-inquiry of %KIND or %LEN applies to a designator, and so must also be allowed for a substring. F18 presently (mis)parses instances of a type-param-inquiry as structure component references and then fixes them in expression semantics when types are known and we can distinguish them. But when the base of a type-param-inquiry is a substring of an array element, as in "charArray(i)(j:k)%len", parsing fails. Adjust the grammar to parse these cases, and extend expression semantics to process the new production. Differential Revision: https://reviews.llvm.org/D130375
- Loading branch information
Showing
9 changed files
with
149 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s | ||
! Tests handling of easily-misparsed substrings and substring | ||
! type parameter inquiries. | ||
subroutine foo(j) | ||
integer, intent(in) :: j | ||
character*4 sc, ac(1) | ||
type t | ||
character*4 sc, ac(1) | ||
end type | ||
type(t) st, at(1) | ||
!CHECK: PRINT *, sc(1_8:int(j,kind=8)) | ||
print *, sc(1:j) | ||
!CHECK: PRINT *, ac(1_8)(1_8:int(j,kind=8)) | ||
print *, ac(1)(1:j) | ||
!CHECK: PRINT *, st%sc(1_8:int(j,kind=8)) | ||
print *, st%sc(1:j) | ||
!CHECK: PRINT *, st%ac(1_8)(1_8:int(j,kind=8)) | ||
print *, st%ac(1)(1:j) | ||
!CHECK: PRINT *, at(1_8)%sc(1_8:int(j,kind=8)) | ||
print *, at(1)%sc(1:j) | ||
!CHECK: PRINT *, at(1_8)%ac(1_8)(1_8:int(j,kind=8)) | ||
print *, at(1)%ac(1)(1:j) | ||
!CHECK: PRINT *, 1_4 | ||
print *, sc(1:j)%kind | ||
!CHECK: PRINT *, 1_4 | ||
print *, ac(1)(1:j)%kind | ||
!CHECK: PRINT *, 1_4 | ||
print *, st%sc(1:j)%kind | ||
!CHECK: PRINT *, 1_4 | ||
print *, st%ac(1)(1:j)%kind | ||
!CHECK: PRINT *, 1_4 | ||
print *, at(1)%sc(1:j)%kind | ||
!CHECK: PRINT *, 1_4 | ||
print *, at(1)%ac(1)(1:j)%kind | ||
!CHECK: PRINT *, int(max(0_8,int(j,kind=8)-1_8+1_8),kind=4) | ||
print *, sc(1:j)%len | ||
!CHECK: PRINT *, int(max(0_8,int(j,kind=8)-1_8+1_8),kind=4) | ||
print *, ac(1)(1:j)%len | ||
!CHECK: PRINT *, int(max(0_8,int(j,kind=8)-1_8+1_8),kind=4) | ||
print *, st%sc(1:j)%len | ||
!CHECK: PRINT *, int(max(0_8,int(j,kind=8)-1_8+1_8),kind=4) | ||
print *, st%ac(1)(1:j)%len | ||
!CHECK: PRINT *, int(max(0_8,int(j,kind=8)-1_8+1_8),kind=4) | ||
print *, at(1)%sc(1:j)%len | ||
!CHECK: PRINT *, int(max(0_8,int(j,kind=8)-1_8+1_8),kind=4) | ||
print *, at(1)%ac(1)(1:j)%len | ||
end |