Commit graph

2403 commits

Author SHA1 Message Date
peter klausler 3d627d6ff9 [flang] More Fortran runtime support for CHARACTER operations
Summary:
- Remove C++ library dependence from lock.h
- Implement LEN_TRIM, REPEAT, ADJUSTL, ADJUSTR, MAX/MIN
  intrinsic functions for CHARACTER

Reviewers: tskeith, PeteSteinfeld, sscalpone, schweitz, DavidTruby

Reviewed By: PeteSteinfeld

Subscribers: llvm-commits, flang-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D82054
2020-06-17 15:51:48 -07:00
Eric Schweitz b46e2548b6 [flang] Fix fallout from varous changes to the cmake files.
Differential revision: https://reviews.llvm.org/D82050
2020-06-17 14:40:05 -07:00
Tim Keith f392b75fd8 [flang] Fix out-of-tree builds
Replace two MLIR dependencies with MLIRLinalgOps.

Differential Revision: https://reviews.llvm.org/D82038
2020-06-17 12:02:00 -07:00
Eric Schweitz 30db177693 [flang] Upstream the Mangler module from lowering.
This upstreams the internal name mangling used in the bridge to generate
unique names from symbols.

Replace InternalNamesTest with the actual, functional unittest.

Differential revision: https://reviews.llvm.org/D81764
2020-06-16 15:24:13 -07:00
sameeran joshi 93f602b339 [flang] unit test support for out-of-tree and in-tree using google tests framework
Review comments addressed.
2020-06-15 22:09:56 +05:30
David Truby 9362698450 [flang] Change DIE("unreachable") cases to use llvm_unreachable
Reviewers: sscalpone

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79507
2020-06-15 17:21:35 +01:00
Eric Schweitz 4741835e03 [flang] Add the helper class for building fir.do_loop operations. A fir.do_loop models the semantics of a Fortran DO loop construct. One can use this operation to explicitly capture a DO loop for passing into the high-level optimizer.
Differential revision: https://reviews.llvm.org/D81692
2020-06-12 17:28:00 -07:00
Pete Steinfeld bb2f6f66c7 [flang] Added test for specification expressions
I added a test the exercises all of the cases instances of specification expressions as defined in section 10.1.11.

Summary: [flang] Added test for specification expressions

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81759
2020-06-12 15:13:24 -07:00
peter klausler a0226f9bff [flang] Dodge bogus uninitialized data warning from gcc 10.1 via code cleanup
G++ 10.1 emits inappropriate "use of uninitialized data" warnings when
compiling f18.  The warnings stem from two sites in templatized code
whose multiple instantiations magnified the number of warnings.

These changes dodge those warnings by making some innocuous changes to
the code.  In the parser, the idiom defaulted(cut >> x), which yields a
parser that always succeeds, has been replaced with a new equivalent
pass<T>() parser that returns a default-constructed value T{} in an
arguably more readable fashion.  This idiom was the only attestation of
the basic parser cut, so it has been removed and the remaining code
simplified.  In Evaluate/traverse.h, a return {}; was replaced with a
return of a default-constructed member.

Differential Revision: https://reviews.llvm.org/D81747
2020-06-12 10:05:05 -07:00
sameeran joshi 70ad73b6b7 [flang] Semantics for SELECT TYPE
Summary:
    Added support for all semantic checks except C1157
    was previously implemented.

    Address review comments.

    Reviewers: PeteSteinfeld, tskeith, klausler, DavidTruby, kiranktp, anchu-rajendran, sscalpone

    Subscribers: kiranchandramohan, llvm-commits, flang-commits

    Tags: #llvm, #flang

    Differential Revision: https://reviews.llvm.org/D79851
2020-06-12 00:12:24 +05:30
Eric Schweitz 8bba0bca72 [flang] Add the complex expression helper class.
The complex expression helper class can be used to generate small,
short-lived instances of a "helper" that can be used to aid the
construction of complex expressions in FIR. The helper class bundles
together these functionally related operations.

Included in this diff is the header for the FIR builder. The
implementation has other dependences and will follow.

