aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Semantics/program-tree.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-10-10[flang] Fix references to destroyed objects (#111582)Peter Klausler1-4/+4
ProgramTree instances are created as the value of a local variable in the Pre(const parser::ProgramUnit &) member function in name resolution. But references to these ProgramTree instances can persist in SubprogramNameDetails symbol table entries that might survive that function call's lifetime, and lead to trouble later when (e.g.) expression semantics needs to deal with a possible forward reference in a function reference in an expression being processed later in expression checking. So put those ProgramTree instances into a longer-lived linked list within the SemanticsContext. Might fix some weird crashes reported on big-endian targets (AIX & Solaris).
2024-05-01[flang] Ensure all warning/portability messages are guarded by Should… ↵Peter Klausler1-1/+3
(#90518) …Warn() Many warning messages were being emitted unconditionally. Ensure that all warnings are conditional on a true result from a call to common::LanguageFeatureControl::ShouldWarn() so that it is easy for a driver to disable them all, or, in the future, to provide per-warning control over them.
2024-04-24[flang] Accept and ignore compiler directives between internal subpro… ↵Peter Klausler1-28/+58
(#89810) …grams The parser only recognizes compiler directives that appear within internal / module subprograms, not those that might appear between them. Extend to allow them between subprograms as well.
2023-10-24[flang][openacc] Allow acc routine at the top level (#69936)Valentin Clement (バレンタイン クレメン)1-0/+4
Some compilers allow the `$acc routine(<name>)` to be placed at the program unit level. To be compatible, this patch enables the use of acc routine at this level. These acc routine directives must have a name.
2022-09-23[flang] Fix spurious errors from MODULE subprogramsPeter Klausler1-0/+4
When an explicit MODULE procedure is defined in the same (sub)module as its interface, and the interface was defined in a generic interface of the same name, bogus errors about symbols already having been defined will ensue. Cleaning up this aspect of name resolution and symbol table management requires marking the place-holding SubprogramNameDetails symbols of explicit MODULE subprograms as such, ensuring that that attribute is not inherited if the SubprogramNameDetails symbol is recycled as a SubprogramDetails, and gathering some code that should have been common between BeginSubprogram() and BeginMpSubprogram() together in one new routine. Differential Revision: https://reviews.llvm.org/D134446
2022-04-25[flang] Avoid global name conflict when BIND(C,NAME=) is usedPeter Klausler1-2/+20
At the top level of program units in a source file, two subprograms are allowed to have the same name if at least one of them has a distinct interoperable binding name. F18's symbol table requires (most) symbols in a scope to have distinct names, though. Solve by using compiler-created names for the symbols of global scope subprograms that have interoperable binding names. Differential Revision: https://reviews.llvm.org/D124295
2022-04-16[flang] Add & use a better visit() (take 2)Peter Klausler1-15/+15
Adds flang/include/flang/Common/log2-visit.h, which defines a Fortran::common::visit() template function that is a drop-in replacement for std::visit(). Modifies most use sites in the front-end and runtime to use common::visit(). The C++ standard mandates that std::visit() have O(1) execution time, which forces implementations to build dispatch tables. This new common::visit() is O(log2 N) in the number of alternatives in a variant<>, but that N tends to be small and so this change produces a fairly significant improvement in compiler build memory requirements, a 5-10% improvement in compiler build time, and a small improvement in compiler execution time. Building with -DFLANG_USE_STD_VISIT causes common::visit() to be an alias for std::visit(). Calls to common::visit() with multiple variant arguments are referred to std::visit(), pending further work. This change is enabled only for GCC builds with GCC >= 9; an earlier attempt (D122441) ran into bugs in some versions of clang and was reverted rather than simply disabled; and it is not well tested with MSVC. In non-GCC and older GCC builds, common::visit() is simply an alias for std::visit().
2022-03-28Revert "[flang] Add & use a better visit()"Andrzej Warzynski1-15/+15
This reverts commit 2ab9990c9eb79682a4d4b183dfbc7612d3e55328. It has caused multiple build failures: * https://lab.llvm.org/buildbot/#/builders/177/builds/4346 * https://lab.llvm.org/buildbot/#/builders/180/builds/3803 * https://lab.llvm.org/buildbot/#/builders/175/builds/10419 * https://lab.llvm.org/buildbot/#/builders/191/builds/4318 * https://lab.llvm.org/buildbot/#/builders/173/builds/4274 * https://lab.llvm.org/buildbot/#/builders/181/builds/4297 All these bots failed with a time-out: ``` command timed out: 1200 seconds without output running [b'ninja', b'-j', b'32'], attempting to kill ``` I'm guessing that that's due to template instantiations failing at some point (https://reviews.llvm.org/D122441 introduced a custom implementation of std::visit). Everything seems fine when either: * building on X86 with GCC or Clang (tested with GCC 9.3 and Clang 12) * building on AArch64 with GCC (tested with GCC 11)
2022-03-25[flang] Add & use a better visit()Peter Klausler1-15/+15
Adds flang/include/flang/Common/visit.h, which defines a Fortran::common::visit() template function that is a drop-in replacement for std::visit(). Modifies most use sites in the front-end and runtime to use common::visit(). The C++ standard mandates that std::visit() have O(1) execution time, which forces implementations to build dispatch tables. This new common::visit() is O(log2 N) in the number of alternatives in a variant<>, but that N tends to be small and so this change produces a fairly significant improvement in compiler build memory requirements, a 5-10% improvement in compiler build time, and a small improvement in compiler execution time. Building with -DFLANG_USE_STD_VISIT causes common::visit() to be an alias for std::visit(). Calls to common::visit() with multiple variant arguments are referred to std::visit(), pending further work. Differential Revision: https://reviews.llvm.org/D122441
2022-02-11[flang] Fix edge case in USE-associated genericsPeter Klausler1-0/+37
It is generally an error when a USE-associated name clashes with a name defined locally, but not in all cases; a generic interface can be both USE-associated and locally defined. This works, but not when there is also a local subprogram with the same name, which is valid when that subprogram is a specific of the local generic. A bogus error issues at the point of the USE because name resolution will have already defined a symbol for the local subprogram. The solution is to collect the names of local generics when creating the program tree, and then create their symbols as well if their names are also local subprograms, prior to any USE association processing. Differential Revision: https://reviews.llvm.org/D119566
2022-01-14[flang] Accept ENTRY names in generic interfacesPeter Klausler1-1/+38
ENTRY statement names in module subprograms were not acceptable for use as a "module procedure" in a generic interface, but should be. ENTRY statements need to have symbols with place-holding SubprogramNameDetails created for them in order to be visible in generic interfaces. Those symbols are created from the "program tree" data structure. This patch adds ENTRY statement names to the program tree data structure and uses them to generate SubprogramNameDetails symbols. Differential Revision: https://reviews.llvm.org/D117345
2020-08-25[flang] Parse global compiler directivespeter klausler1-0/+4
Accept and represent "global" compiler directives that appear before and between program units in a source file. Differential Revision: https://reviews.llvm.org/D86555
2020-03-28[flang] Reformat with latest clang-format and .clang-formatTim Keith1-14/+14
Original-commit: flang-compiler/f18@9fe84f45d7fd685051004678d6b5775dcc4c6f8f Reviewed-on: https://github.com/flang-compiler/f18/pull/1094
2020-02-25[flang] [LLVMify F18] Compiler module folders should have capitalised names ↵CarolineConcatto1-0/+192
(flang-compiler/f18#980) This patch renames the modules in f18 to use a capital letter in the module name Signed-off-by: Caroline Concatto <caroline.concatto@arm.com> Original-commit: flang-compiler/f18@d2eb7a1c443d1539ef12b6f027074a0eb15b1ea0 Reviewed-on: https://github.com/flang-compiler/f18/pull/980