llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.93k stars 11.53k forks source link

[Flang][OpenMP] Abnormal termination of compilation of a threadprivate directive with wrong arguments #82943

Open yus3710-fj opened 6 months ago

yus3710-fj commented 6 months ago

This is an issue from Fujitsu testsuite.

Flang-new terminates abnormally when compiling a threadprivate directive with wrong arguments.

The following are the test program and the compilation results of flang-new and gfortran. (I believe function references can't be threadprivate variables, but gfortran-13.2 seems to accept it.)

! test.f90
!$omp threadprivate(a,b)
integer,pointer :: a
allocatable a ! may not have both the POINTER and ALLOCATABLE attributes
external b ! function references can't be threadprivate variables
end
$ flang-new -v test.f90 -fopenmp
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git db8b76dbb07d4053a4e44baf1518c9ea0d84c844)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
Found candidate GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
Selected GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-4eed2d.o -x f95-cpp-input test.f90

fatal internal error: SemanticsContext::FindScope(): invalid source location for 'threadprivate(a,b)'
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /path/to/install/bin/flang-new -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-4eed2d.o -x f95-cpp-input test.f90
 #0 0x0000ffffaf356dc8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/path/to/install/lib/libLLVMSupport.so.19git+0x1a6dc8)
 #1 0x0000ffffaf354cf8 llvm::sys::RunSignalHandlers() (/path/to/install/lib/libLLVMSupport.so.19git+0x1a4cf8)
 #2 0x0000ffffaf354e7c SignalHandler(int) Signals.cpp:0:0
 #3 0x0000ffffb1d207a0 (linux-vdso.so.1+0x7a0)
 #4 0x0000ffffaeda6274 raise (/lib64/libc.so.6+0x36274)
 #5 0x0000ffffaed90a2c abort (/lib64/libc.so.6+0x20a2c)
 #6 0x0000ffffa63d241c (/path/to/install/lib/libFortranCommon.so.19git+0x241c)
 #7 0x0000ffffaa320fac (/path/to/install/lib/libFortranSemantics.so.19git+0x2140fac)
 #8 0x0000ffffaa23ecf8 std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<void (*)(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct>(std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&)>, std::tuple<std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&>, std::integer_sequence<unsigned long, 4ul>>::__visit_invoke(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct>(std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x205ecf8)
 #9 0x0000ffffaa23df68 void Fortran::parser::ForEachInTuple<0ul, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&), std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)) (/path/to/install/lib/libFortranSemantics.so.19git+0x205df68)
#10 0x0000ffffaa23e6d8 std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<void (*)(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>>(std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&)>, std::tuple<std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&>, std::integer_sequence<unsigned long, 0ul>>::__visit_invoke(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>>(std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x205e6d8)
#11 0x0000ffffaa235c2c Fortran::semantics::ResolveOmpParts(Fortran::semantics::SemanticsContext&, Fortran::parser::ProgramUnit const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x2055c2c)
#12 0x0000ffffaa2b070c Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::ProgramUnit const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x20d070c)
#13 0x0000ffffaa2b1024 Fortran::semantics::ResolveNames(Fortran::semantics::SemanticsContext&, Fortran::parser::Program const&, Fortran::semantics::Scope&) (/path/to/install/lib/libFortranSemantics.so.19git+0x20d1024)
#14 0x0000ffffaa324b44 Fortran::semantics::Semantics::Perform() (/path/to/install/lib/libFortranSemantics.so.19git+0x2144b44)
#15 0x0000ffffb01d2b34 Fortran::frontend::FrontendAction::runSemanticChecks() (/path/to/install/lib/libflangFrontend.so.19git+0x192b34)
#16 0x0000ffffb028f108 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/path/to/install/lib/libflangFrontend.so.19git+0x24f108)
#17 0x0000ffffb01d2180 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/path/to/install/lib/libflangFrontend.so.19git+0x192180)
#18 0x0000ffffb01c63f8 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/path/to/install/lib/libflangFrontend.so.19git+0x1863f8)
#19 0x0000ffffb0745020 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/path/to/install/lib/libflangFrontendTool.so.19git+0x5020)
#20 0x0000000000405eb8 fc1_main(llvm::ArrayRef<char const*>, char const*) (/path/to/install/bin/flang-new+0x405eb8)
#21 0x0000000000404ae0 main (/path/to/install/bin/flang-new+0x404ae0)
#22 0x0000ffffaed94384 __libc_start_main (/lib64/libc.so.6+0x24384)
#23 0x0000000000404d28 _start (/path/to/install/bin/flang-new+0x404d28)
flang-new: error: unable to execute command: Aborted (core dumped)
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git db8b76dbb07d4053a4e44baf1518c9ea0d84c844)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
flang-new: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-new: note: diagnostic msg: /tmp/test-3ec075
flang-new: note: diagnostic msg: /tmp/test-3ec075.sh
flang-new: note: diagnostic msg: 