Differential Revision: https://reviews.llvm.org/D81287
2020-06-10 09:05:20 -07:00
Tim Keith a27d385209 [flang] Fix bug resolving type in type definition
When we encountered a type name in a derived type definition, we were
sometimes finding a component of that name rather than the type from
the enclosing scope. Fix this by introducing `NonDerivedTypeScope()` to
start the search in the right scope.

Differential Revision: https://reviews.llvm.org/D81493
2020-06-09 14:14:03 -07:00
Valentin Clement 38674030c0 Apply fix from D81179 only from GCC < 8
Summary: Apply workaround done in D81179 only for GCC < 8. As @klausler mentioned in D81179 we want to avoid additional checks for other compilers that do not need them.

Reviewers: DavidTruby, klausler, jdoerfert, sscalpone

Reviewed By: klausler, sscalpone

Subscribers: llvm-commits, tskeith, isuruf, klausler

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D81208
2020-06-08 15:51:57 -04:00
Isuru Fernando bb73d1b278 [flang] Fix issue of flang/runtime/config.h not being found in out of tree builds
Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=46078

Reviewers: DavidTruby, jdoerfert, PeteSteinfeld, sscalpone, tskeith

Reviewed By: PeteSteinfeld, sscalpone, tskeith

Subscribers: mgorny, llvm-commits, tskeith

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D81266
2020-06-08 14:16:08 -05:00
Isuru Fernando 3862cbbc65 [flang] Use LLVM's flags
Summary:
The only difference is that LLVM_ENABLE_WERROR is set to OFF
by default, but we enable this in a standalone flang build

This commit fixes some windows issues with the flags

Reviewers: DavidTruby, jdoerfert, sscalpone

Reviewed By: DavidTruby, sscalpone

Subscribers: ormris, richard.barton.arm, mehdi_amini, Meinersbur, ChinouneMehdi, tskeith, mgorny, llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D78306
2020-06-08 15:29:52 +01:00
Pete Steinfeld 4d8c00c059 [flang] Fix crash on erroneous expressions
Summary:
If you create an expression with parse errors, the `parser::Expr.typedExpr`
will be empty, which causes a compiler crash.  The crash is caused by the
check in check-do-forall.cpp that scans all expresssions to see if `DO`
variables are being modified.

It turned out that the problem was that I was fetching subexpressions of type
`parser::Expr`, which are not guaranteed to have a non-null `typedExpr`.  I
fixed this by only grabbing the top-level expression from which to gather
arguments as part of the DO loop analysis.  This, in turn, exposed a problem
where I wasn't collecting all of the actual arguments in an expression.  This
was caused by the fact that I wasn't recursing through the rest of the
expression after finding an argument.  I fixed this by recursing through the
argument in the member function in `CollectActualArgumentsHelper`.

Reviewers: klausler, tskeith, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81101
2020-06-05 08:46:43 -07:00
Pete Steinfeld 1746c8ed26 [flang] Fixed crash on forward referenced len parameter
Summary:
Using a forward reference to define a `len` parameter causes a crash.
The underlying cause was that a previously declared type had an
erroneous expression for its `LEN` param value.  When this expression
was referenced to evaluate a subsequent expression, bad things happened.
I fixed this by putting in code to detect this case.

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80593
2020-06-04 13:12:11 -07:00
Eric Schweitz baa12ddb6f [flang] Add the conversions for types.
Part of lowering is to convert the front-end types to their FIR dialect representations.  These conversions are done by here in the ConvertType module.

proactively update the code to conform better with LLVM coding conventions

Differential Revision: https://reviews.llvm.org/D81034
2020-06-04 12:54:50 -07:00
Valentin Clement 3d9bb031d1 [flang] avoid GCC < 8 compiler failure after D80794
Summary:
Patch D80794 remove the custom flags for release build for flang.
This leads to build failure with GCC < 8. This patch add upperbound check
in order to avoid the -Werror=array-bounds to trigger a build failure.

```
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
```

```
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:809:28: error: array subscript is above array bounds [-Werror=array-bounds]
               xy += product[to];
                     ~~~~~~~^
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:810:22: error: array subscript is above array bounds [-Werror=array-bounds]
               product[to] = xy & partMask;
               ~~~~~~~^
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:809:28: error: array subscript is above array bounds [-Werror=array-bounds]
               xy += product[to];
                     ~~~~~~~^
```

