Commit Graph

2739 Commits

Author SHA1 Message Date
Sourabh Singh Tomar 932aae77e9 Revert D86875 "[Flang][NFC] Remove license comments from files in docs/ folder."
This reverts commit f787c9a90c, this was causing some build issues.
2020-09-10 23:04:37 +05:30
Tim Keith 82edd428f1 [flang] Fix check for distinguishable operators/assignments
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.

Differential Revision: https://reviews.llvm.org/D87341
2020-09-10 07:22:55 -07:00
compinder 5ec043eae1 [FLANG] Generate error for invalid selector.
Fix of PR47339

Differential Revision: https://reviews.llvm.org/D87073/new/
2020-09-09 19:14:54 +05:30
Diana Picus d4b88ac165 [cmake] Use absolute paths for modules search
For out of tree builds, the user generally needs to specify LLVM_DIR and
MLIR_DIR on the command line so that the correct LLVM and MLIR
installations are picked up.

If the provided paths are absolute, everything works fine, however for
buildbots it is customary to work with relative paths, and that makes it
difficult for CMake to find the right modules to include.

This patch changes CMakeLists.txt to convert LLVM_DIR and MLIR_DIR to
absolute paths before adding them to CMAKE_MODULE_PATH. The inputs are
assumed to be relative to the source directory (llvm-project/flang).

Differential Revision: https://reviews.llvm.org/D87083
2020-09-09 13:56:19 +02:00
Irina Dobrescu 0fd425af07 [flang]Add Semantic Checks for OpenMP Allocate Clause
Reviewed By: kiranchandramohan, clementval, kiranktp, raghavendhra

Differential Revision: https://reviews.llvm.org/D86051
2020-09-09 12:06:21 +01:00
Michael Kruse c58dfbdc81 [flang][msvc] Avoid range-based for over initializer_list. NFC.
Msvc crashes with "INTERNAL COMPILER ERROR" when iterating over an `std::initializer_list` in a constexpr constructor. Explicitly use the iterator instead.

This patch is part of the series to [[ http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html | make flang compilable with MS Visual Studio ]].

Reviewed By: isuruf

Differential Revision: https://reviews.llvm.org/D86425
2020-09-09 00:22:36 -05:00
Richard Barton 69230e75f1 [flang] Convert release notes to markdown
Switch ReleaseNotes from .rst to .md to match the other docs.

At the same time, fix the version number for master.
2020-09-08 08:47:33 +01:00
Kiran Kumar T P 4536c6acb3 [flang][OpenMP] Enhance parser support for atomic construct to OpenMP 5.0
Summary:
This patch enhances parser support for atomic construct to OpenMP 5.0.
2.17.7 atomic -> ATOMIC [clause [,]] atomic-clause [[,] clause] |
                 ATOMIC [clause]
       clause -> memory-order-clause | HINT(hint-expression)
       memory-order-clause -> SEQ_CST | ACQ_REL | RELEASE | ACQUIRE | RELAXED
       atomic-clause -> READ | WRITE | UPDATE | CAPTURE

The patch includes code changes and testcase modifications.

Reviewed By: DavidTruby, kiranchandramohan, sameeranjoshi

Differential Revision: https://reviews.llvm.org/D82931
2020-09-08 06:52:07 +05:30
Richard Barton 7e5dab5fca [flang] Spelling and format edits to README.txt. NFC. 2020-09-07 16:49:08 +01:00
Richard Barton 2e1827271c [flang] Fix link to old repo location in doxygen mainpage. NFC. 2020-09-07 16:43:08 +01:00
peter klausler c963757783 [flang] Implement nonstandard OPEN statement CARRIAGECONTROL specifier
Differential Revision: https://reviews.llvm.org/D87052
2020-09-02 13:07:45 -07:00
peter klausler 92a5419786 [flang] Support multiple CookedSource instances
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-09-02 10:34:23 -07:00
peter klausler f80866bd4a [flang] Make -fget-symbols-sources output deterministic
The DumpSymbolsSources() routine ordered its output by the addresses
of the names of the symbols, and was susceptible to variation across
environments.  Fixed by using a multimap using the values of the names.