********************
$ gfortran-13.2 test.f90 -fopenmp
test.f90:4:13:

    4 | allocatable a ! may not have both the POINTER and ALLOCATABLE attributes
      |             1
Error: ALLOCATABLE attribute conflicts with POINTER attribute at (1)
llvmbot commented 6 months ago

@llvm/issue-subscribers-openmp

Author: Yusuke MINATO (yus3710-fj)

This is an issue from Fujitsu testsuite. Flang-new terminates abnormally when compiling a `threadprivate` directive with wrong arguments. The following are the test program and the compilation results of flang-new and gfortran. (I believe function references can't be threadprivate variables, but gfortran-13.2 seems to accept it.) ```fortran ! test.f90 !$omp threadprivate(a,b) integer,pointer :: a allocatable a ! may not have both the POINTER and ALLOCATABLE attributes external b ! function references can't be threadprivate variables end ``` ```console $ flang-new -v test.f90 -fopenmp flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git db8b76dbb07d4053a4e44baf1518c9ea0d84c844) Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /path/to/install/bin Found candidate GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12 Selected GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12 Candidate multilib: .;@m64 Selected multilib: .;@m64 "/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-4eed2d.o -x f95-cpp-input test.f90 fatal internal error: SemanticsContext::FindScope(): invalid source location for 'threadprivate(a,b)' PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: /path/to/install/bin/flang-new -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-4eed2d.o -x f95-cpp-input test.f90 #0 0x0000ffffaf356dc8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/path/to/install/lib/libLLVMSupport.so.19git+0x1a6dc8) #1 0x0000ffffaf354cf8 llvm::sys::RunSignalHandlers() (/path/to/install/lib/libLLVMSupport.so.19git+0x1a4cf8) #2 0x0000ffffaf354e7c SignalHandler(int) Signals.cpp:0:0 #3 0x0000ffffb1d207a0 (linux-vdso.so.1+0x7a0) #4 0x0000ffffaeda6274 raise (/lib64/libc.so.6+0x36274) #5 0x0000ffffaed90a2c abort (/lib64/libc.so.6+0x20a2c) #6 0x0000ffffa63d241c (/path/to/install/lib/libFortranCommon.so.19git+0x241c) #7 0x0000ffffaa320fac (/path/to/install/lib/libFortranSemantics.so.19git+0x2140fac) #8 0x0000ffffaa23ecf8 std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<void (*)(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct>(std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&)>, std::tuple<std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&>, std::integer_sequence<unsigned long, 4ul>>::__visit_invoke(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct>(std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x205ecf8) #9 0x0000ffffaa23df68 void Fortran::parser::ForEachInTuple<0ul, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&), std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)) (/path/to/install/lib/libFortranSemantics.so.19git+0x205df68) #10 0x0000ffffaa23e6d8 std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<void (*)(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>>(std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&)>, std::tuple<std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&>, std::integer_sequence<unsigned long, 0ul>>::__visit_invoke(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>>(std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x205e6d8) #11 0x0000ffffaa235c2c Fortran::semantics::ResolveOmpParts(Fortran::semantics::SemanticsContext&, Fortran::parser::ProgramUnit const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x2055c2c) #12 0x0000ffffaa2b070c Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::ProgramUnit const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x20d070c) #13 0x0000ffffaa2b1024 Fortran::semantics::ResolveNames(Fortran::semantics::SemanticsContext&, Fortran::parser::Program const&, Fortran::semantics::Scope&) (/path/to/install/lib/libFortranSemantics.so.19git+0x20d1024) #14 0x0000ffffaa324b44 Fortran::semantics::Semantics::Perform() (/path/to/install/lib/libFortranSemantics.so.19git+0x2144b44) #15 0x0000ffffb01d2b34 Fortran::frontend::FrontendAction::runSemanticChecks() (/path/to/install/lib/libflangFrontend.so.19git+0x192b34) #16 0x0000ffffb028f108 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/path/to/install/lib/libflangFrontend.so.19git+0x24f108) #17 0x0000ffffb01d2180 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/path/to/install/lib/libflangFrontend.so.19git+0x192180) #18 0x0000ffffb01c63f8 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/path/to/install/lib/libflangFrontend.so.19git+0x1863f8) #19 0x0000ffffb0745020 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/path/to/install/lib/libflangFrontendTool.so.19git+0x5020) #20 0x0000000000405eb8 fc1_main(llvm::ArrayRef<char const*>, char const*) (/path/to/install/bin/flang-new+0x405eb8) #21 0x0000000000404ae0 main (/path/to/install/bin/flang-new+0x404ae0) #22 0x0000ffffaed94384 __libc_start_main (/lib64/libc.so.6+0x24384) #23 0x0000000000404d28 _start (/path/to/install/bin/flang-new+0x404d28) flang-new: error: unable to execute command: Aborted (core dumped) flang-new: error: flang frontend command failed due to signal (use -v to see invocation) flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git db8b76dbb07d4053a4e44baf1518c9ea0d84c844) Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /path/to/install/bin flang-new: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: flang-new: note: diagnostic msg: /tmp/test-3ec075 flang-new: note: diagnostic msg: /tmp/test-3ec075.sh flang-new: note: diagnostic msg: ******************** ``` ```console $ gfortran-13.2 test.f90 -fopenmp test.f90:4:13: 4 | allocatable a ! may not have both the POINTER and ALLOCATABLE attributes | 1 Error: ALLOCATABLE attribute conflicts with POINTER attribute at (1) ```
llvmbot commented 6 months ago