Reviewers: DavidTruby, sscalpone, jdoerfert

Reviewed By: DavidTruby

Subscribers: llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D81179
2020-06-04 14:48:39 -04:00
Jean Perier 62b127eef6 [flang] Fix IsConstantExpr for division expressions
Summary:
Fortran::evaluate::IsConstantExpr did not check that the numerator
was a constant expression. This patch fixes the issue.

Reviewers: DavidTruby, klausler, schweitz, PeteSteinfeld, jdoerfert, sscalpone

Reviewed By: klausler, PeteSteinfeld, sscalpone

Subscribers: llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D81096
2020-06-04 09:44:44 +02:00
Anchu Rajendran 70f1b4b412 [flang] Implemented 2 Semantic checks for DATA statement and fixed a few bugs
Summary
  - Implemented C876, C877
  - Fixed IsConstantExpr to check C879
  - Fixed bugs in few test cases - data01.f90, block-data01.f90,
  pre-fir-tree02.f90
  - Modified implementation of C8106 to identify all automatic objects
  and modified equivalence01.f90 to reflect the changes

Differential Revision: https://reviews.llvm.org/D78424
2020-06-03 10:33:26 +05:30
David Truby 81bf1e29aa [flang] Fix release build flags.
Summary:
This patch removes the custom CMAKE_RELEASE_CXX_FLAGS variable.
This variable being set was having the effect of removing other important
Release flags, notably `-DNDEBUG`.

This patch may need to be accompanied by fixes for the macOS issues that
the removed comment mentions; I don't have a mac to test this on though so
hopefully a reviewer can help with that.

Reviewers: Andrzej, tskeith, sscalpone

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80794
2020-06-02 16:29:12 +01:00
Eric Schweitz ae6e499d25 [flang] This adds the lowering stubs for Open MP.
The lowering bridge will call these lowering hooks to process the Open
MP directives that it iterates over in the PFT.  This is a mock
interface without an implementation in this patch.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D80815
2020-06-01 09:11:53 -07:00
Tim Keith 14f49599cc [flang][NFC] Remove link-time dependency of Evaluate on Semantics
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-29 16:39:14 -07:00
Eric Schweitz fbac9ce226 [flang] Batch together the changes to the PFT intermediate data
structure for upstreaming to llvm-project.

These files have had many changes since they were originally upstreamed.
Some of the changes are cosmetic.  Most of the functional changes were
done to support the lowering of control-flow syntax from the front-end
parse trees to the FIR dialect.

This patch is meant to be a reviewable size. The functionality it
provides will be used by code yet to be upstreamed in lowering.

review comments:

[review D80449][NFC] make PFT ParentVariant a ReferenceVariant

ReferenceVariant had to be slightly updated to also support
non constant references (which is required for ParentType).

[review D80449] extend Variable implementation beyond a comment
2020-05-29 15:24:20 -07:00
Pete Steinfeld c4dbe59ae8 [flang] Fixes for problems with declaring procedure entities
Summary:
We were not detecting declaring multiple interfaces to the same procedure.
Also, we were not handling the initialization of entitiies where the associated
Symbol had previously had errors.

I added the function `IsInterfaceSet()` to ProcEntityDetails to see if
the value of `interface_` had been previously set.  I then checked  this
function before calling set_interface() and emitted an error message if
the interface was already set.

Also, in situations where we were emitting error messages for symbols, I
set the Error flag on the Symbol.  Then when performing initialization
on the Symbol, I first check to see if the Symbol had an error.

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80453
2020-05-26 12:17:20 -07:00
Pete Steinfeld 38095549c6 [flang] Constraint checks C751 to C760
Summary:
Many of these were already implemented, and I just annotated the tests and/or
the code.

C752 was a simple check to verify that CONTIGUOUS components are arrays with

C754 proved to be virtually identical to C750 that I implemented previously.
This caused me to remove the distinction between specification expressions for
type parameters and bounds expressions that I'd previously created.
the POINTER attribute.

I also changed the error messages to specify that errors in specification
expressions could arise from either bad derived type components or type
parameters.