Differential Revision: https://reviews.llvm.org/D87035
2020-09-02 09:32:26 -07:00
Camille Coti b11c527816 [flang] Version information in flang/f18
Fixed some version information in flang/f18:

  - fixed the behavior of the -v switch: this flag enables verbosity with used with arguments, but just displays the version when used alone (related to this bug: https://bugs.llvm.org/show_bug.cgi?id=46017)
 - added __FLANG, __FLANG_MAJOR__, __FLANG_MINOR__ and __FLANG_PATCHLEVEL__ (similar to their __F18* counterparts) for compatibility purpose

Reviewed By: AlexisPerry, richard.barton.arm, tskeith

Differential Revision: https://reviews.llvm.org/D84334
2020-09-01 19:05:43 +01:00
peter klausler 11ddb84b69 [flang] Fix integer CASE constant typing
Don't use just 128-bit integer as the type for integer
CASE statement constants.  Use the actual type of the
literal constants that appeared.

Differential Review: https://reviews.llvm.org/D86875
2020-09-01 10:59:35 -07:00
peter klausler 1a633e72f6 [flang] Improve compile-time shape conformance checking
Conformance checking of the shapes of the operands of
array expressions can't, of course, always be done at
compilation time; but when the shapes are known and
nonconformable, we should catch the errors that we can.

Differential Revision: https://reviews.llvm.org/D86887
2020-09-01 08:51:50 -07:00
peter klausler f862d85807 [flang] Check shape conformance on initializers
Specifically, ensure that initializers conform with their objects
according to 8.2 para 4.

Differential Revision: https://reviews.llvm.org/D86886
2020-08-31 16:27:06 -07:00
peter klausler 4cbfd93a59 [flang] Make `TypeParamInquiry` monomorphic
Change the expression representation TypeParamInquiry from being
a class that's templatized on the integer KIND of its result into
a monomorphic representation that results in a SubscriptInteger
that can then be converted.

This is a minor simplification, but it's worth doing because
it is believed to also be a work-around for bugs in the MSVC
compiler with overload resolution that affect the expression
traversal framework.

Differential Revision: https://reviews.llvm.org/D86551
2020-08-31 15:40:40 -07:00
peter klausler 646f19bb9d [flang] Format label scope is independent of block scope
Compilation of the following program currently generates a warning message:

        i = 1
        if (i .eq. 0) then
          write(6, 200) i
200       format (I8)
        end if
        write(6, 200) i
      end

x.f90:6:9: Label '200' is not in scope
          write(6, 200) i
          ^^^^^^^^^^^^^^^

Whereas branch targets must conform to the Clause 11.1.2.1 program
requirement "Transfer of control to the interior of a block from
outside the block is prohibited, ...", this doesn't apply to format
statement references.
2020-08-31 13:34:28 -07:00
sameeran joshi f787c9a90c [Flang][NFC] Remove license comments from files in docs/ folder.
Solves issue https://reviews.llvm.org/D86131#2247275

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D86875
2020-08-31 18:52:59 +05:30
Tim Keith 627e9007ea [flang][NFC] Change how error symbols are recorded
When an error is associated with a symbol, it was marked with a flag
from Symbol::Flag. The problem with that is that you need a mutable
symbol to do that. Instead, store the set of error symbols in the
SemanticsContext. This allows for some const_casts to be eliminated.

Also, improve the internal error that occurs if SetError is called
but no fatal error has been reported.

Differential Revision: https://reviews.llvm.org/D86740
2020-08-28 10:30:25 -07:00
Valentin Clement 832c8a7298 [flang][openacc] Fix gang-argument parsing and add validity tests for !$acc loop
This patch fix the prasing for the gang-arg values for the gang clause. It also adds
some clause validity tests for the loop construct.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D86584
2020-08-27 22:33:05 -04:00
Valentin Clement 4df2a5f782 [flang][openacc] Add check for tile clause restriction
The tile clause in OpenACC 3.0 imposes some restriction. Element in the tile size list are either * or a
constant positive integer expression. If there are n tile sizes in the list, the loop construct must be immediately
followed by n tightly-nested loops.
This patch implement these restrictions and add some tests.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D86655
2020-08-27 22:13:46 -04:00
Pavel Labath 9cb222e749 [cmake] Make gtest include directories a part of the library interface
This applies the same fix that D84748 did for macro definitions.
Appropriate include path is now automatically set for all libraries
which link against gtest targets, which avoids the need to set
include_directories in various parts of the project.

Differential Revision: https://reviews.llvm.org/D86616
2020-08-27 15:35:57 +02:00
peter klausler bce7a7edf3 [flang] Check that various variables referenced in I/O statements may be defined
A number of I/O syntax rules involve variables that will be written to,
and must therefore be definable.  This includes internal file variables,
IOSTAT= and IOMSG= specifiers, most INQUIRE statement specifiers, a few
other specifiers, and input variables.  This patch checks for
these violations, and implements several additional I/O TODO constraint
checks.

Differential Revision: https://reviews.llvm.org/D86557
2020-08-25 12:06:18 -07:00
peter klausler a0a1a4e5c8 [flang] Improve error handling for bad characters in source
When an illegal character appears in Fortran source (after
preprocessing), catch and report it in the prescanning phase
rather than leaving it for the parser to cope with.

Differential Revision: https://reviews.llvm.org/D86553
2020-08-25 11:42:19 -07:00
peter klausler 13cee14bb1 [flang] Parse global compiler directives
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-08-25 11:41:11 -07:00
peter klausler ba4cc3b380 [flang] Don't completely left-justify fixed-form tokenization
If the label field is empty, and macro replacement occurs,
the rescanned text might be misclassified as a comment card
if it happens to begin with a C or a D.  Insert a leading
space into these otherwise empty label fields.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47173
2020-08-25 10:53:56 -07:00
Tim Keith 044a71d828 [flang] Don't attempt to compute element size if no DynamicType
If an error has occurred a symbol may have a DeclTypeSpec but no
valid DynamicType. There is no need to compute the size of erroneous
symbols.

Also, we only need to process object entities and procedure entities.
All other kinds of symbols can be skipped.

This fixes another problem revealed by https://bugs.llvm.org/show_bug.cgi?id=47265

Differential Revision: https://reviews.llvm.org/D86484
2020-08-24 18:20:24 -07:00
Tim Keith b8bfe3586e [flang] Fix bug accessing implicit variable in specification expression
A specification expression can reference an implicitly declared variable
in the host procedure. Because we have to process specification parts
before execution parts, this may be the first time we encounter the
variable. We were assuming the variable was implicitly declared in the
scope where it was encountered, leading to an error because local
variables may not be referenced in specification expressions.

The fix is to tentatively create the implicit variable in the host
procedure because that is the only way the specification expression can
be valid. We mark it with the flag `ImplicitOrError` to indicate that
either it must be implicitly defined in the host (by being mentioned in
the execution part) or else its use turned out to be an error.
We need to apply the implicit type rules of the host, which requires
some changes to implicit typing.

Variables in common blocks are allowed to appear in specification expressions
(because they are not locals) but the common block definition may not appear
until after their use. To handle this we create common block symbols and object
entities for each common block object during the `PreSpecificationConstruct`
pass. This allows us to remove the corresponding code in the main visitor and
`commonBlockInfo_.curr`. The change in order of processing causes some
different error messages to be emitted.

Some cleanup is included with this change:
- In `ExpressionAnalyzer`, if an unresolved name is encountered but
  no error has been reported, emit an internal error.
- Change `ImplicitRulesVisitor` to hide the `ImplicitRules` object
  that implements it. Change the interface to pass in names rather
  than having to get the first character of the name.
- Change `DeclareObjectEntity` to have the `attrs` argument default
  to an empty set; that is the typical case.
- In `Pre(parser::SpecificationPart)` use "structured bindings" to
  give names to the pieces that make up a specification-part.
- Enhance `parser::Unwrap` to unwrap `Statement` and `UnlabeledStatement`
  and make use of that in PreSpecificationConstruct.

Differential Revision: https://reviews.llvm.org/D86322
2020-08-24 12:53:46 -07:00
Valentin Clement d5557c6e05 [flang][openacc] Fix reduction operator parsing/unparsing
Update the way reduction operator are defined for the OpenACC parser.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D86296
2020-08-24 14:22:51 -04:00
Sameeran joshi bc9cdfa12b [FLANG] Pick `.md` files when building sphinx documentation.
Need to build sphinx using below flags to Cmake
`-DLLVM_ENABLE_SPHINX=ON -DSPHINX_WARNINGS_AS_ERRORS=OFF`.
Generate html docs using cmake target
`docs-flang-html`
Generated html files should be at `build/tools/flang/docs/html`.
Patch in series from the dicussion on review
https://reviews.llvm.org/D85828

After this patch the markdown docmentation must be written using guide in-
`llvm/docs/MarkdownQuickstartTemplate.md`

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D86131
2020-08-24 22:11:15 +05:30
Valentin Clement 86bbf8e6fc [flang][openacc] Fix wait-argument for wait clause + add tests
This patch fix the usage of the wait-argument in a clause and add several tests and fix the unparsing of
the wait-argument.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D86325
2020-08-23 20:01:25 -04:00
Mehdi Amini f6615b2ddb Update FIR registration to not rely on the global MLIR dialect registry (NFC)
MLIR is removing "soon" the global dialect registry, this patch is
transitionning FIR to not rely on it anymore.
2020-08-23 21:24:54 +00:00
Michael Kruse 207d4499df [flang][msvc] Split class declaration and constexpr variable definition. NFC.
Msvc has trouble defining a struct/class and defining a constexpr symbol in the same declarator. It reports the following error:
```
basic-parsers.h(809): error C2131: expression did not evaluate to a constant
basic-parsers.h(809): note: failure was caused by call of undefined function or one not declared 'constexpr'
basic-parsers.h(809): note: see usage of 'Fortran::parser::OkParser::OkParser'
```

Fix the msvc compilation by splitting the two definitions into two separate declarators.

This patch is part of the series to [[ http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html | make flang compilable with MS Visual Studio ]].

Reviewed By: DavidTruby, klausler

Differential Revision: https://reviews.llvm.org/D85937
2020-08-22 15:05:48 -05:00
Michael Kruse 2aaa5a546e [flang][msvc] Disambiguate injected class name.
The identifier `Expr` within the scope of the Expr class (including its temple specializations) refers to the current template/instantiation (see https://en.cppreference.com/w/cpp/language/injected-class-name for details). The `MapTemplate` template expect a non-instantiated template as the first template argument, not the concrete instantiation of `Expr`.

At least msvc interprets `Expr` as the injected class name, whereas gcc and clang use the global `flang::evaluate::Expr` template. Disambiguate by explicitly using the namespace.

This patch is part of the series to [[ http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html | make flang compilable with MS Visual Studio ]].

Reviewed By: DavidTruby

Differential Revision: https://reviews.llvm.org/D85646
2020-08-22 12:16:10 -05:00
Tim Keith c0c3cafa2b [flang] Fix assert on bad character kind
When we report an error for a bad character kind, don't keep it in the
`DeclTypeSpec`. Otherwise there could be further problems. In this case,
`ComputeOffsets()` got an assertion error because we didn't recognize
`CHARACTER(*,8)` as needing a descriptor because of the bad kind.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47173

Differential Revision: https://reviews.llvm.org/D86357
2020-08-22 10:11:38 -07:00
Mehdi Amini 2d83014c46 Fix flang test after MLIR API changes 2020-08-19 17:21:38 +00:00
River Riddle 250f43d3ec [mlir] Remove the use of "kinds" from Attributes and Types
This greatly simplifies a large portion of the underlying infrastructure, allows for lookups of singleton classes to be much more efficient and always thread-safe(no locking). As a result of this, the dialect symbol registry has been removed as it is no longer necessary.

For users broken by this change, an alert was sent out(https://llvm.discourse.group/t/removing-kinds-from-attributes-and-types) that helps prevent a majority of the breakage surface area. All that should be necessary, if the advice in that alert was followed, is removing the kind passed to the ::get methods.

Differential Revision: https://reviews.llvm.org/D86121
2020-08-18 16:20:14 -07:00
Tim Keith a3538b8394 [flang] Improve error messages for procedures in expressions
When a procedure name was used on the RHS of an assignment we were not
reporting the error. When one was used in an expression the error
message wasn't very good (e.g. "Operands of + must be numeric; have
INTEGER(4) and untyped").

Detect these cases in ArgumentAnalyzer and emit better messages,
depending on whether the named procedure is a function or subroutine.

Procedure names may appear as actual arguments to function and
subroutine calls so don't report errors in those cases. That is the same
case where assumed type arguments are allowed, so rename `isAssumedType_`
to `isProcedureCall_` and use that to decide if it is an error.

Differential Revision: https://reviews.llvm.org/D86107
2020-08-18 10:47:55 -07:00
sameeran joshi eaff200429 [Flang] Move markdown files(.MD) from documentation/ to docs/
Summary:
Other LLVM sub-projects use docs/ folder for documentation files.
Follow LLVM project policy.
Modify `documentation/` references in sources to `docs/`.
This patch doesn't modify files to reStructuredText(.rst) file format.

Reviewed By: DavidTruby, sscalpone

Differential Revision: https://reviews.llvm.org/D85884
2020-08-18 15:14:15 +05:30
Valentin Clement 3060894bbb [flang][directives] Use TableGen to generate clause unparsing
Use the TableGen directive back-end to generate code for the clauses unparsing.

Reviewed By: sscalpone, kiranchandramohan

Differential Revision: https://reviews.llvm.org/D85851
2020-08-17 14:22:25 -04:00
Tim Keith d66463eedc [flang] Copy attributes and flags onto host-assoc symbols
As with use-associated symbols, copy the attributes and flags from the
original symbol onto host-associated symbols when they are created.

This was showing up as an error on a deallocate of a host-associated
name. We reported an error because the symbol didn't have the POINTER
or ALLOCATABLE attribute.

Differential Revision: https://reviews.llvm.org/D85763
2020-08-17 07:00:07 -07:00
David Truby 3b338e53e9 [flang] Add preprocessor test for defines passed on the command line
This adds a test for D85862 to ensure that preprocessor definitions
passed on command lines don't regress in future.

Reviewed By: tskeith

Differential Revision: https://reviews.llvm.org/D85967
2020-08-17 14:35:46 +01:00
Mehdi Amini 25ee851746 Revert "Separate the Registration from Loading dialects in the Context"
This reverts commit 2056393387.

Build is broken on a few bots
2020-08-15 09:21:47 +00:00
Mehdi Amini 2056393387 Separate the Registration from Loading dialects in the Context
This changes the behavior of constructing MLIRContext to no longer load globally registered dialects on construction. Instead Dialects are only loaded explicitly on demand:
- the Parser is lazily loading Dialects in the context as it encounters them during parsing. This is the only purpose for registering dialects and not load them in the context.
- Passes are expected to declare the dialects they will create entity from (Operations, Attributes, or Types), and the PassManager is loading Dialects into the Context when starting a pipeline.

This changes simplifies the configuration of the registration: a compiler only need to load the dialect for the IR it will emit, and the optimizer is self-contained and load the required Dialects. For example in the Toy tutorial, the compiler only needs to load the Toy dialect in the Context, all the others (linalg, affine, std, LLVM, ...) are automatically loaded depending on the optimization pipeline enabled.

Differential Revision: https://reviews.llvm.org/D85622
2020-08-15 08:07:31 +00:00
Mehdi Amini ba92dadf05 Revert "Separate the Registration from Loading dialects in the Context"
This was landed by accident, will reland with the right comments
addressed from the reviews.
Also revert dependent build fixes.
2020-08-15 07:35:10 +00:00
Mehdi Amini ebf521e784 Separate the Registration from Loading dialects in the Context
This changes the behavior of constructing MLIRContext to no longer load globally registered dialects on construction. Instead Dialects are only loaded explicitly on demand:
- the Parser is lazily loading Dialects in the context as it encounters them during parsing. This is the only purpose for registering dialects and not load them in the context.
- Passes are expected to declare the dialects they will create entity from (Operations, Attributes, or Types), and the PassManager is loading Dialects into the Context when starting a pipeline.

This changes simplifies the configuration of the registration: a compiler only need to load the dialect for the IR it will emit, and the optimizer is self-contained and load the required Dialects. For example in the Toy tutorial, the compiler only needs to load the Toy dialect in the Context, all the others (linalg, affine, std, LLVM, ...) are automatically loaded depending on the optimization pipeline enabled.
2020-08-14 09:40:27 +00:00
Valentin Clement 05169af5ce [flang][openacc] Handle optional end directive in combined construct
OpenACC combined construct can have an optional end directive. This patch handle this
case in the parsing/unparsing with a canonicalization step. Unlike OmpEndLoopDirective,
this doesn't need a special treatment in the pre-fir tree as there is no clause attached to
a AccEndCombinedDirective.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D84481
2020-08-13 14:05:00 -04:00
peter klausler 5c9aca1e93 [flang] Descriptor-based I/O using wrong size for contiguous unformatted I/O
The descriptor-based I/O routine was using the size of the descriptor
rather than the size of the described data for the transfer.  Fix,
and add a comment to the relevant API.

Differential Revision: https://reviews.llvm.org/D85863
2020-08-13 10:46:43 -07:00
peter klausler fad31d6032 [flang] Implement shape analysis of TRANSFER intrinsic function result
The shape (esp. the size) of the result of a call to TRANSFER
is implemented according to the definition in the standard.

Differential Revision: https://reviews.llvm.org/D85866
2020-08-13 09:56:24 -07:00
Peter Steinfeld 19d7cc2e83 [flang] Fix assert on character literal substrings as arguments
Character literal substrings used as arguments were causing asserts.  This
happened when the code was trying to get the DynamicType of the substring.  We
were only recording the DynamicType of the Designator on which the substring
was based.  For character literal substrings, the Designator was a character
literal, and we weren't handling getting its type.

I fixed this by changing the `GetType()` method for `DynamicType` to check to
see if we were getting the type of a `Substring` and calculating the type of
the substring by getting the number of bytes in an element of the string.

I also changed the test `resolve49.f90` with some tests, one of which causes
the original crash.

Differential Revision: https://reviews.llvm.org/D85908
2020-08-13 09:09:05 -07:00
peter klausler e5caa6b5ab [flang] Correct manipulation of mixed complex expressions
Ensure that mixed complex expressions (one operand complex,
the other not) are properly manipulated; add test.
2020-08-13 09:04:00 -07:00
peter klausler 51cfad3a1a [flang] Ensure Preprocessor::Define saves macro names correctly
This fixes problems with macros defined with -D on the command line
and predefined macros defined in the throwaway driver program.
2020-08-13 09:00:48 -07:00
peter klausler f09a2244ba [flang] Correct the default value for PAD= to PAD='YES'. 2020-08-13 08:57:53 -07:00
Michael Kruse 8199cd8a55 [flang] Compilation fix.
unlink() was changed to llvm::sys::fs::remove() in f18.cpp, but the same
change also has to be applied to f18-parse-demo.cpp.
2020-08-13 03:05:05 -05:00
Michael Kruse 18e9482e44 [flang][msvc] Use platform-independent primitives in temporary f18 driver.
Use functions for process launching, temporary file creation and file deletion from LLVM support library instead of POSIX-specific ones.

This patch is part of the series to [[ http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html | make flang compilable with MS Visual Studio ]].

Reviewed By: DavidTruby

Differential Revision: https://reviews.llvm.org/D85660
2020-08-13 02:08:14 -05:00
Michael Kruse 62ef1cb207 [flang][msvc] Remove default arguments for function specializations.
C++ does not allow function template specializations to have default arguments. IIUC callers will only use the default arguments of the primary template. gcc and clang accept the syntax anyway, but msvc emits an error.

See https://en.cppreference.com/w/cpp/language/template_specialization for more details.

This patch is part of the series to [[ http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html | make flang compilable with MS Visual Studio ]].

Reviewed By: DavidTruby

Differential Revision: https://reviews.llvm.org/D85657
2020-08-12 16:46:02 -05:00
Michael Kruse e3d38b7b88 [flang][msvc] Tell windows.h to not define min/max macros.
Defining macros for min and max breaks using std::min and std::max. Defining NOMINMAX before including the header stops them from being defined.

See https://web.archive.org/web/20170911092732/https://support.microsoft.com/en-us/help/143208/prb-using-stl-in-windows-program-can-cause-min-max-conflicts for details.

This patch is part of the series to [[ http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html | make flang compilable with MS Visual Studio ]].

Reviewed By: isuruf

Differential Revision: https://reviews.llvm.org/D85656
2020-08-12 14:36:21 -05:00
Tim Keith f5e4451e1f [flang] Fix interpretation of intrinsic names as arguments
If an unrestricted specific intrinsic function name is first encountered
as an actual argument, it should be interpreted as an object entity,
not a procedure entity.

Fix some tests that depended on the previous interpretation by adding
explicit INTRINSIC statements.

Differential Revision: https://reviews.llvm.org/D85792
2020-08-11 16:52:50 -07:00
sameeran joshi 2fc86ccdd2 [Flang] Fix release blocker issue #46931 related to documentation.
Summary:
Fixes bug : https://bugs.llvm.org/show_bug.cgi?id=46931
This commit add a new flag -DLLVM_ENABLE_SPHINX=ON to cmake command to generate sphinx documentation,
along with new cmake targets `docs-flang-html`.
`ninja docs-flang-html` - generates sphinx documentation.
Generated release notes are present in <builddir>/tools/flang/docs/html/ folder.

Reviewers: richard.barton.arm, DavidTruby

Tags: #flang

Differential Revision: https://reviews.llvm.org/D85470
2020-08-11 23:22:30 +05:30
Tim Keith cf715717aa [flang] Allow compiler directives in more places
Allow compiler directives in the implicit-part and before USE statements
in the specification-part.

Differential Revision: https://reviews.llvm.org/D85693
2020-08-11 08:37:27 -07:00
Valentin Clement 16c1d251c4 [flang][directives] Use TableGen information for clause classes in parse-tree
This patch takes advantage of the directive information and tablegen generation
to replace the clauses class parse tree and in the dump parse tree sections.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D85549
2020-08-11 10:44:14 -04:00
Tim Keith a9795b6f63 [flang] Disable -Wmaybe-uninitialized for GCC
According to llvm/cmake/config-ix.cmake, gcc's potentially uninitialized
use analysis has lots of false positives. We are encountering one in
flang/lib/Lower/CharacterExpr.cpp.

That warning is disabled for gcc in in-tree builds; this does the same
thing for out-of-tree builds.

Differential Revision: https://reviews.llvm.org/D85694
2020-08-11 07:20:15 -07:00
clementval 3b3dc1dbff Revert "[flang][directives] Use TableGen information for clause classes in parse-tree"
This reverts commit bf93edc475.

Buildbot failure
2020-08-11 09:54:04 -04:00
Valentin Clement bf93edc475 [flang][directives] Use TableGen information for clause classes in parse-tree
This patch takes advantage of the directive information and tablegen generation
to replace the clauses class parse tree and in the dump parse tree sections.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D85549
2020-08-11 09:43:11 -04:00
Richard Barton 0057532e3f Revert "[flang] Version information in flang/f18"
Patch breaks out of tree builds and fails its regression test on buildbots.

This reverts commit 6e67a74ed73e60a9609f2666e9ac9f44c63c3e0f.
2020-08-11 08:41:57 +01:00
Tim Keith 7f5928ef5a [flang] Avoid cascading error in subscript triplet
If a bound of a subscript triplet is present but fails to analyze
due to an error, return nullopt rather than returning a Triplet with
that bound missing. This is so we can distinguish an absent bound from
an erroneous one and avoid spurious errors.

Differential Revision: https://reviews.llvm.org/D85672
2020-08-10 11:44:08 -07:00
peter klausler 189c0833df [flang] Fix edge case with Hollerith
To prevent mistokenization of CHARACTER*2HXY as a Hollerith
literal constant while allowing it in DATA A/2*2HXY/, there's
a little state that tracks whether a / has been seen earlier
in the same statement.  But it was being reset on each line,
not statement, so Hollerith in a DATA statement continuation
line was incorrectly tokenized.  Fixed.

Differential Revision: https://reviews.llvm.org/D85571
2020-08-10 11:31:41 -07:00
Camille Coti 89a9db438f [flang] Version information in flang/f18
Fixed some version information in flang/f18:

  - fixed the behavior of the -v switch: this flag enables verbosity with used with arguments, but just displays the version when used alone (related to this bug: https://bugs.llvm.org/show_bug.cgi?id=46017)
 - added __FLANG, __FLANG_MAJOR__, __FLANG_MINOR__ and __FLANG_PATCHLEVEL__ (similar to their __F18* counterparts) for compatibility purpose

Reviewed By: sscalpone, AlexisPerry, richard.barton.arm, tskeith

Differential Revision: https://reviews.llvm.org/D84334
2020-08-10 16:18:24 +01:00
peter klausler 4ac617f490 [flang] Handle DATA initialization of EQUIVALENCE'd objects
Objects that are storage associated by EQUIVALENCE and
initialized with DATA are initialized by creating a
compiler temporary data object in the same scope,
assigning it an offset, type, and size that covers the
transitive closure of the associated initialized original
symbols, and combining their initializers into one common
initializer for the temporary.

Some problems with offset assignment of EQUIVALENCE'd objects
in COMMON were exposed and corrected, and some more error
cases are checked.

Remove obsolete function.
Small bugfix (nested implied dos).
Add a test.
Fix struct/class warning.

Differential Revision: https://reviews.llvm.org/D85560
2020-08-07 16:39:23 -07:00
River Riddle 82fd139201 [flang] Update FirOpsDialect constructor to pass its TypeID 2020-08-07 13:43:25 -07:00
River Riddle 1d6a8deb41 [mlir] Remove the need to define `kindof` on attribute and type classes.
This revision refactors the default definition of the attribute and type `classof` methods to use the TypeID of the concrete class instead of invoking the `kindof` method. The TypeID is already used as part of uniquing, and this allows for removing the need for users to define any of the type casting utilities themselves.

Differential Revision: https://reviews.llvm.org/D85356
2020-08-07 13:43:25 -07:00
peter klausler 43b304b09f [flang] Support DATA statement initialization of numeric with Hollerith/CHARACTER
This is a common Fortran language extension.

Differential Revision: https://reviews.llvm.org/D85492
2020-08-07 13:17:36 -07:00
peter klausler cc01194c2f [flang] Descriptor-based I/O data item transfers
Add support for OutputDescriptor() and InputDescriptor()
in the I/O runtime.  Change existing scalar formatted I/O
functions to drive descriptor-based I/O routines internally.

Differential Revision: https://reviews.llvm.org/D85491
2020-08-07 13:09:09 -07:00
peter klausler 0e9e06a6d4 [flang][NFC] Reformat files with current clang-format
Differential Revision: https://reviews.llvm.org/D85489
2020-08-07 12:10:26 -07:00
Tim Keith cf03bcf929 [flang] Remove extra CMAKE_CXX_FLAGS in Lower and Optimizer
`-Wno-error` and `-Wno-unused-parameter` appear to no longer be needed
for Lower and Optimizer.

Differential Revision: https://reviews.llvm.org/D85465
2020-08-07 10:21:54 -07:00
Tim Keith d8713523a2 [flang] Improve message for assignment to subprogram
In the example below we were producing the error message
"Assignment to constant 'f' is not allowed":
```
function f() result(r)
  f = 1.0
end
```

This changes it to a more helpful message when the LHS is a subprogram
name and also mentions the function result name when it's a function.

Differential Revision: https://reviews.llvm.org/D85483
2020-08-06 20:34:00 -07:00
Michael Kruse f81bae9ff4 [flang][msvc] Do not use gcc/clang command line options for msvc.
The command line options `-Wno-error` and `-Wno-unused-parameter` are specific to gcc/clang, do not use them when compiling with other compilers.

This patch is part of the series to [[ http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html | make flang compilable with MS Visual Studio ]].

Reviewed By: isuruf

Differential Revision: https://reviews.llvm.org/D85355
2020-08-06 15:46:52 -05:00
Tim Keith 08c7d570d3 [flang] Add options to control IMPLICIT NONE
Add `-fimplicit-none-type-always` to treat each specification-part
like it has `IMPLICIT NONE`. This is helpful for enforcing good Fortran
programming practices. We might consider something similar for
`IMPLICIT NONE(EXTERNAL)` as well.

Add `-fimplicit-none-type-never` to ignore occurrences of `IMPLICIT NONE`
and `IMPLICIT NONE(TYPE)`. This is to handle cases like the one below,
which violates the standard but it accepted by some compilers:
```
subroutine s(a, n)
  implicit none
  real :: a(n)
  integer :: n
end
```

Differential Revision: https://reviews.llvm.org/D85363
2020-08-06 06:48:01 -07:00
Irina Dobrescu e355f85bdf [flang] Add parser support for OpenMP allocate clause
Differential Revision: https://reviews.llvm.org/D85212
2020-08-06 10:45:34 +01:00
Tim Keith 6d2d73059f [flang] Fix compilation warning in check-directive-structure.h
Clang 9 gets the following warning after revision `D85104`.
```
../../flang/lib/Semantics/check-directive-structure.h:36:7: error: 'Fortran::semantics::DirectiveStructureChecker<llvm::omp::Directive, llvm::omp::Clause, Fortran::parser::OmpClause, 77>' has virtual functions but non-virtual destructor [-Werror,-Wnon-virtual-dtor]
```

The fix is the make the destructor virtual. Neither it nor the
constructor need to be public, so make them protected.

Differential Revision: https://reviews.llvm.org/D85383
2020-08-05 18:03:41 -07:00
Valentin Clement 40626184cf [flang][NFC] Unify OpenMP and OpenACC structure checker
This patch remove duplicated code between the check-omp-structure and the check-acc-structure
and unify it into a check-directive-structure templated class.

Reviewed By: kiranchandramohan, sscalpone, ichoyjx

Differential Revision: https://reviews.llvm.org/D85104
2020-08-05 14:25:49 -04:00
Andrzej Warzynski 621681e3e5 [Flang] Fix multi-config generator builds
Based on https://reviews.llvm.org/D84022 with additional changes to
maintain out-of-tree builds.

Original commit message:
Currently the binaries are output directly into the bin subdirectory of
the build directory. This doesn't work correctly with multi-config
generators which should output the binaries into <CONFIG_NAME>/bin
instead.

The original patch was implemented by David Truby and the additional
changes added here were also proposed by David Truby.

Differential Revision: https://reviews.llvm.org/D85078/

Co-authored-by: David Truby <david.truby@arm.com>
2020-08-05 08:59:11 +01:00
Rahul Joshi 1d6a724aa1 [MLIR] Change FunctionType::get() and TupleType::get() to use TypeRange
- Moved TypeRange into its own header/cpp file, and add hashing support.
- Change FunctionType::get() and TupleType::get() to use TypeRange

Differential Revision: https://reviews.llvm.org/D85075
2020-08-04 12:43:40 -07:00
peter klausler 675ad1bc6a [flang] Implement runtime support for INQUIRE statements
Differential Revision: https://reviews.llvm.org/D85166
2020-08-03 17:15:08 -07:00
peter klausler d879ac8a6e [flang] Defer "next input record" processing until handlers established
External input was detecting "end of file" conditions in
BeginExternal...Input() and BeginUnformattedInput() routines
before EnableHandlers() could have been called.  Defer the
"start next record" processing to the input data item
handlers (and EndIoStatement() for when there are no data
items).

Differential Revision: https://reviews.llvm.org/D85161
2020-08-03 16:44:37 -07:00
peter klausler d8334c4360 [flang] Acquire file accessibility, size, positioning
Extend the raw file wrapper to get accessibility, positioning,
and size information.  This is needed for INQUIRE (to follow).

Differential Revision: https://reviews.llvm.org/D85160
2020-08-03 16:42:48 -07:00
peter klausler 49bbb8b60e Remove unneeded RoundDefault enumerator, and fix spelling in comments 2020-08-03 16:14:24 -07:00
peter klausler 7c5630fe99 [flang] Handle spaces (more) correctly in REAL input
Fixes problems in FCVS test fm110.f.
Add more comments, too.

Differential Revision: https://reviews.llvm.org/D85163
2020-08-03 16:12:30 -07:00
peter klausler 089adc339e [flang] Make preprocessing behavior tests runnable as regression tests
And fix a minor bug exposed by doing so.

Differential Revision: https://reviews.llvm.org/D85164
2020-08-03 15:07:38 -07:00
Tim Keith 0d454e8e08 [flang] Fix bug detecting intrinsic function
Don't set the INTRINSIC attribute on a dummy procedure.

Differential Revision: https://reviews.llvm.org/D85136
2020-08-03 12:21:59 -07:00
compinder 594dec2884 [FLANG] Fix issues in SELECT TYPE construct when intrinsic type specification is specified in TYPE GUARD statement.
Fix of PR46789 and PR46830.

Differential Revision: https://reviews.llvm.org/D84290
2020-08-03 09:24:42 +05:30
River Riddle 2a6c8b2e95 [mlir][PassIncGen] Refactor how pass registration is generated
The current output is a bit clunky and requires including files+macros everywhere, or manually wrapping the file inclusion in a registration function. This revision refactors the pass backend to automatically generate `registerFooPass`/`registerFooPasses` functions that wrap the pass registration. `gen-pass-decls` now takes a `-name` input that specifies a tag name for the group of passes that are being generated. For each pass, the generator now produces a `registerFooPass` where `Foo` is the name of the definition specified in tablegen. It also generates a `registerGroupPasses`, where `Group` is the tag provided via the `-name` input parameter, that registers all of the passes present.

Differential Revision: https://reviews.llvm.org/D84983
2020-07-31 13:20:37 -07:00
Sourabh Singh Tomar bf812c145c [flang][OpenMP] Added initial support for lowering OpenMP parallel construct
This patch lower `!OMP PARALLEL` construct from PFT to OpenMPDialect operations.
This is first patch in this direction(lowering parallel construct).

OpenMP parallel construct can have multiple clauses and parameters. This patch
only implements lowering of an empty(contains no code in body) parallel construct
without any clauses or parameters.

Patch is carved out of following approved PR:
https://github.com/flang-compiler/f18-llvm-project/pull/322

Reviewed By: kiranchandramohan, DavidTruby

Differential Revision: https://reviews.llvm.org/D84965
2020-07-31 23:59:46 +05:30
sameeran joshi b752a8ca49 [flang][NFC] Verify C781 from - Clause 7 constraint checks for f18.
Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84503
2020-07-31 23:58:18 +05:30
sameeran joshi 8830f1170d [flang]Verify C7107, C7108, C7109 from - Clause 7 constraint checks for f18.
1.  Annotate the sources with constraint numbers.
   2.  Add tests for

    *C7107 (R765) digit shall have one of the values 0 or 1.
    *C7108 (R766) digit shall have one of the values 0 through 7.
    *C7109 (R764) A boz-literal-constant shall appear only as a data-stmt-constant in a DATA statement, or where explicitly allowed in 16.9 as an actual argument of an intrinsic procedure.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84504
2020-07-31 23:45:20 +05:30
Tim Keith 765b81f6b9 Revert "[flang] Fix multi-config generator builds."
This reverts commit 332170356e.

The change breaks out-of-tree builds.
Discussion in https://reviews.llvm.org/D84022
2020-07-31 11:10:44 -07:00
sameeran joshi 49660234db [Flang] Checks for constraint C7110-C7115.
Added more tests.
	 Annotate sources and tests.
	 Improve error message.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D85014
2020-07-31 23:27:57 +05:30
Richard Barton 30e45f339e [flang] Add -h as a synonym for help
As expected by user in http://lists.llvm.org/pipermail/flang-dev/2020-June/000404.html

Depends on D84856

Differential Revision: https://reviews.llvm.org/D84857
2020-07-31 15:56:37 +01:00
Richard Barton b068d19a15 [flang] Add details to --help screen on default behaviour
Add a usage string and a defaults section that clarifies:
 * If no input files are given, f18 reads from stdin
 * If no input files are given, f18 dumps the parse tree.
 * The default behaviour is to exec F18_FC.
 * The fefault F18_FC setting is 'gfortran'

Adds a simple regression test which tests the top and tail of the help
screen and the exit status.

Depends on D84855

Differential Revision: https://reviews.llvm.org/D84856
2020-07-31 15:56:37 +01:00
Richard Barton dd5ea5674b [flang] Make interactive behaviour more obvious
When flang is invoked with no files it waits for input on stdin. Make it
print a message saying this to prevent the user being surprised.

Differential Revision: https://reviews.llvm.org/D84855
2020-07-31 15:56:37 +01:00
Jean Perier a50cec71ec [flang] Fix CMPLX folding with complex arguments
CMPLX folding was expecting only one arguments in case X argument
is complex. This is wrong since there is also the optional KIND
argument.

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D84936
2020-07-31 10:26:08 +02:00
Peter Steinfeld 2cf52504bb [flang] Fixes for RESHAPE()
I fixed an assert caused by passing an empty array as the source= argument to
RESHAPE().  In the process, I noticed that there were no tests for RESHAPE(),
so I wrote a test that covers all the description in 16.9.163.  In the process,
I made the error messages more consistent and descriptive.  I also changed the
test to see if a reference to an intrinsic function was a constant to say that
it is a constant if it's a refererence to an invalid intrinsic.  This avoids
emitting multiple messages for the same erroneous source.

Differential Revision: https://reviews.llvm.org/D84904
2020-07-30 19:05:06 -07:00
Peter Steinfeld fac84536bc [flang] Fix an assert on duplicate initializations
When declaring the same variable twice with an initialization, we were failing
an internal check.  I fixed this by checking to see if the associated symbol
already had an error.

I added tests for pointer and non-pointer initialization of duplicate names.

Differential Revision: https://reviews.llvm.org/D84969
2020-07-30 12:58:28 -07:00
Tim Keith 38272f45fe [flang] Create HostAssoc symbols for uplevel references
To make it easier for lowering to identify which symbols from the host
are captured by internal subprograms, create HostAssocDetails for them.

In particular, if a symbol is referenced and it is contained in a
subprogram or main program that is not the same as the containing
program unit of the reference, a HostAssocDetails symbol is created
in the current scope.

Differential Revision: https://reviews.llvm.org/D84889
2020-07-30 07:12:26 -07:00
Jean Perier 67e41df4e0 [flang] Expose specific to generic intrinsic name mapping
The intrinsic lowering facility is based on the generic intrinsic names to avoid
duplicating implementations. Specific intrinsics call are re-written to call to
the generic versions by the front-end but this cannot be done when specific intrinsics
are passed as arguments (the rewrite would give illegal/ambiguous unparsed Fortran).
Solve the issue by making the specific to generic name mapping accessible to lowering
and can be later used to generate the unrestricted intrinsic functions.

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D84842
2020-07-30 14:30:12 +02:00
David Truby 332170356e [flang] Fix multi-config generator builds.
Summary:
Currently the binaries are output directly into the bin subdirectory of the
build directory. This doesn't work correctly with multi-config generators which
should output the binaries into <CONFIG_NAME>/bin instead.

Reviewers: sscalpone, richard.barton.arm

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D84022
2020-07-30 09:56:52 +01:00
Tim Keith 2c662f3d3d [flang] Fix bug with intrinsic in type declaration stmt
When an instrinsic function is declared in a type declaration statement
we need to set the INTRINSIC attribute and (per 8.2(3)) ignore the
specified type.

To simplify the check, add IsIntrinsic utility to BaseVisitor.

Also, intrinsics and external procedures were getting assigned a size
and offset and they shouldn't be.

Differential Revision: https://reviews.llvm.org/D84702
2020-07-29 07:23:31 -07:00
Tim Keith 9500d48de3 [flang][NFC] Extract name resolution for OpenACC & OpenMP into new file
Move `ResolveAccParts` and `ResolveOmpParts` from resolve-names.cpp to
resolve-directives.{h,cpp}. Move the implementation in the classes
`DirectiveAttributeVisitor`, `AccAttributeVisitor`, and
`OmpAttributeVisitor` to resolve-directives.cpp as well.

To allow this to happen, move `EvaluateIntExpr` and introduce
`EvaluateInt64` to resolve-names-utils.h. The latter is also useful
elsewhere in resolve-names.cpp for converting an Expr to std::int64_t.

The other problem was that `ResolveDesignator` was called from the code
that was moved. At the moment it doesn't seem to be doing anything so I
removed the calls (and no tests failed). If it proves to be needed, we
can either resolve those designators in resolve-names.cpp or pass the
`ResolveDesignator` function in to the code that needs to call it.

Differential Revision: https://reviews.llvm.org/D84768
2020-07-28 16:38:36 -07:00
Camille Coti ca0bf440db Order of libraries and source files in the f18 frontend
When the f18 frontend calls the link editor, put the libraries and object files in the correct order.

Fixes the issues reported here https://github.com/flang-compiler/flang/issues/897

Reviewed By: sscalpone, AlexisPerry

Differential Revision: https://reviews.llvm.org/D84340
2020-07-28 09:03:04 -06:00
peter klausler e57464151d [flang] Allow omission of comma in FORMAT(1PE5.2) in runtime
A comma is not required between a scale factor and a following
data edit descriptor (C1302).

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84369
2020-07-27 15:02:54 -07:00
AlexisPerry 4a4cafabc9 [flang] Temp Driver - pass the flag to change the default integer kind through to F18_FC
fixes BUG 46307

Differential Revision: https://reviews.llvm.org/D84266
2020-07-27 09:57:34 -07:00
Valentin Clement ff25b2da2a [flang][openacc] Basic name resolution infrastructure for OpenACC construct
Reviewed By: tskeith, klausler, ichoyjx

Differential Revision: https://reviews.llvm.org/D83998
2020-07-26 20:01:35 -04:00
Tim Keith 7454acdf3b [flang] Fix implicit declarations in statement functions
If a symbol (that is not a dummy argument) is implicitly declared inside
a statement function, don't create it in the statement function's scope.
Instead, treat statement functions like blocks when finding the inclusive
scope and create the symbol there.

Add a new flag, StmtFunction, to symbols that represent statement functions.

Differential Revision: https://reviews.llvm.org/D84588
2020-07-26 12:13:39 -07:00
David Truby 4ef2e594d5 [flang] Run non-gtest unit tests with lit.
Summary:
As a corrollary, these tests are now run as part of the check-flang
target.

Reviewers: sscalpone

Subscribers: mgorny, delcypher, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D83946
2020-07-24 14:49:39 +01:00
Tim Keith 412056e2d0 [flang] Implicitly convert result of statement function
The result of a statement function may require an implicit conversion
to match its result type. Add that to the expression that represents
the statement function body in SubprogramDetails.

Extract the analysis of that expression into a separate function.

Dump the statement function expression as part of the dump of
SubprogramDetails.

Differential Revision: https://reviews.llvm.org/D84452
2020-07-23 17:15:35 -07:00
clementval aca58ef784 [flang][openacc] Add missing comment in header 2020-07-23 14:10:35 -04:00
Pete Steinfeld 83dca19c11 [flang] Fix a crash when a BOZ literal is used as a relational operator
Summary:
Expressions like `iVar==z'fe'` were causing an assertion error  because
the `Relate()` function in `Evaluate/tools.cpp` that processes
relational operators didn't deal with BOZ literals, which are typeless.
I fixed this by checking to see if the operands are BOZ literals.  If
so, if the other operand is REAL, I convert them to REAL.  Otherwise, I convert
them to integers with default kind.

I also added a test to resolve63.f90 that triggers the problem.

Reviewers: tskeith, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D83917
2020-07-23 09:14:10 -07:00
Sourabh Singh Tomar 9e4ab439c2 [flang][OpenMP] Added support for lowering OpenMP taskyield construct
Summary:
This patch lower `!OMP TASKYIELD` construct from PFT to
OpenMPDialect operations.
Construct is lowered with conformance to OpenMP 5.0 spec.

Patch is carved out of following merged PR:
https://github.com/flang-compiler/f18-llvm-project/pull/297

Reviewed: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D84350
2020-07-23 07:16:34 +05:30
Valentin Clement b27ab9ce74 [flang][openacc] Skeleton for OpenACC construct lowering
Summary:
This patch introduce the basic infrastructure to be able to lower
OpenACC constructs to the future OpenACC dialect.

Reviewers: schweitz, kiranchandramohan, DavidTruby, sscalpone, jdoerfert, ichoyjx

Reviewed By: ichoyjx

Subscribers: ichoyjx, SouraVX, mgorny, jfb, sstefan1, llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D84195
2020-07-22 21:34:22 -04:00
Valentin Clement 3b8ffdec07 [flang][openmp] Required clauses are allowed
Summary:
This patch fix a problem where clause needed to be in the allowed set even
they were in the required set. A required clause is allowed obvisouly. This allow
to remove the duplicate in OMP.td

Reviewers: kiranchandramohan, DavidTruby, richard.barton.arm, jdoerfert, sscalpone, kiranktp, ichoyjx

Reviewed By: kiranchandramohan

Subscribers: yaxunl, guansong, sstefan1, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D84353
2020-07-22 21:31:35 -04:00
peter klausler 3bc2ae951a [flang] Add runtime I/O APIs for COMPLEX formatted input
It turns out that COMPLEX formatted input needs its own runtime APIs
so that null values in list-directed input skip the entire COMPLEX
datum rather than just a real or imaginary part thereof.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84370
2020-07-22 17:52:19 -07:00
Logan Smith 77e0e9e17d Reapply "Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories."
add_compile_options is more sensitive to its location in the file than add_definitions--it only takes effect for sources that are added after it. This updated patch ensures that the add_compile_options is done before adding any source files that depend on it.

Using add_definitions caused the flag to be passed to rc.exe on Windows and thus broke Windows builds.
2020-07-22 17:50:19 -07:00
Logan Smith 97a0f80c46 Revert "Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories."
This reverts commit 388c9fb1af.
2020-07-22 15:07:01 -07:00
Logan Smith 388c9fb1af Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories.
Using add_compile_definitions caused the flag to be passed to rc.exe on Windows and thus broke Windows builds.
2020-07-22 14:19:34 -07:00
Pete Steinfeld f72106e2a3 [flang] Fix an assert when RESHAPE() is called on empty strings
Summary:
When a constant array of empty strings goes through contant folding, the result
is something that contains no bytes.  If this array is passed to the intrinsic
function `RESHAPE()`, we were not handling things correctly.  I fixed this by
checking for an empty destination when calling the function `CopyFrom()` on an
array of strings.

I also added a test with a couple of different examples that trigger the
problem.

Reviewers: klausler, tskeith, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D84352
2020-07-22 12:21:58 -07:00
Louis Dionne afa1afd410 [CMake] Bump CMake minimum version to 3.13.4
This upgrade should be friction-less because we've already been ensuring
that CMake >= 3.13.4 is used.

This is part of the effort discussed on llvm-dev here:

  http://lists.llvm.org/pipermail/llvm-dev/2020-April/140578.html

Differential Revision: https://reviews.llvm.org/D78648
2020-07-22 14:25:07 -04:00
Hans Wennborg 3eec657825 Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.
After lots of follow-up fixes, there are still problems, such as
-Wno-suggest-override getting passed to the Windows Resource Compiler
because it was added with add_definitions in the CMake file.

Rather than piling on another fix, let's revert so this can be re-landed
when there's a proper fix.

This reverts commit 21c0b4c1e8.
This reverts commit 81d68ad27b.
This reverts commit a361aa5249.
This reverts commit fa42b7cf29.
This reverts commit 955f87f947.
This reverts commit 8b16e45f66.
This reverts commit 308a127a38.
This reverts commit 274b6b0c7a.
This reverts commit 1c7037a2a5.
2020-07-22 20:23:58 +02:00
peter klausler c6cb726a8c [flang] Replay a FORMAT at the right position
When FORMAT control reaches the final parenthesis and data items
remain, we advance a record and revert to the beginning of the
FORMAT for further items.  But when the FORMAT contains any
nested parenthesized group of editing descriptors, possibly
repeated, reversion must be to the beginning of the last such
top-level parenthesized group, including its repetition count.

Reviewed By: sscalpone, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84281
2020-07-21 18:59:49 -07:00
peter klausler 320389e849 [flang] Fix source line continuation in potential macro calls (bugzilla 46768)
The prescanner looks for implicit continuation lines when
there are unclosed parentheses at the end of a line, so that
source preprocessing macro references with arguments that span
lines are recognized.  The condition that determines this
implicit continuation has been put into a predicate member
function and corrected to apply only when the following line
is source (not a preprocessing directive, comment, &c.).

Fixes bugzilla #46768.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84280
2020-07-21 18:21:35 -07:00
peter klausler 8f2c5c4314 [flang] Implement byte-swapped external unformatted I/O in runtime
Add SetConvert() to the OPEN statement's runtime API.
Add ByteswapOption() to the main program's runtime API.
Check a $FORT_CONVERT environment variable, too, for
a swapping specifier.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84284
2020-07-21 18:14:46 -07:00
peter klausler 9bb091a8fc [flang] Handle leading zeroes after decimal in REAL formatted input
Leading zero digits after the decimal mark were being dropped.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84282
2020-07-21 18:03:24 -07:00
peter klausler 26330a0c7c [flang] Check for misplaced labels
In fixed form source, complain when a label digit appears
outside the label field & when a non-digit appears in the label
field.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84283
2020-07-21 18:00:16 -07:00
Logan Smith 21c0b4c1e8 Disable -Wsuggest-override for all remaining unittests/ directories 2020-07-21 17:48:36 -07:00
peter klausler cbff0c75b9 [flang] Improve output from a STOP statement
Add a missing newline to IEEE FP flag formatting, and
don't neglect to emit STOP when there's no code number.

Reviewed By: tskeith

Differential Revision: https://reviews.llvm.org/D84060
2020-07-18 11:33:46 -07:00
peter klausler e79a86e45b [flang] Insert leading blanks in LOGICAL formatted output fields
Summary: For Lw output editing, emit (w-1) blanks before the T or the F.

Reviewed By: sscalpone, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84059
2020-07-18 10:44:16 -07:00
peter klausler b0a971d25c [flang] Prevent bogus runtime I/O error message
The runtime was requiring that STATUS='OLD' be explicitly specified
on an OPEN statement for a connected unit.  There error should issue
only if a STATUS= other than 'OLD' is specified; an OPEN with no
STATUS= specifier is okay.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84079
2020-07-17 17:21:54 -07:00
peter klausler 8305a92a47 [flang] Treat tabs like spaces in formatted input.
Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84078
2020-07-17 17:19:20 -07:00
peter klausler 8e2b4e50f2 [flang] Support <name>=<integer> syntax in compiler directives
Accept name=value as part of a !DIR$ compiler directive.  These
are currently ignored in semantics, but we should recognize
more directive forms to facilitate testing.  In due course,
these placeholding directive parsers will be replaced.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84077
2020-07-17 17:05:38 -07:00
peter klausler cf2274b779 [flang] Allow ! and // comments after some preprocessing directives
Old-style C /*comments*/ are omitted from preprocessor directive
token sequences by the prescanner, but line-ending C++ and Fortran
free-form comments are not since their handling might depend on
the directive.  Add code to skip these line-ending comments as
appropriate in place of existing code that just skipped blanks.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84061
2020-07-17 15:28:22 -07:00
peter klausler ea4758a125 [flang] Rework read/write permission management for runtime file opening
Anonymous Fortran unit files (e.g., "./fort.7") need to be created
O_RDWR so that they can be written, rewound, and read.  Other
files opened with no ACTION= specifier need to set read/write
permissions based on the file, if it exists.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84063
2020-07-17 14:44:58 -07:00
peter klausler b30fa1c3da [flang] Add entry points for internal scalar list-directed I/O
BeginInternalListInput and BeginInternalListOutput were missing
from the I/O API implementation; add them.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84066
2020-07-17 12:49:06 -07:00
Sourabh Singh Tomar 079b49b3fb [flang][OpenMP] Added support for lowering OpenMP taskwait construct
Summary:
This patch lower `!OMP TASKWAIT` construct from PFT to
OpenMPDialect operations.
Construct is lowered with conformance to OpenMP 4.5 spec.

Patch is carved out of following approved PR:
https://github.com/flang-compiler/f18-llvm-project/pull/280

Reviewed By: kiranchandramohan, clementval

Differential Revision: https://reviews.llvm.org/D83983
2020-07-17 20:01:54 +05:30
Rahul Joshi 2e046be90e [flang] Adopt NoRegionArguments (WhereOp) and ParentOneOf (ResultOp) traits
Differential Revision: https://reviews.llvm.org/D83522
2020-07-16 08:35:22 -07:00
David Truby 920e127e02 [flang] Add missing link dependencies to FrontendOpenACC.
Summary:
These link dependencies are required for shared library builds to
work correctly.

Reviewers: clementval

Reviewed By: clementval

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D83938
2020-07-16 14:22:18 +01:00
David Truby 1c93671e59 [flang] Fix shared library builds for lib/Lower.
Summary:
This adds missing definitions for functions in the Lower directory
that were causing failures in shared library builds.
The definitions for these are taken from the fir-dev branch on github.

Reviewers: sscalpone, schweitz, jeanPerier, klausler

Reviewed By: schweitz

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D83771
2020-07-16 10:18:14 +01:00
Kiran Kumar T P d4b1a14f0a [flang][OpenMP] Enhance parser support for taskwait construct to OpenMP 5.0
Summary:
This patch enhances parser support for taskwait construct to OpenMP 5.0.

2.17.5 taskwait Construct
        !$omp taskwait [clause[ [,] clause] ... ]
                where clause is one of the following:
                depend([depend-modifier,]dependence-type : locator-list)

The patch includes code changes and testcase modifications.

Reviewed By: Valentin Clement, Kiran Chandramohan

Differential Revision: https://reviews.llvm.org/D82255
2020-07-16 10:10:59 +05:30
Tim Keith fa5e4482e0 [flang] Don't use-associate intrinsics
When an intrinsic is referenced in a module scope, a symbol for it is
added. When that module is USEd, the intrinsic should not be included.
Otherwise we can get ambiguous reference errors with the same intrinsic
coming from two difference modules.

Differential Revision: https://reviews.llvm.org/D83905
2020-07-15 15:08:08 -07:00
Tim Keith b297563a75 [flang] Fix erroneous application of SAVE statement
A SAVE statement with no entity list applies the SAVE attribute only to
the entities that it is allowed on. We were applying it to automatic
data objects and reporting an error that they can't have SAVE.

The fix is to change `DeclarationVisitor::CheckSaveAttr` to check for
automatic objects. That controls both checking and setting the
attribute. This allows us to remove the check from `CheckSpecExpr`
(along with `symbolBeingChecked_`). Also, it was only called on constant
objects so the non-const overload can be eliminated.

The check in `CheckSpecExpr` is replaced by an explicit check for
automatic objects in modules. This caught an error in modfile03.f90 so
that part of the test was eliminated.

Differential Revision: https://reviews.llvm.org/D83899
2020-07-15 13:02:33 -07:00