@llvm/issue-subscribers-flang-frontend

Author: Yusuke MINATO (yus3710-fj)

This is an issue from Fujitsu testsuite. Flang-new terminates abnormally when compiling a `threadprivate` directive with wrong arguments. The following are the test program and the compilation results of flang-new and gfortran. (I believe function references can't be threadprivate variables, but gfortran-13.2 seems to accept it.) ```fortran ! test.f90 !$omp threadprivate(a,b) integer,pointer :: a allocatable a ! may not have both the POINTER and ALLOCATABLE attributes external b ! function references can't be threadprivate variables end ``` ```console $ flang-new -v test.f90 -fopenmp flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git db8b76dbb07d4053a4e44baf1518c9ea0d84c844) Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /path/to/install/bin Found candidate GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12 Selected GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12 Candidate multilib: .;@m64 Selected multilib: .;@m64 "/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-4eed2d.o -x f95-cpp-input test.f90 fatal internal error: SemanticsContext::FindScope(): invalid source location for 'threadprivate(a,b)' PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: /path/to/install/bin/flang-new -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-4eed2d.o -x f95-cpp-input test.f90 #0 0x0000ffffaf356dc8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/path/to/install/lib/libLLVMSupport.so.19git+0x1a6dc8) #1 0x0000ffffaf354cf8 llvm::sys::RunSignalHandlers() (/path/to/install/lib/libLLVMSupport.so.19git+0x1a4cf8) #2 0x0000ffffaf354e7c SignalHandler(int) Signals.cpp:0:0 #3 0x0000ffffb1d207a0 (linux-vdso.so.1+0x7a0) #4 0x0000ffffaeda6274 raise (/lib64/libc.so.6+0x36274) #5 0x0000ffffaed90a2c abort (/lib64/libc.so.6+0x20a2c) #6 0x0000ffffa63d241c (/path/to/install/lib/libFortranCommon.so.19git+0x241c) #7 0x0000ffffaa320fac (/path/to/install/lib/libFortranSemantics.so.19git+0x2140fac) #8 0x0000ffffaa23ecf8 std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<void (*)(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct>(std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&)>, std::tuple<std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&>, std::integer_sequence<unsigned long, 4ul>>::__visit_invoke(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct>(std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x205ecf8) #9 0x0000ffffaa23df68 void Fortran::parser::ForEachInTuple<0ul, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&), std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)) (/path/to/install/lib/libFortranSemantics.so.19git+0x205df68) #10 0x0000ffffaa23e6d8 std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<void (*)(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>>(std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&)>, std::tuple<std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&>, std::integer_sequence<unsigned long, 0ul>>::__visit_invoke(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>>(std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x205e6d8) #11 0x0000ffffaa235c2c Fortran::semantics::ResolveOmpParts(Fortran::semantics::SemanticsContext&, Fortran::parser::ProgramUnit const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x2055c2c) #12 0x0000ffffaa2b070c Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::ProgramUnit const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x20d070c) #13 0x0000ffffaa2b1024 Fortran::semantics::ResolveNames(Fortran::semantics::SemanticsContext&, Fortran::parser::Program const&, Fortran::semantics::Scope&) (/path/to/install/lib/libFortranSemantics.so.19git+0x20d1024) #14 0x0000ffffaa324b44 Fortran::semantics::Semantics::Perform() (/path/to/install/lib/libFortranSemantics.so.19git+0x2144b44) #15 0x0000ffffb01d2b34 Fortran::frontend::FrontendAction::runSemanticChecks() (/path/to/install/lib/libflangFrontend.so.19git+0x192b34) #16 0x0000ffffb028f108 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/path/to/install/lib/libflangFrontend.so.19git+0x24f108) #17 0x0000ffffb01d2180 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/path/to/install/lib/libflangFrontend.so.19git+0x192180) #18 0x0000ffffb01c63f8 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/path/to/install/lib/libflangFrontend.so.19git+0x1863f8) #19 0x0000ffffb0745020 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/path/to/install/lib/libflangFrontendTool.so.19git+0x5020) #20 0x0000000000405eb8 fc1_main(llvm::ArrayRef<char const*>, char const*) (/path/to/install/bin/flang-new+0x405eb8) #21 0x0000000000404ae0 main (/path/to/install/bin/flang-new+0x404ae0) #22 0x0000ffffaed94384 __libc_start_main (/lib64/libc.so.6+0x24384) #23 0x0000000000404d28 _start (/path/to/install/bin/flang-new+0x404d28) flang-new: error: unable to execute command: Aborted (core dumped) flang-new: error: flang frontend command failed due to signal (use -v to see invocation) flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git db8b76dbb07d4053a4e44baf1518c9ea0d84c844) Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /path/to/install/bin flang-new: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: flang-new: note: diagnostic msg: /tmp/test-3ec075 flang-new: note: diagnostic msg: /tmp/test-3ec075.sh flang-new: note: diagnostic msg: ******************** ``` ```console $ gfortran-13.2 test.f90 -fopenmp test.f90:4:13: 4 | allocatable a ! may not have both the POINTER and ALLOCATABLE attributes | 1 Error: ALLOCATABLE attribute conflicts with POINTER attribute at (1) ```
harishch4 commented 3 months ago

Could you please check now, current flang-new seems to throw semantic errors(expected): https://godbolt.org/z/zsqxGvxo1

yus3710-fj commented 3 months ago

Thank you for the information. Your test code includes PROGRAM statement. Flang-new had already worked as expected for such a code even before I reported this issue. However, flang-new hasn't worked for the original program I wrote in the description yet.

kiranktp commented 3 months ago

@Thirumalai-Shaktivel [AMD] is looking into this issue.

Thirumalai-Shaktivel commented 2 months ago

This issue is fixed and is under internal review.

I get the following error, Hope it is intended

$ flang-new x.f90 -fopenmp
error: Semantic errors in x.f90
./x.f90:2:23: error: 'b' is a data object and may not be EXTERNAL
  !$omp threadprivate(a,b)
                        ^
./x.f90:3:20: error: The type of 'a' has already been implicitly declared
  integer,pointer :: a
                     ^
./x.f90:2:21: Implicit declaration of 'a'
  !$omp threadprivate(a,b)
                      ^
./x.f90:5:10: error: EXTERNAL attribute not allowed on 'b'
  external b ! function references can't be threadprivate variables
           ^
./x.f90:2:23: Implicit declaration of 'b'
  !$omp threadprivate(a,b)
                        ^