In cases where we detect a type param that was not declared, I created a symbol
marked as erroneous.  That avoids subsequent semantic process for expressions
containing the symbol.  This change caused me to adjust tests resolve33.f90 and
resolve34.f90.  Also, I avoided putting out error messages for erroneous type
param symbols in `OkToAddComponent()` in resolve-names.cpp and in
`EvaluateParameters()`, type.cpp.

C756 checks that procedure components have the POINTER attribute.

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D79798
2020-05-15 18:50:14 -07:00
Eric Christopher b1ae13b4e9 Fix flang build after mlir SideEffects.h -> SideEffectInterfaces.h change. 2020-05-15 15:51:32 -07:00
Alex Zinenko 4ead2cf76c [mlir] Rename conversions involving ex-Loop dialect to mention SCF
The following Conversions are affected: LoopToStandard -> SCFToStandard,
LoopsToGPU -> SCFToGPU, VectorToLoops -> VectorToSCF. Full file paths are
affected. Additionally, drop the 'Convert' prefix from filenames living under
lib/Conversion where applicable.

API names and CLI options for pass testing are also renamed when applicable. In
particular, LoopsToGPU contains several passes that apply to different kinds of
loops (`for` or `parallel`), for which the original names are preserved.

Differential Revision: https://reviews.llvm.org/D79940
2020-05-15 10:45:11 +02:00
Valentin Clement 85725a67c7 [Flang][OpenMP] Avoid abort when collapse clause value is negative
Summary:
If the value in the collapse close is negative f18 abort without the correct error message. This PR change the size_t in name resolution to a int64_t and check appropriately for negative or zero before the privatization of induction variable.
The correct error is then catch by the OpenMP structure check.

This diff is migrated from the GitHub pull request https://github.com/flang-compiler/f18/pull/1098

Reviewers: ichoyjx, jdoerfert, sscalpone, DavidTruby

Reviewed By: ichoyjx, sscalpone, DavidTruby

Subscribers: sscalpone, klausler, yaxunl, guansong, llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D77821
2020-05-14 21:37:25 -04:00
Stephen Neuendorffer 661b234cbc [MLIR] Rename SideEffects.td -> SideEffectInterfaces.td
This normalize the name of the tablegen file with the name of the generated
files (SideEffectInterfaces.h.inc) and the other Interface tablegen files,
which all end in Interface(s).td

Differential Revision: https://reviews.llvm.org/D79517
2020-05-12 12:21:42 -07:00
Tim Keith 6f300105d2 [flang] Fix bug with IMPORT of USE of USE
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-11 13:28:07 -07:00
Tim Keith 99aa87a5b5 [flang][NFC] Simplify semantics test scripts
There were several different ways of handling the option to f18 to
find predefined modules:
- test_errors.sh was created by cmake substituting
  FLANG_INTRINSIC_MODULES_DIR into test_errors.sh.in
- some tests used the flang script which has the option built it
- some tests used %f18_with_includes which was replaced by the path
  to f18 plus the -I option
- some included -I../../include/flang in their run command

To make this more consistent, change %f18 to include the
-intrinsic-module-directory option and use it everywhere, including
to replace %flang and %f18_with_includes. This requires changing all
of the invocations of the test scripts to put %f18 at the end so that
it can expand to more than one argument.

This eliminates the need to generate test_errors.sh which means we
don't need flang/test/Semantics/CMakeLists.txt or the %B substitution.
That makes the test_errors.sh command like the others, replacing
%B/test/Semantics/test_errors.sh with %S/test_errors.sh.

Also remove the OPTIONS: functionality as custom options can be included
in the RUN: command. And remove -I/../../include/flang as that is now
always included.

Differential Revision: https://reviews.llvm.org/D79634
2020-05-11 11:49:25 -07:00
Valentin Clement 63a4fdda8c [flang] Fix compilation after rename of Loop dialect to scf
Summary: Flang was not compiling correctly after the renaming of Loop dialect to SCF. This patch fixes the problem.

Reviewers: ftynse, DavidTruby

Reviewed By: ftynse

