-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[F03] bogus error: Could not resolve generic type bound procedure #533 #849
base: master
Are you sure you want to change the base?
Changes from 1 commit
6aa81f7
17c072e
6244084
f43ed48
e491503
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Earlier a tbp arg was added for few type bound procedure calls (with/without nopass clause). This was inconsistent. While procedure matching, procedures with nopass clauses were not considered. This has been fixed. Now a tbp arg will be added to all type bound procedure calls and this tbp arg will be considered/discarded depending on the procedure (with/without nopass clause) being matched. Change-Id: I73a1b0c15852b8d2302048d44db4aa26f1f0a9ac
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) 2019, Advanced Micro Devices, Inc. All rights reserved. | ||
# | ||
# Date of Modification: December 2019 | ||
# | ||
|
||
########## Make rule to test type-bound procedures ######## | ||
|
||
fcheck.o check_mod.mod: $(SRC)/check_mod.f90 | ||
-$(FC) -c $(FFLAGS) $(SRC)/check_mod.f90 -o fcheck.o | ||
|
||
tbp.o: $(SRC)/tbp.f90 check_mod.mod | ||
@echo ------------------------------------ building test $@ | ||
-$(FC) -c $(FFLAGS) $(LDFLAGS) $(SRC)/tbp.f90 -o tbp.o | ||
|
||
tbp: tbp.o fcheck.o | ||
-$(FC) $(FFLAGS) $(LDFLAGS) tbp.o fcheck.o $(LIBS) -o tbp | ||
|
||
tbp.run: tbp | ||
@echo ------------------------------------ executing test tbp | ||
tbp | ||
-$(RM) test_m.mod | ||
|
||
### TA Expected Targets ### | ||
|
||
build: $(TEST) | ||
|
||
.PHONY: run | ||
run: $(TEST).run | ||
|
||
verify: ; | ||
|
||
### End of Expected Targets ### |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) 2019, Advanced Micro Devices, Inc. All rights reserved. | ||
# | ||
# Date of Modification: December 2019 | ||
# | ||
|
||
# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t | ||
# RUN: cat %t | FileCheck %S/runmake |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
! Copyright (c) 2019, Advanced Micro Devices, Inc. All rights reserved. | ||
! | ||
! Date of Modification: December 2019 | ||
|
||
module test_m | ||
implicit none | ||
|
||
type A_t | ||
contains | ||
! Case 1: | ||
procedure ,nopass :: f_int | ||
procedure :: f_real | ||
generic :: f => f_int, f_real | ||
! Case 2: | ||
procedure :: f_int1 | ||
procedure ,nopass :: f_real1 | ||
generic :: f1 => f_int1, f_real1 | ||
! Case 3: | ||
procedure ,nopass:: f_int2 | ||
procedure ,nopass :: f_real2 | ||
generic :: f2 => f_int2, f_real2 | ||
! Case 4: | ||
procedure :: f_int3 | ||
procedure :: f_real3 | ||
generic :: f3 => f_int3, f_real3 | ||
endtype | ||
|
||
contains | ||
! Case 1: | ||
integer function f_int( n ) result (RSLT) | ||
integer :: n | ||
RSLT = n - 1 | ||
end function f_int | ||
integer function f_real( me, x ) result (RSLT) | ||
class(A_t) :: me | ||
real :: x | ||
RSLT = x + 1 | ||
end function f_real | ||
|
||
! Case 2: | ||
integer function f_int1( me, n ) result (RSLT) | ||
class(A_t) :: me | ||
integer :: n | ||
RSLT = n - 1 | ||
end function f_int1 | ||
integer function f_real1( x ) result (RSLT) | ||
real :: x | ||
RSLT = x + 1 | ||
end function f_real1 | ||
|
||
! Case 3: | ||
integer function f_int2( n ) result (RSLT) | ||
integer :: n | ||
RSLT = n - 1 | ||
end function f_int2 | ||
integer function f_real2( x ) result (RSLT) | ||
real :: x | ||
RSLT = x + 1 | ||
end function f_real2 | ||
|
||
! Case 3: | ||
integer function f_int3( me, n ) result (RSLT) | ||
class(A_t) :: me | ||
integer :: n | ||
RSLT = n - 1 | ||
end function f_int3 | ||
integer function f_real3( me, x ) result (RSLT) | ||
class(A_t) :: me | ||
real :: x | ||
RSLT = x + 1 | ||
end function f_real3 | ||
end module | ||
|
||
program main | ||
USE CHECK_MOD | ||
use test_m | ||
implicit none | ||
type(A_t) :: A | ||
logical results(4) | ||
logical expect(4) | ||
|
||
results = .false. | ||
expect = .true. | ||
|
||
results(1) = 9 .eq. A%f(10) | ||
results(2) = 99 .eq. A%f1(100) | ||
results(3) = 999 .eq. A%f2(1000) | ||
results(4) = 9999 .eq. A%f3(10000) | ||
|
||
call check(results,expect,4) | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -768,16 +768,6 @@ semant2(int rednum, SST *top) | |
} else { | ||
int dty = TBPLNKG(sptr); | ||
itemp = ITEM_END; | ||
if (generic_tbp_has_pass_and_nopass(dty, sptr)) { | ||
int parent, sp; | ||
e1 = (SST *)getitem(0, sizeof(SST)); | ||
sp = sym_of_ast(ast); | ||
SST_SYMP(e1, sp); | ||
SST_DTYPEP(e1, DTYPEG(sp)); | ||
mkident(e1); | ||
mkexpr(e1); | ||
itemp = mkitem(e1); | ||
} | ||
goto var_ref_common; | ||
} | ||
} | ||
|
@@ -966,7 +956,9 @@ semant2(int rednum, SST *top) | |
mem2 = get_specific_member(TBPLNKG(sptr), VTABLEG(mem)); | ||
argno = get_tbp_argno(BINDG(mem2), TBPLNKG(sptr)); | ||
if (!argno && NOPASSG(mem2)) { | ||
goto var_ref_common; /* assume NOPASS tbp */ | ||
// One tbp argument will be added to a type bound procedure call | ||
// with NOPASS clause. | ||
argno = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the same change not required in the else portion below? Can you add a test for operator also? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check is for generic type bound procedures only, so we do not need this for else part. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is better to restrict this change only to generic type bound procedures. I will do this change and push it for review again. |
||
} | ||
} else { | ||
argno = get_tbp_argno(sptr, DTYPEG(pass_sym_of_ast(ast))); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you call the real ones also through the generic name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had fogotten to add a check for functions without any parameter. I will add them too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was pointing out that you are calling only the integer ones. Call the real ones also in the test for completeness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops sorry, my bad. Sure I will add the check for real type as well.