aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Semantics/mod-file.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-12-05[flang] Map symbols in expressions when copying interface symbolsPeter Klausler1-1/+4
Given a MODULE SUBROUTINE or MODULE FUNCTION interface followed later by a corresponding separate module subprogram definition in a MODULE PROCEDURE, the copies of the interface's dummy argument and function result symbols that populate the initial scope of that MODULE PROCEDURE need to have any symbol references in their types or bounds adjusted to point to their new counterparts. Differential Revision: https://reviews.llvm.org/D139200
2022-12-04[flang] Don't propagate PRIVATE into submodule module filesPeter Klausler1-8/+12
Module files for submodules should not contain PRIVATE attributes, since everything in them is local to the parent module and accessible to all descendant submodules. Differential Revision: https://reviews.llvm.org/D139160
2022-12-03[flang] Don't repeat module procedure interface from ancestor in *.mod filePeter Klausler1-1/+6
When a submodule defines a module procedure whose interface was declared in an ancestor (sub)module, don't repeat the definition of that interface in the submodule's *.mod file output. Differential Revision: https://reviews.llvm.org/D139132
2022-12-02[flang] Restore ENUM_CLASS() to be compilation-time codePeter Klausler1-2/+2
Rework some recent changes to the ENUM_CLASS() macro so that all of the construction of enumerator-to-name string mapping data structures is again performed at compilation time. Differential Revision: https://reviews.llvm.org/D137859
2022-11-03[Flang] Run clang-format on all flang filesPeter Steinfeld1-1/+1
This will make it easier for me to do reviews. Differential Revision: https://reviews.llvm.org/D137291
2022-08-25[flang] Emit missing IMPORTs in module file interfacesPeter Klausler1-0/+8
When a symbol from the enclosing scope is necessary to declare a procedure or procedure pointer dummy argument or function result for a procedure interface, note it in the collection of symbols to be imported when scanning that interface. Differential Revision: https://reviews.llvm.org/D132683
2022-08-18[flang] Be more persistent in search for non-intrinsic module filePeter Klausler1-22/+37
When a particular module name has been brought into a compilation as an intrinsic module via USE,INTRINSIC, perhaps indirectly via an enclosing USE statement, f18 will resolve later USE statements to it unless they are USE,NON_INTRINSIC. This is not entirely correct -- a bare USE statement for a module name that happens to match that of an intrinsic module should still search the search paths for a non-intrinsic module file of the same name. Differential Revision: https://reviews.llvm.org/D132163
2022-08-09[flang] Don't lose homonymous specific when copying genericPeter Klausler1-2/+3
Defined generic procedure interfaces are allowed to shadow non-generic procedures of the same name in the same scope (whether or not that non-generic procedure is a specific procedure of the generic). When making a copy of a generic interface symbol so that it can be locally modified or be merged with another generic, don't forget about the homonymous non-generic procedure that it might shadow. Differential Revision: https://reviews.llvm.org/D131103
2022-06-16[flang] Handle module subprogram with interface in same (sub)module when ↵Peter Klausler1-1/+7
writing module file There's a few (3) cases where Fortran allows two distinct symbols to have the same name in the same scope. Module file output copes with only two of them. The third involves a separate module procedure that isn't separate: both the procedure and its declared interface appear in the same (sub)module. Fix to ensure that the interface is included in the module file output, so that the module file reader doesn't suffer a bogus error about a "separate module procedure without an interface". Differential Revision: https://reviews.llvm.org/D127784
2022-06-03[flang] Distinguish intrinsic module USE in module files; correct search pathsPeter Klausler1-2/+9
In the USE statements that f18 emits to module files, ensure that symbols from intrinsic modules are marked as such on their USE statements. And ensure that the current working directory (".") cannot override the intrinsic module search path when trying to locate an intrinsic module. Differential Revision: https://reviews.llvm.org/D127019
2022-05-28[flang] Avoid spurious warnings from reading module filesPeter Klausler1-0/+4
When processing the literal constants of the various kinds of INTEGER that are too large by 1 (e.g., 2147483648_4) in expression analysis, emit a portability warning rather than a fatal error if the literal constant appears as the operand to a unary minus, since the folded result will be in range. And don't emit any warning if the negated literal is coming from a module file -- f18 wrote the module file and the warning would simply be confusing, especially to the programmer that wrote (-2147483647_4-1) in the first place. Further, emit portability warnings for the canonical expressions for infinities and NaN (-1./0., 0./0., & 1./0.), but not when they appear in a module file, for the same reason. The Fortran language has no syntax for these special values so we have to emit expressions that fold to them. Fixes LLVM bugs https://github.com/llvm/llvm-project/issues/55086 and https://github.com/llvm/llvm-project/issues/55081. Differential Revision: https://reviews.llvm.org/D126584
2022-05-23[flang] Allow global scope names that clash with intrinsic modulesPeter Klausler1-9/+26
Intrinsic module names are not in the user's namespace, so they are free to declare global names that conflict with intrinsic modules. Differential Revision: https://reviews.llvm.org/D126140
2022-04-26[flang] Fix crash from PDT component init in module filePeter Klausler1-4/+5
Semantics now needs to preserve the parse trees from module files, in case they contain parameterized derived type definitions with component initializers that may require re-analysis during PDT instantiation. Save them in the SemanticsContext. Differential Revision: https://reviews.llvm.org/D124467
2022-04-16[flang] Add & use a better visit() (take 2)Peter Klausler1-94/+95
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-04-15[flang] Handle parameter-dependent types in PDT initializersPeter Klausler1-10/+13
For parameterized derived type component initializers whose expressions' types depend on parameter values, f18's current scheme of analyzing the initialization expression once during name resolution fails. For example, type :: pdt(k) integer, kind :: k real :: component = real(0.0, kind=k) end type To handle such cases, it is necessary to re-analyze the parse trees of these initialization expressions once for each distinct initialization of the type. This patch adds code to wipe an expression parse tree of its typed expressions, and update those of its symbol table pointers that reference type parameters, and then re-analyze that parse tree to generate the properly typed component initializers. Differential Revision: https://reviews.llvm.org/D123728
2022-04-09[flang] Support export/import OpenMP Threadprivate FlagPeixin-Qiao1-1/+7
The information about OpenMP/OpenACC declarative directives in modules should be carried in export mod files. This supports export OpenMP Threadprivate directive and import OpenMP declarative directives. Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D120396
2022-03-28Revert "[flang] Add & use a better visit()"Andrzej Warzynski1-90/+89
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-89/+90
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-03-16[flang] Include missing internal interfaces in .mod filesEmil Kieri1-0/+24
Interfaces which are internal to a procedure need to be included in module files if (and only if) they are referenced in the interface of the procedure. That is, they are needed if they are the interfaces of dummy or return value procedures. Fixes #53420 Differential Revision: https://reviews.llvm.org/D121738
2022-03-08[flang] Distinguish usage and portability warning messagesPeter Klausler1-1/+1
Using recently established message severity codes, upgrade non-fatal messages to usage and portability warnings as appropriate. Differential Revision: https://reviews.llvm.org/D121246
2022-03-08[flang] Add nonfatal message classesPeter Klausler1-1/+2
F18 presently has fatal and non-fatal diagnostic messages. We'd like to make non-fatal warnings stand out better in the output of the compiler. This will turn out to be a large change that affects many files. This patch is just the first part. It converts a Boolean isFatal_ data member of the message classes into a severity code, and defines four of these codes (Error, Warning, Portability, and a catch-all Other). Later patches will result from sweeping over the parser and semantics, changing most non-fatal diagnostic messages into warnings and portability notes. Differential Revision: https://reviews.llvm.org/D121228
2022-03-07[flang] Fix module file missing USE for shadowed derived typePeter Klausler1-1/+11
When a module uses a derived type that is shadowed by a generic interface, the module file was missing a USE statement for the name. Detect and handle this situation. Differential Revision: https://reviews.llvm.org/D121160
2022-01-31[flang] Distinguish intrinsic from non-intrinsic modulesPeter Klausler1-9/+44
For "USE, INTRINSIC", search only for intrinsic modules; for "USE, NON_INTRINSIC", do not recognize intrinsic modules. Allow modules of both kinds with the same name to be used in the same source file (but not in the same scoping unit, a constraint of the standard that is now enforced). The symbol table's scope tree now has a single instance of a scope with a new kind, IntrinsicModules, whose children are the USE'd intrinsic modules (explicit or not). This separate "top-level" scope is a child of the single global scope and it allows both intrinsic and non-intrinsic modules of the same name to exist in the symbol table. Intrinsic modules' scopes' symbols now have the INTRINSIC attribute set. The search path directories need to make a distinction between regular directories and the one(s) that point(s) to intrinsic modules. I allow for multiple intrinsic module directories in the second search path, although only one is needed today. Differential Revision: https://reviews.llvm.org/D118631
2022-01-13[flang] Implement semantics for DEC STRUCTURE/RECORDPeter Klausler1-16/+110
Implements part of the legacy "DEC structures" feature from VMS Fortran. STRUCTUREs are processed as if they were derived types with SEQUENCE. DATA-like object entity initialization is supported as well (e.g., INTEGER FOO/666/) since it was used for default component initialization in structures. Anonymous components (named %FILL) are also supported. These features, and UNION/MAP, were already being parsed. An omission in the collection of structure field names in the case of nested structures with entity declarations was fixed in the parser. Structures are supported in modules, but this is mostly for testing purposes. The names of fields in structures accessed via USE association cannot appear with dot notation in client code (at least not yet). DEC structures antedate Fortran 90, so their actual use in applications should not involve modules. This patch does not implement UNION/MAP, since that feature would impose difficulties later in lowering them to MLIR types. In the meantime, if they appear, semantics will issue a "not yet implemented" error message. Differential Revision: https://reviews.llvm.org/D117151
2021-12-01[flang] Adjust names in Semantics that imply too much (NFC)Peter Klausler1-7/+7
Some kinds of Fortran arrays are declared with the same syntax, and it is impossible to tell from a shape (:, :) or (*) whether the object is assumed shape, deferred shape, assumed size, implied shape, or whatever without recourse to more information about the symbol in question. This patch softens the names of some predicate functions (IsAssumedShape to CanBeAssumedShape) and makes others more reflective of the syntax they represent (isAssumed to isStar) in an attempt to encourage coders to seek and find definitive predicate functions whose names deliver what they seem to mean. Address TODO comments in IsSimplyContiguous() by using the updated IsAssumedShape() predicate. Differential Revision: https://reviews.llvm.org/D114829
2021-09-29[flang] Make builtin types more easily accessible; use thempeter klausler1-5/+8
Rearrange the contents of __builtin_* module files a little and make sure that semantics implicitly USEs the module __Fortran_builtins before processing each source file. This ensures that the special derived types for TEAM_TYPE, EVENT_TYPE, LOCK_TYPE, &c. exist in the symbol table where they will be available for use in coarray intrinsic function processing. Update IsTeamType() to exploit access to the __Fortran_builtins module rather than applying ad hoc name tests. Move it and some other utilities from Semantics/tools.* to Evaluate/tools.* to make them available to intrinsics processing. Add/correct the intrinsic table definitions for GET_TEAM, TEAM_NUMBER, and THIS_IMAGE to exercise the built-in TEAM_TYPE as an argument and as a result. Add/correct/extend tests accordingly. Differential Revision: https://reviews.llvm.org/D110356
2021-09-01[flang] Include default component initialization in static initializerspeter klausler1-1/+15
The combined initializers constructed from DATA statements and explicit static initialization in declarations needs to include derived type component default initializations, overriding those default values without complaint with values from explicit DATA statement or declaration initializations when they overlap. This also has to work for objects with storage association due to EQUIVALENCE. When storage association causes default component initializations to overlap, emit errors if and only if the values differ (See Fortran 2018 subclause 19.5.3, esp. paragraph 10). The f18 front-end has a module that analyzes and converts DATA statements into equivalent static initializers for objects. For storage-associated objects, compiler-generated objects are created that overlay the entire association and fill it with a combined initializer. This "data-to-inits" module already exists, and this patch is essentially extension and clean-up of its machinery to complete the job. Also: emit EQUIVALENCE to module files; mark compiler-created symbols and *don't* emit those to module files; check non-static EQUIVALENCE sets for conflicting default component initializations, so lowering doesn't have to check them or emit diagnostics. Differential Revision: https://reviews.llvm.org/D109022
2021-04-10[flang] Accept & fold IEEE_SELECTED_REAL_KINDpeter klausler1-0/+3
F18 supports the standard intrinsic function SELECTED_REAL_KIND but not its synonym in the standard module IEEE_ARITHMETIC named IEEE_SELECTED_REAL_KIND until this patch. Differential Revision: https://reviews.llvm.org/D100066
2021-03-24[flang] Save binding labels as stringsTim Keith1-14/+6
Binding labels start as expressions but they have to evaluate to constant character of default kind, so they can be represented as an std::string. Leading and trailing blanks have to be removed, so the folded expression isn't exactly right anyway. So all BIND(C) symbols now have a string binding label, either the default or user-supplied one. This is recorded in the .mod file. Add WithBindName mix-in for details classes that can have a binding label so that they are all consistent. Add GetBindName() and SetBindName() member functions to Symbol. Add tests that verifies that leading and trailing blanks are ignored in binding labels and that the default label is folded to lower case. Differential Revision: https://reviews.llvm.org/D99208
2021-03-24Revert "[flang] Save binding labels as strings"Tim Keith1-6/+14
This reverts commit eb4ad0e3e3635194c21dccdd1c52027e632d2996. This was causing a crash compiling omp_lib.f90
2021-03-24[flang] Save binding labels as stringsTim Keith1-14/+6
Binding labels start as expressions but they have to evaluate to constant character of default kind, so they can be represented as an std::string. Leading and trailing blanks have to be removed, so the folded expression isn't exactly right anyway. So all BIND(C) symbols now have a string binding label, either the default or user-supplied one. This is recorded in the .mod file. Add WithBindName mix-in for details classes that can have a binding label so that they are all consistent. Add GetBindName() and SetBindName() member functions to Symbol. Add tests that verifies that leading and trailing blanks are ignored in binding labels and that the default label is folded to lower case. Differential Revision: https://reviews.llvm.org/D99208
2021-03-18[flang] Refine symbol sortingpeter klausler1-3/+4
Replace semantics::SymbolSet with alternatives that clarify whether the set should order its contents by source position or not. This matters because positionally-ordered sets must not be used for Symbols that might be subjected to name replacement during name resolution, and address-ordered sets must not be used (without sorting) in circumstances where the order of their contents affects the output of the compiler. All set<> and map<> instances in the compiler that are keyed by Symbols now have explicit Compare types in their template instantiations. Symbol::operator< is no more. Differential Revision: https://reviews.llvm.org/D98878
2021-02-11[flang] Improve "Error reading module file" error messagepeter klausler1-7/+7
Instead of using a message attachment with further details, emit the details as part of a single message. Differential Revision: https://reviews.llvm.org/D96465
2021-01-14[flang] Fix some module file issues exposed by Whizardpeter klausler1-24/+55
Generic type-bound interfaces for user-defined operators need to be formatted as "OPERATOR(.op.)", not just ".op." PRIVATE generics need to be marked as such. Declaration ordering: when a generic interface shadows a derived type of the same name, it needs to be emitted to the module file at the point of definition of the derived type; otherwise, the derived type's definition may appear after its first use. The module symbol for a module read from a module file needs to be marked as coming from a module file before semantic processing is performed on the contents of the module so that any special handling for declarations in module files can be properly activated. IMPORT statements were sometimes missing for use-associated symbols in surrounding scopes; fine-tune NeedImport(). Differential Revision: https://reviews.llvm.org/D94636
2021-01-13[flang] Fix accessibility of USEd name in .mod fileTim Keith1-0/+1
If a module specifies default private accessibility, names that have been use-associated are private by default. This was not reflected in .mod files. Differential Revision: https://reviews.llvm.org/D94602
2020-12-28[flang] Fix bugs in .mod file for abstract interfaceTim Keith1-1/+10
When an abstract interface is defined, add the ABSTRACT attribute to subprogram symbols that define the interface body. Make use of that when writing .mod files to include "abstract" on the interface statement. Also, fix a problem with the order of symbols in a .mod file. Sometimes a name is mentioned before the "real" declaration, e.g. in an access statement. We want the order to be based on the real definitions. In these cases we replace the symbol name with an identical name with a different source location. Then by sorting based on the source location we get symbols in the right order. Differential Revision: https://reviews.llvm.org/D93572
2020-12-02[flang] Fix bugs related to merging generics during USETim Keith1-9/+19
When the same generic name is use-associated from two modules, the generics are merged into a single one in the current scope. This change fixes some bugs in that process. When a generic is merged, it can have two specific procedures with the same name as the generic (c.f. module m7c in modfile07.f90). We were disallowing that by checking for duplicate names in the generic rather than duplicate symbols. Changing `namesSeen` to `symbolsSeen` in `ResolveSpecificsInGeneric` fixes that. We weren't including each USE of those generics in the .mod file so in some cases they were incorrect. Extend GenericDetails to specify all use-associated symbols that are merged into the generic. This is used to write out .mod files correctly. The distinguishability check for specific procedures of a generic sometimes have to refer to procedures from a use-associated generic in error messages. In that case we don't have the source location of the procedure so adapt the message to say where is was use-associated from. This requires passing the scope through the checks to make that determination. Differential Revision: https://reviews.llvm.org/D92492
2020-09-30[flang] Semantic analysis for FINAL subroutinespeter klausler1-5/+15
Represent FINAL subroutines in the symbol table entries of derived types. Enforce constraints. Update tests that have inadvertent violations or modified messages. Added a test. The specific procedure distinguishability checking code for generics was used to enforce distinguishability of FINAL procedures. (Also cleaned up some confusion and redundancy noticed in the type compatibility infrastructure while digging into that area.) Differential revision: https://reviews.llvm.org/D88613
2020-09-02[flang] Support multiple CookedSource instancespeter klausler1-2/+1
These are owned by an instance of a new class AllCookedSources. This removes the need for a Scope to own a string containing a module's cooked source stream, and will enable errors to be emitted when parsing module files in the future. Differential Revision: https://reviews.llvm.org/D86891
2020-07-13[flang] Use octal escapes for character literals in modfilesTim Keith1-0/+4
Character literals can be formatted using octal or hex escapes for non-ascii characters. This is so that the program can be unparsed for either pgf90 or gfortran to compile. But modfiles should not be affected by that -- they should be consistent. This changes causes modfiles to always have character literals formatted with octal escapes. Differential Revision: https://reviews.llvm.org/D83703
2020-06-18[flang] Fix crash with alternate returns in modulesPete Steinfeld1-2/+8
Summary: We weren't handling the case of subroutines with alternate returns that are contained in modules. I changed the code to add an `*` as the name of the parameter when creating the `.mod` file. Reviewers: tskeith, klausler, DavidTruby Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D82096
2020-05-29[flang][NFC] Remove link-time dependency of Evaluate on SemanticsTim Keith1-1/+1
Summary: Some Symbol-related functions used in Evaluate were moved to Evaluate/tools.h. This includes changing some member functions that were replaced by non-member functions `IsDummy`, `GetUsedModule`, and `CountLenParameters`. Some member functions were made inline in `Scope`, `Symbol`, `ArraySpec`, and `DeclTypeSpec`. The definitions were preceded by a comment explaining why they are inline. `IsConstantShape` was expanded inline in `IsDescriptor` because it isn't used anywhere else After this change, at least when compiling with clang on macos, `libFortranEvaluate.a` has no undefined symbols that are satisfied by `libFortranSemantics.a`. Reviewers: klausler, PeteSteinfeld, sscalpone, jdoerfert, DavidTruby Reviewed By: PeteSteinfeld Subscribers: llvm-commits Tags: #flang, #llvm Differential Revision: https://reviews.llvm.org/D80762
2020-05-11[flang] Fix bug with IMPORT of USE of USETim Keith1-1/+1
When a module contained an import of a use-association of a use-association, we weren't recognizing that the symbols was needed. The fix is the follow all of the use-associations using `GetUltimate()`. Differential Revision: https://reviews.llvm.org/D79737
2020-05-06[flang][NFC] Add accessors to equivalence and common blocksTim Keith1-4/+4
Add a way to get mutable equivalence sets to Scope so that they can have sizes and offsets assigned to them. Change CommonBlockDetails to have mutable symbols so that they can have sizes and offets assigned to them. This also allows the removal of some `const_cast`s. Add MutableSymbolRef and MutableSymbolVector as mutable analogs to SymbolRef and SymbolVector. Replace uses of equivalent types with those names. Differential Revision: https://reviews.llvm.org/D79346
2020-04-23[flang] Compute sizes and offsets for symbolsTim Keith1-23/+12
Summary: Add size and offset properties to symbols, representing their byte size and offset within their enclosing scope. Add size and align properties to scopes so that they are available for scopes representing derived types. Add ComputeOffsets pass over the symbol table to fill in those fields. Compute descriptor size based on rank and length parameters. Extract DerivedTypeSpec::NumLengthParameters from DynamicType::RequiresDescriptor to share the code. Add Scope::GetSymbols to get symbols in canonical order. compute-offsets.cpp and mod-file.cpp both need to process symbols in the order in which they are declared. Move the collecting of those symbols into Scope so that it can be shared. Add symbol size and offset to output of `-fdebug-dump-symbols` and use that in some tests. Still to do: - make size and alignment rules configurable based on target - use offsets to check EQUIVALENCE statements Differential Revision: https://reviews.llvm.org/D78680
2020-03-28[flang] Reformat with latest clang-format and .clang-formatTim Keith1-120/+121
Original-commit: flang-compiler/f18@9fe84f45d7fd685051004678d6b5775dcc4c6f8f Reviewed-on: https://github.com/flang-compiler/f18/pull/1094
2020-03-24[flang] Semantics for ENTRYpeter klausler1-6/+8
initial test passes Move some checks to check-declarations Fix bugs found in testing Get tests all passing Allow declaration statements for function result to follow ENTRY Fix another bug Original-commit: flang-compiler/f18@e82cfee4325f90e3c6ed08e797fa940259948ffd Reviewed-on: https://github.com/flang-compiler/f18/pull/1086
2020-03-24[flang] Replace manual mmap with llvm::MemoryBufferDavid Truby1-3/+3
The previous code had handling for cases when too many file descriptors may be opened; this is not necessary with MemoryBuffer as the file descriptors are closed after the mapping occurs. MemoryBuffer also internally handles the case where a file is small and therefore an mmap is bad for performance; such files are simply copied to memory after being opened. Many places elsewhere in the code assume that the buffer is not empty, and the old file opening code handles this by replacing an empty file with a buffer containing a single newline. That behavior is now kept in the new MemoryBuffer based code. Original-commit: flang-compiler/f18@d34df8435127d847867e2c0bb157def9f20f4202 Reviewed-on: https://github.com/flang-compiler/f18/pull/1032
2020-03-19[flang] [LLVMify F18] Replace the use std::ostream with LLVM streams ↵Caroline Concatto1-44/+52
llvm::ostream This patch replaces the occurrence of std::ostream by llvm::raw_ostream. In LLVM Coding Standards[1] "All new code should use raw_ostream instead of ostream".[1] As a consequence, this patch also replaces the use of: std::stringstream by llvm::raw_string_ostream or llvm::raw_ostream* std::ofstream by llvm::raw_fd_ostream std::endl by '\n' and flush()[2] std::cout by llvm::outs() and std::cerr by llvm::errs() It also replaces std::strerro by llvm::sys::StrError** , but NOT in Fortran runtime libraries *std::stringstream were replaced by llvm::raw_ostream in all methods that used std::stringstream as a parameter. Moreover, it removes the pointers to these streams. [1]https://llvm.org/docs/CodingStandards.html [2]https://releases.llvm.org/2.5/docs/CodingStandards.html#ll_avoidendl Signed-off-by: Caroline Concatto <caroline.concatto@arm.com> Running clang-format-7 Signed-off-by: Caroline Concatto <caroline.concatto@arm.com> Removing residue of ostream library Signed-off-by: Caroline Concatto <caroline.concatto@arm.com> Original-commit: flang-compiler/f18@a3507d44b8911e6024033aa583c1dc54e0eb89fd Reviewed-on: https://github.com/flang-compiler/f18/pull/1047
2020-03-05[flang] Use a file descriptor in Temp struct (flang-compiler/f18#1036)Steve Scalpone1-4/+5
The struct Temp is used in the function call createUniqueFile which only takes in a file descriptor instead of a file handler. In Unix these are the same thing, but in Windows they are different. Therefore, the type of the member of struct Temp is changed from file handler to file descriptor and when closing the file the file descriptor is converted to a file handler. Original-commit: flang-compiler/f18@a8edb328f717305143ac827132c6d6f45e6e11b9 Reviewed-on: https://github.com/flang-compiler/f18/pull/1036