-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang] Prevent bad expression rewrite 0*ARR -> 0 (#79853)
Don't rewrite 0*X to 0 if X is not scalar. Up until now this hasn't shown up as a bug because a scalar 0 works in nearly all expressions where an array would be expected. But not in all cases -- this bad rewrite can cause generic procedure resolution to fail when it causes an actual argument to have an unsupported rank.
- Loading branch information
Showing
2 changed files
with
23 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
! RUN: %flang_fc1 -fsyntax-only -pedantic %s 2>&1 | FileCheck %s --allow-empty | ||
! Regression test for pFUnit case: ensure that 0*ka doesn't get rewritten | ||
! into a scalar 0 and then fail generic resolution. | ||
! CHECK-NOT: error: | ||
program test | ||
interface g | ||
procedure s | ||
end interface | ||
integer(1) a(1) | ||
a(1) = 2 | ||
call test(1_1, a) | ||
contains | ||
subroutine s(a1,a2) | ||
integer(1) a1(:), a2(:) | ||
print *, a1 | ||
print *, a2 | ||
end | ||
subroutine test(j,ka) | ||
integer(1) j, ka(:) | ||
call g(int(j+0*ka,kind(ka)), ka) | ||
end | ||
end |