Subscribers: aartbik, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79723
2020-05-11 13:15:33 -04:00
Tim Keith b05c8c5756 [flang] Make implicit conversion explicit in assignment
When intrinsic types are assigned there are some implicit conversions
that take place. This change make them explicit in the types
representation of assignments.

Differential Revision: https://reviews.llvm.org/D79637
2020-05-09 09:11:00 -07:00
sameeran joshi 332e6aea37 [flang]Semantics for SELECT RANK.
Summary:
    Initially on github I worked on semantic checks.Then I tried some compile-time
    test of the rank value, they were failing as there were no symbols
    generated for them inside SELECT RANK's scope.So I went further to
    add new symbol in each scope, also added the respective 'rank: '
    field for a symbol when we dump the symboltable. I added a field to
    keep track of the rank in AssocEntityDetails class.This caused shape
    analysis framework to become inconsistent. So shape analysis framework
    was updated to handle this new representation.

	 *   I added more tests for above changes.

	 *   On phabricator I addressed some minor changes.

	 *   Lastly I worked on review comments.

    Reviewers: klausler,sscalpone,DavidTruby,kiranchandramohan,tskeith,anchu-rajendran,kiranktp

    Reviewed By:klausler, DavidTruby, tskeith

    Subscribers:#flang-commits, #llvm-commits

    Tags: #flang, #llvm

    Differential Revision: https://reviews.llvm.org/D78623
2020-05-08 08:52:31 +05:30
Jacques Pienaar 5eae715a31 [mlir] Add NamedAttrList
This is a wrapper around vector of NamedAttributes that keeps track of whether sorted and does some minimal effort to remain sorted (doing more, e.g., appending attributes in sorted order, could be done in follow up). It contains whether sorted and if a DictionaryAttr is queried, it caches the returned DictionaryAttr along with whether sorted.

Change MutableDictionaryAttr to always return a non-null Attribute even when empty (reserve null cases for errors). To this end change the getter to take a context as input so that the empty DictionaryAttr could be queried. Also create one instance of the empty dictionary attribute that could be reused without needing to lock context etc.

Update infer type op interface to use DictionaryAttr and use NamedAttrList to avoid incurring multiple conversion costs.

Fix bug in sorting helper function.

Differential Revision: https://reviews.llvm.org/D79463
2020-05-07 12:33:36 -07:00
sameeran joshi cc4768f2ec [flang]Add examples in documentation/BijectiveInternalNameUniquing.md
Summary:
    I thought it would be simpler to understand on how the unique names would
    look like when an example is present. So I added some examples.

    I found 2 such places to add examples
    -Common blocks
    -Module scope global data

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

    Reviewed By: schweitz, jeanPerier

    Subscribers: llvm-commits, flang-commits

    Tags: #flang, #llvm

    Differential Revision: https://reviews.llvm.org/D79442
2020-05-08 00:01:35 +05:30
Tim Keith 7ccc7e5672 [flang] Fix to IsDescriptor
IsDescriptor was returning false for a component whose shape depended
on a length parameter. Change it to return true for any array with
non-constant bounds.

Differential Revision: https://reviews.llvm.org/D79349
2020-05-07 07:51:45 -07:00
Tim Keith 54b35c0664 [flang][NFC] Replace "align" with "alignment"
In the places it is used as a noun, replace "align" with "alignment".

Differential Revision: https://reviews.llvm.org/D79520
2020-05-06 15:03:30 -07:00
Pete Steinfeld 07b69dcf66 [flang] Response to Steve Scalpone's suggestion to improve a message
Summary: I updated the code that produces the message and the associated test.

Reviewers: sscalpone, DavidTruby, kiranchandramohan

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79514
2020-05-06 15:00:53 -07:00
Pete Steinfeld cfce9b6760 [flang] Response to Steve Scalpone's suggestion to improve a message
Summary: I updated the code that produces the message and the associated test.

Reviewers: sscalpone, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79514
2020-05-06 12:28:21 -07:00
Tim Keith d5c05ced82 [flang][NFC] Add accessors to equivalence and common blocks
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-05-06 12:22:28 -07:00
Tim Keith 237d0e3c04 [flang] Handle EQUIVALENCE and COMMON in size and offset computations
Objects in common blocks have offsets relative to the start of the
common block, independent of the enclosing scope, so they are processed
first. Add alignment to CommonBlockDetails to record the required
alignment of the common block.

