Page MenuHomePhabricator

[flang] Fix check for distinguishable operators/assignments
ClosedPublic

Authored by tskeith on Sep 8 2020, 6:01 PM.

Details

Summary

Change how generic operators and assignments are checked for
distinguishable procedures. Because of how they are invoked, available
type-bound generics and normal generics all have to be considered
together. This is different from how generic names are checked.

Move common part of checking into DistinguishabilityHelper so that it
can be used in both cases after the appropriate procedures have been
added.

Cache result of Procedure::Characterize(Symbol) in a map in
CheckHelper so that we don't have to worry about passing the
characterized Procedures around or the cost of recomputing them.

Add MakeOpName() to construct names for defined operators and assignment
for using in error messages. This eliminates the need for different
messages in those cases.

When the procedures for a defined operator or assignment are undistinguishable,
include the type name in the error message, otherwise it may be ambiguous.

Add missing check that procedures for defined operators are functions
and that their dummy arguments are INTENT(IN) or VALUE.

Diff Detail

Event Timeline

tskeith created this revision.Sep 8 2020, 6:01 PM
Herald added a project: Restricted Project. · View Herald Transcript
tskeith requested review of this revision.Sep 8 2020, 6:01 PM
tskeith updated this revision to Diff 290760.Sep 9 2020, 9:46 AM
  • Improve error message
tskeith edited the summary of this revision. (Show Details)Sep 9 2020, 9:48 AM
klausler accepted this revision.Sep 9 2020, 10:02 AM
This revision is now accepted and ready to land.Sep 9 2020, 10:02 AM
tskeith updated this revision to Diff 290966.Sep 10 2020, 7:21 AM
  • Use resolve96 for new test name
This revision was landed with ongoing or failed builds.Sep 10 2020, 7:40 AM
This revision was automatically updated to reflect the committed changes.

This commit missed adding a dependency from libFortranEvaluate and libFortranSemantics. Adding it back in introduces a circular dependency and so breaks shared library builds.

Here's the failure I see:

9789.701 [508/8/3577] Linking CXX shared library lib/libFortranEvaluate.so.12git
FAILED: : && /usr/local/bin/clang++ -fPIC -stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-string-conversion -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3  -stdlib=libc++ -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/flang_aarch64_ubuntu_clang/flang-aarch64-ubuntu-clang/build/./lib  -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libFortranEvaluate.so.12git -o lib/libFortranEvaluate.so.12git tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/call.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/characteristics.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/check-expression.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/common.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/complex.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/constant.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/expression.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/fold.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/fold-character.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/fold-complex.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/fold-designator.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/fold-integer.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/fold-logical.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/fold-real.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/formatting.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/host.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/initial-image.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/integer.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/intrinsics.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/intrinsics-library.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/logical.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/real.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/shape.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/static-data.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/tools.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/type.cpp.o tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/variable.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libFortranDecimal.so.12git  lib/libFortranParser.so.12git  lib/libFortranCommon.so.12git  lib/libLLVMSupport.so.12git  -Wl,-rpath-link,/home/flang_aarch64_ubuntu_clang/flang-aarch64-ubuntu-clang/build/lib && :
tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/tools.cpp.o: In function `Fortran::evaluate::AttachDeclaration(Fortran::parser::Message&, Fortran::semantics::Symbol const&)':
tools.cpp:(.text._ZN7Fortran8evaluate17AttachDeclarationERNS_6parser7MessageERKNS_9semantics6SymbolE+0xa0): undefined reference to `Fortran::semantics::Scope::GetName() const'
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

You can see the error on the shared library buildbot (still in the staging instance): http://lab.llvm.org:8014/builders/flang-aarch64-ubuntu-clang/builds/866/steps/build-unified-tree/logs/stdio.

If make libFortranEvaluate depend on libFortranSemantics in CMake, I get this more explicit error:

CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
  "FortranEvaluate" of type SHARED_LIBRARY
    depends on "FortranSemantics" (weak)
  "FortranSemantics" of type SHARED_LIBRARY
    depends on "FortranEvaluate" (weak)
At least one of these targets is not a STATIC_LIBRARY.  Cyclic dependencies are allowed only among static libraries.
CMake Generate step failed.  Build files cannot be regenerated correctly.

I've posted what I think is the fix over on https://reviews.llvm.org/D87505