Skip to content

Commit

Permalink
Fix private overwrite flag
Browse files Browse the repository at this point in the history
find_def_in_most_recent_scope() set the private bit to 0 when it found an alias. This was most likely unintended and could cause issues when resolving multiple definitions of the same symbol at a later stage (if a private symbol appeared to be publicly available).

Tests for private flag overwrite added, based on flang github issue #890.
  • Loading branch information
michalpasztamobica authored and kiranchandramohan committed Oct 23, 2020
1 parent b39412c commit aec36b8
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
20 changes: 20 additions & 0 deletions test/f90_correct/inc/use00.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#

########## Make rule for test use00 ########

build:
@echo ------------------------------------ building test $(TEST)
-$(CC) -c $(CFLAGS) $(SRC)/check.c -o check.$(OBJX)
-$(FC) -c $(FFLAGS) $(LDFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(OBJX)
-$(FC) $(FFLAGS) $(LDFLAGS) $(TEST).$(OBJX) check.$(OBJX) $(LIBS) -o $(TEST).$(EXESUFFIX)

run:
@echo ------------------------------------ executing test $(TEST)
./$(TEST).$(EXESUFFIX)

verify: ;

9 changes: 9 additions & 0 deletions test/f90_correct/lit/use00.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Shared lit script for each tests. Run bash commands that run tests with make.

# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t
# RUN: cat %t | FileCheck %S/runmake
39 changes: 39 additions & 0 deletions test/f90_correct/src/use00.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module f_precisions
integer, parameter, public :: f_double = selected_real_kind(15, 307)
end module f_precisions

module box
use f_precisions, gp=>f_double
private
public :: get_gp
contains
subroutine get_gp(out_val)
integer, intent(out) :: out_val
out_val = gp
end subroutine get_gp
end module box

module Poisson_Solver
use f_precisions
integer, parameter, public :: gp=f_double
end module Poisson_Solver

module module_defs
use f_precisions
integer, parameter, public :: gp=f_double
end module module_defs

subroutine PSolver(eh)
use module_defs ! This has a public gp
use box ! This has a private gp
use Poisson_Solver, except_gp => gp ! This has a public gp
real(gp), intent(out) :: eh ! Should be able to use gp from module_base
end subroutine PSolver

program main
use box
use Poisson_Solver
integer :: box_gp
call get_gp(box_gp)
call check(box_gp, gp, 1) ! box's gp and Solver's gp alias the same variable
end program
1 change: 0 additions & 1 deletion tools/flang1/flang1exe/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ find_def_in_most_recent_scope(int sptr, int save_sem_scope_level)
if (NMPTRG(sptr1) != NMPTRG(sptr))
continue;
if (STYPEG(sptr1) == ST_ALIAS && aliased_sym_visible(sptr1)) {
PRIVATEP(sptr1, 0);
HIDDENP(SYMLKG(sptr1), 0);
}
if (STYPEG(sptr1) == ST_ALIAS) {
Expand Down

4 comments on commit aec36b8

@pawosm-arm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, this commit introduced regression in cp2k!

F90-S-0079-Keyword form of argument illegal in this context for eps (src/almo_scf_methods.F: 1758)
  0 inform,   0 warnings,   1 severes, 0 fatal for almo_scf_t_to_proj

and

F90-S-0079-Keyword form of argument illegal in this context for eps (src/almo_scf_optimizer.F: 6302)
F90-S-0079-Keyword form of argument illegal in this context for eps (src/almo_scf_optimizer.F: 6315)
  0 inform,   0 warnings,   2 severes, 0 fatal for compute_gradient
F90-S-0079-Keyword form of argument illegal in this context for eps (src/almo_scf_optimizer.F: 6910)
  0 inform,   0 warnings,   1 severes, 0 fatal for compute_xalmos_from_main_var
F90-S-0079-Keyword form of argument illegal in this context for eps (almo_scf_optimizer.F: 7130)
  0 inform,   0 warnings,   1 severes, 0 fatal for compute_preconditioner
F90-S-0079-Keyword form of argument illegal in this context for eps (src/almo_scf_optimizer.F: 9325)
F90-S-0079-Keyword form of argument illegal in this context for eps (src/almo_scf_optimizer.F: 9786)
  0 inform,   0 warnings,   2 severes, 0 fatal for almo_scf_xalmo_trustr

cp2k github master SHA f07f6186bf33635422e740a738a9e1b48731449e

@pawosm-arm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch also broke AMD's fix for cp2k issues. I didn't know that and now we have broken git master.

@pawosm-arm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reverted my commit with test cases for AMD's fix until this situation is sorted.

@pawosm-arm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was kindly asked to open new issue for this, it's: #995

Please sign in to comment.