For equivalence sets, each object depends on the one that is forced to
occur first in memory. The rest are recorded in the dependents_ map and
have offsets assigned after the other symbols are done.

Differential Revision: https://reviews.llvm.org/D79347
2020-05-06 11:45:28 -07:00
Tim Keith 0195b3a909 [flang] Fix bug in tests for standalone build
When doing a standalone build of flang against an LLVM that contains a
built flang, the tests were run on the flang from LLVM rather than on
the one that was just built.

The problem was in the lit configuration for finding %flang etc.
Fix it to look only in the directory where it was built.

Differential Revision: https://reviews.llvm.org/D79327
2020-05-05 11:08:23 -07:00
Pete Steinfeld 8d0c3c05f2 [flang] New implementation for checks for constraints C741 through C750
Summary:
Most of these checks were already implemented, and I just added references to
them to the code and tests. Also, much of this code was already
reviewed in the old flang/f18 GitHub repository, but I didn't get to
merge it before we switched repositories.

I implemented the check for C747 to not allow coarray components in derived
types that are of type C_PTR, C_FUNPTR, or type TEAM_TYPE.

I implemented the check for C748 that requires a data component whose type has
a coarray ultimate component to be a nonpointer, nonallocatable scalar and not
be a coarray.

I implemented the check for C750 that adds additional restrictions to the
bounds expressions of a derived type component that's an array.
These bounds expressions are sepcification expressions as defined in
10.1.11.  There was already code in lib/Evaluate/check-expression.cpp to
check semantics for specification expressions, but it did not check for
the extra requirements of C750.

C750 prohibits specification functions, the intrinsic functions
ALLOCATED, ASSOCIATED, EXTENDS_TYPE_OF, PRESENT, and SAME_TYPE_AS. It
also requires every specification inquiry reference to be a constant
expression, and requires that the value of the bound not depend on the
value of a variable.

To implement these additional checks, I added code to the intrinsic proc
table to get the intrinsic class of a procedure.  I also added an
enumeration to distinguish between specification expressions for
derived type component bounds versus for type parameters.  I then
changed the code to pass an enumeration value to
"CheckSpecificationExpr()" to indicate that the expression was a bounds
expression and used this value to determine whether to emit an error
message when violations of C750 are found.

I changed the implementation of IsPureProcedure() to handle statement
functions and changed some references in the code that tested for the
PURE attribute to call IsPureProcedure().

I also fixed some unrelated tests that got new errors when I implemented these
new checks.

Reviewers: tskeith, DavidTruby, sscalpone

Subscribers: jfb, llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D79263
2020-05-05 09:37:39 -07:00
Stephen Neuendorffer f432154d1b [flang] update tools/f18 to use LLVM_LINK_COMPONENTS.
This will prevent conflicts with libLLVM.so when using LLVM_LINK_LLVM_DYLIB=on.

Differential Revision: https://reviews.llvm.org/D79370
2020-05-05 08:55:17 -07:00
peter klausler 6fec2c4402 [flang] Fix x87 binary->decimal
Summary:
Fix decimal formatting of 80-bit x87 values; the calculation ofnearest neighbor values failed to account for the explicitmost significant bit in that format.

Replace MultiplyByRounded with MultiplyBy in binary->decimal conversions,
since rounding won't happen and the name was misleading; then remove
dead code, and migrate LoseLeastSignificantDigit() from one source file
to another where it's still needed.

Reviewers: tskeith, sscalpone, jdoerfert, DavidTruby

Reviewed By: tskeith

Subscribers: llvm-commits, flang-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D79345
2020-05-04 12:04:08 -07:00
Pete Steinfeld b6f1bad630 [flang] Fixed a crash
Summary:
I found a small test case that caused a crash when derived type
definitions have parameters without definitions.

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79282
2020-05-04 07:54:23 -07:00
River Riddle 1165a35a73 [IndexedAccessorRange] Only offset the base if the index is non-zero.
This is more efficient and removes the need for derived ranges to handle the degenerate empty case.
2020-05-01 11:56:39 -07:00