Commit Graph

726 Commits

Author SHA1 Message Date
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
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
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
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 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
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
Eric Schweitz bc0342383d [flang] Upstream recent work on FIR to llvm-project.
Summary:

Reviewers: DavidTruby, sscalpone, jeanPerier

Subscribers: mgorny, aartbik, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78835
2020-04-27 17:48:57 -07:00
David Truby 75c31057a7 [flang] Semantic checks for OpenMP combined constructs.
Summary:
This includes a refactor of the existing combined construct checks
that were present, as well as adding the remaining combined constructs
that had not been implemented yet.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77812
2020-04-27 12:40:49 +01:00
David Truby b547e1a4d1 [flang] Fix handling of files without terminating newlines.
Reviewers: sscalpone

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78578
2020-04-27 12:40:22 +01:00
peter klausler 3a1afd8c3d Rework DATA statement semantics to use typed expressions
Summary:
Updates recent work on DATA statement semantic checking in
flang/lib/Semantics/check-data.{h,cpp} to use the compiler's
internal representation for typed expressions rather than working
on the raw parse tree.  Saves the analyzed expressions for DATA
statement values as parse tree decorations because they'll soon be
needed in lowering.  Corrects wording of some error messages.

Fixes a bug in constant expression checking: structure constructors
are not constant expressions if they set an allocatable component
to anything other than NULL.

Includes infrastructure changes to make this work, some renaming
to reflect the fact that the implied DO loop indices tracked by
expression analysis are not (just) from array constructors, remove
some dead code, and improve some comments.

Reviewers: tskeith, sscalpone, jdoerfert, DavidTruby, anchu-rajendran, schweitz

Reviewed By: tskeith, anchu-rajendran, schweitz

Subscribers: llvm-commits, flang-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D78834
2020-04-25 10:29:34 -07:00
Tim Keith c353ebbfa4 [flang] Compute sizes and offsets for symbols
Summary:
Add size and offset properties to symbols, representing their byte size
and offset within their enclosing scope.

Add size and align properties to scopes so that they are available for
scopes representing derived types.

Add ComputeOffsets pass over the symbol table to fill in those fields.

Compute descriptor size based on rank and length parameters. Extract
DerivedTypeSpec::NumLengthParameters from DynamicType::RequiresDescriptor
to share the code.

Add Scope::GetSymbols to get symbols in canonical order.
compute-offsets.cpp and mod-file.cpp both need to process symbols in the
order in which they are declared. Move the collecting of those symbols
into Scope so that it can be shared.

Add symbol size and offset to output of `-fdebug-dump-symbols` and use
that in some tests.

Still to do:
- make size and alignment rules configurable based on target
- use offsets to check EQUIVALENCE statements

Differential Revision: https://reviews.llvm.org/D78680
2020-04-23 14:54:34 -07:00
Rainer Orth 0535fab237 [Flang][test] Don't set PATH in flang/test/Semantics/common.sh
Currently, many `Flang :: Semantics` tests FAIL on Solaris.  The failure
mode is always the same:

  actual at 67: Name in ALLOCATE statement must be a variable name
  expect at 67: ERROR: Name in ALLOCATE statement must be a variable name

It turns out the issue is twofold here:

- The awk script embedded in `flang/test/Semantics/common.sh` uses a string
  value for `FS`, which isn't supported by traditional awk as documented in
  the GNU autoconf manual.

- Even though /usr/gnu/bin (with gawk installed as awk) is in my build
  environment's `PATH`, still /bin/awk is used

Although the proper fix would probably be to avoid the unportability, it's
easy to work around it for now.  `common.sh` above is the only script in
the whole tree that for unknown reasons overrides `PATH` to
`/usr/bin:/bin`, unnecessarily creating this mess in the first place.  Just
removing that setting easily avoids the issue.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D78550
2020-04-21 14:32:57 +02:00
Anchu Rajendran c1c01212c4 [flang]Implemented Semantic Checkes for 5 data constraints
Summary:
 C874, C875, C878, C880 and C881 checks are implemented.

Differential Revision: https://reviews.llvm.org/D78008
2020-04-18 12:21:30 +05:30
Eric Schweitz d58a405de6 [flang] Upstream patch to enable the fir-ops test. bug 45487
Differential revision: https://reviews.llvm.org/D77834
2020-04-14 10:02:04 -07:00
Mehdi Amini ed6c452edc Add missing dependencies on the flang test target
Without this, the LLVM utilities (FileCheck) aren't built when running
`ninja check-flang` and it fails with:

llvm-project/llvm/utils/lit/lit/llvm/subst.py:134: fatal: Did not find FileCheck in...

Also the modules aren't built without depending on `module_files`, which
makes multiple tests failing.

Differential Revision: https://reviews.llvm.org/D78036
2020-04-13 18:23:01 +00:00
David Truby 89c7d9633b [flang] Temporarily XFAIL failing test Fir/fir-ops.fir 2020-04-09 18:36:17 +01:00
peter klausler 455ed8de4f [flang] Process names in ASSIGN and assigned GOTO
Allow ASSIGNed integer variables as formats

Address review comment

Original-commit: flang-compiler/f18@361a151508
Reviewed-on: https://github.com/flang-compiler/f18/pull/1099
2020-04-03 14:58:07 -07:00
Pete Steinfeld 2b790490b6 [flang] Checks for constraints C731 through C740
In most cases, I just added the contraint names to the code and tests.

I implemented the following checks:
  - C736 A child type with a coarray ultimate component must have a parent with
    a coarray ultimate component.
  - C737 A child type with and EVENT_TYPE or LOCK_TYPE component must have a
    parent either which is EVENT_TYPE or LOCK_TYPE or a type with an EVENT_TYPE
    or LOCK_TYPE component.
  - C740 Sequence types must contain at least on component
  - C740 Data components of sequence types must either be of an intrinsic type
    or a sequenced derived type.

After implementing these checks, some tests had new errors unrelated to their
original purpose, so I fixed them.

Original-commit: flang-compiler/f18@098f01bc47
Reviewed-on: https://github.com/flang-compiler/f18/pull/1097
2020-04-02 06:41:33 -07:00
peter klausler 7a77c20dbd [flang] Semantics for SELECT CASE
Prep for review

Respond to review comments

Fix first line in new test

Original-commit: flang-compiler/f18@12f6f30600
Reviewed-on: https://github.com/flang-compiler/f18/pull/1089
2020-03-27 12:02:11 -07:00
Patrick McCormick 6c16aa4f67 [flang] A rework of the cmake build components for in and out of tree builds.
In general all the basic functionality seems to work and removes some redundancy
and more complicated features in favor of borrowing infrastructure from LLVM
build configurations. Here's a quick summary of details and remaining issues:

  * Testing has spanned Ubuntu 18.04 & 19.10, CentOS 7, RHEL 8, and
    MacOS/darwin.  Architectures include x86_64 and Arm.  Without
    access to Window nothing has been tested there yet.

  * As we change file and directory naming schemes (i.e.,
    capitalization) some odd things can occur on MacOS systems with
    case preserving but not case senstive file system configurations.
    Can be painful and certainly something to watch out for as any
    any such changes continue.

  * Testing infrastructure still needs to be tuned up and worked on.
    Note that there do appear to be cases of some tests hanging (on
    MacOS in particular).  They appear unrelated to the build
    process.

  * Shared library configurations need testing (and probably fixing).

  * Tested both standalone and 'in-mono repo' builds.  Changes for
    supporting the mono repo builds will require LLVM-level changes that
    are straightforward when the time comes.

  * The configuration contains a work-around for LLVM's C++ standard mode
    passing down into Flang/F18 builds (i.e., LLVM CMake configuration would
    force a -std=c++11 flag to show up in command line arguments.  The
    current configuration removes that automatically and is more strict in
    following new CMake guidelines for enforcing C++17 mode across all the
    CMake files.

  * Cleaned up a lot of repetition in the command line arguments.  It
    is likely that more work is still needed to both allow for
    customization and working around CMake defailts (or those
    inherited from LLVM's configuration files). On some platforms agressive
    optimization flags (e.g. -O3) can actually break builds due to the inlining
    of templates in .cpp source files that then no longer are available for use
    cases outside those source files (shows up as link errors).   Sticking at -O2
    appears to fix this.  Currently this CMake configuration forces this in
    release mode but at the cost of stomping on any CMake, or user customized,
    settings for the release flags.

  * Made the lit tests non-source directory dependent where appropriate. This is
    done by configuring certain test shell files to refer to the correct paths
    whether an in or out of tree build is being performed. These configured
    files are output in the build directory. A %B substitution is introduced in
    lit to refer to the build directory, mirroring the %S substitution for the
    source directory, so that the tests can refer to the configured shell scripts.

Co-authored-by: David Truby <david.truby@arm.com>

Original-commit: flang-compiler/f18@d1c7184159
Reviewed-on: https://github.com/flang-compiler/f18/pull/1045
2020-03-26 18:17:04 +00:00
peter klausler c42f6314eb [flang] Semantics for ENTRY
initial test passes

Move some checks to check-declarations

Fix bugs found in testing

Get tests all passing

Allow declaration statements for function result to follow ENTRY

Fix another bug

Original-commit: flang-compiler/f18@e82cfee432
Reviewed-on: https://github.com/flang-compiler/f18/pull/1086
2020-03-24 14:30:34 -07:00
Pete Steinfeld e17e71735e [flang] Changes to enforce constraints C727 to C730 and most constraints related to attributes
The full list of constraints is C727, C728, C729, C730, C743, C755, C759, C778,
and C1543.

I added a function to tools.cpp to check to see if a symbol name is the name
of an intrinsic type.

The biggest change was to resolve-names.cpp to check to see if attributes were
either duplicated or in conflict with each other.  I changed all locations
where attributes were set to check for duplicates or conflicts.

I also added tests for all checks and annotated the tests and code with the
numbers of the constraints being tested/checked.

Original-commit: flang-compiler/f18@3f30e8a61e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1084
2020-03-24 09:24:49 -07:00
David Truby 13ea73e42d [flang] Replace manual mmap with llvm::MemoryBuffer
The previous code had handling for cases when too many file descriptors may be
opened; this is not necessary with MemoryBuffer as the file descriptors are
closed after the mapping occurs. MemoryBuffer also internally handles the case
where a file is small and therefore an mmap is bad for performance; such files
are simply copied to memory after being opened.

Many places elsewhere in the code assume that the buffer is not empty, and the
old file opening code handles this by replacing an empty file with a buffer
containing a single newline. That behavior is now kept in the new MemoryBuffer
based code.

Original-commit: flang-compiler/f18@d34df84351
Reviewed-on: https://github.com/flang-compiler/f18/pull/1032
2020-03-24 13:35:01 +00:00
peter klausler 9977b24a6d [flang] Improve error message for procedure passed as invalid argument to an intrinsic
Support forward references to sibling module procedures

Add tests, handle corner cases

Rename new test

Original-commit: flang-compiler/f18@234bb519cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/1076
2020-03-18 14:04:08 -07:00
Tim Keith 61b1390e2a [flang] Check module subprogram against separate module procedure
When a module subprogram has the MODULE prefix the following must match
with the corresponding separate module procedure interface body:
- C1549: characteristics and dummy argument names
- C1550: binding label
- C1551: NON_RECURSIVE prefix

SubprogramMatchHelper performs all of these checks.

Rename separate-module-procs.f90 to separate-mp01.f90 so we can have
separate-mp02.f90 (etc).

Make ShapesAreCompatible public in characteristics.h.

Add Scope::IsSubmodule.

Original-commit: flang-compiler/f18@d121578af1
Reviewed-on: https://github.com/flang-compiler/f18/pull/1080
2020-03-17 16:01:59 -07:00
Tim Keith 824d198e31 [flang] Create symbols for args of separate-module-subprogram
A separate-module-subprogram is declared as `module procedure ...`
and gets its characteristics from the declaration of that name as
a separate module procedure. When we encounter one, we need to create
symbols in the new subprogram scope for the dummy arguments and
function return (if any).

The failure to create these symbols led to the bug in issue flang-compiler/f18#1054:
when a dummy argument was referenced, the compiler interpreted it as
an implicit declaration because there was no symbol for the argument.

Fixes flang-compiler/f18#1054.

Original-commit: flang-compiler/f18@4d3c4bac84
Reviewed-on: https://github.com/flang-compiler/f18/pull/1080
Tree-same-pre-rewrite: false
2020-03-17 16:01:59 -07:00
Tim Keith d1ce4d275f [flang] Fix location of name of Symbol for ProcEntity
When we encounter a ProcDecl and a symbol for it has already been
created, replace the CharBlock for the name with the one in the ProcDecl
as it is the "main" declaration of that name. This matches what is done
for an EntityDecl.

This moves the location of some error messages to a better source
location so update the affected tests.

Original-commit: flang-compiler/f18@514c0f2c94
Reviewed-on: https://github.com/flang-compiler/f18/pull/1080
Tree-same-pre-rewrite: false
2020-03-17 16:01:59 -07:00
peter klausler f4faeefe3d [flang] Do not emit a prefix for a default-kind character constant in AsFortran
Original-commit: flang-compiler/f18@4a3db55727
Reviewed-on: https://github.com/flang-compiler/f18/pull/1078
2020-03-17 12:35:31 -07:00
Tim Keith 6905526a10 [flang] Test cleanup
Fix omp-nested01.f90 so that it is not an expected failure. The test was
never enabled but I'm guessing this is what it's supposed to do.

Fix the instructions to include "make test" as part of running tests.

Original-commit: flang-compiler/f18@c351181cab
Reviewed-on: https://github.com/flang-compiler/f18/pull/1075
2020-03-16 10:46:17 -07:00
Luke Ireland da9d002b18 [flang] Added CMakeLists changes, moved config and made test scripts compatible.
All Fortran tests are now run in lit, except Preprocessing tests flang-compiler/f18#1052
Preprocessing tests are a separate kind of test, so will be sorted out
later.

Original-commit: flang-compiler/f18@3f99d35f3d
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
2020-03-13 13:54:24 +00:00
Luke Ireland f1a8eae3b6 [flang] Port all remaining regression tests to lit
We have re-classified a subset of the regression tests as unit tests and
now we are porting the remaining ones.

Test discovery and running is now performed by lit rather than ctest.
The tests continue to use their original scripts with minor
modifications. Most of the changes were mechanical and so scripted.
A few changes were made by hand. Details

Manual:
  * modfile09-*.f90 tests depend on being run together as some tests have
    dependencies on modules created by other tests. This will need
     separating out when porting away from test_modfile.sh, but for now,
     added modfile09-*.f90 to the Inputs directory and added a single
     tests modfile09.f90 to hold the run line.
  * getdefinition03-a.f90 includes a non-test file getdefinition03-b.f90.
    Manually edited the former to find the latter in Inputs so as to add
    only one test.
  * Same pattern for getsymbols03-{a,b}.f90

Auto:
  * Remaining tests have a lit RUN line added to them based on the type
    of test they are.
  * Failing tests also have an XFAIL line added to them.
  * Generic tests have their pre-existing RUN lines replaced with the
    word "EXEC" to avoid conflict with the added lit RUN line.

Original-commit: flang-compiler/f18@63ec0af9f4
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
Tree-same-pre-rewrite: false
2020-03-13 11:58:11 +00:00
Luke Ireland ee5fa1f233 [flang] Create a separate directory for unittests
Some of the regression tests are C programs that act as test harnesses
for the compiler internals as opposed to being Fortran inputs to test
the compiler in action. The former style of tests are analog to LLVM's
unittests and will not use the lit framework.

Change-Id: I0ff10e23f66ff843e8fff4c35cfb6559b9dab762

Original-commit: flang-compiler/f18@2bfddbe8f8
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
Tree-same-pre-rewrite: false
2020-03-13 11:58:11 +00:00
Luke Ireland a9d9261cf3 [flang] Re-enable semantics/altreturn{02,03} tests
These tests were disabled due to https://github.com/flang-compiler/f18/issues/407.
Previously these tests caused F18 to crash as the feature was not fully
implemented.

The altreturn feature is now implemented, so these tests can be
re-enabled. altreturn03 tested some negative cases which F18 correctly
diagnoses. Modified that test to expect these new error messages. Also
make the later cases in the test reachable.

These tests can now be ported by the script to lit-style tests.

Change-Id: Ib336c10d55068d9a26fc2deb43ad052e74e73456

Original-commit: flang-compiler/f18@4de19d7ba2
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
Tree-same-pre-rewrite: false
2020-03-13 11:58:11 +00:00
Isuru Fernando 231fae9087 [flang] Need <algorithm> for std::min and std::max (flang-compiler/f18#1063)
Original-commit: flang-compiler/f18@d0f9ef7742
Reviewed-on: https://github.com/flang-compiler/f18/pull/1063
2020-03-12 10:52:29 -07:00
peter klausler 3b63571425 [flang] Use hash table for UnitMap, avoid C++ STL binary dependence
Scan FORMAT strings locally to avoid C++ binary runtime dependence when computing deepest parenthesis nesting

Remove a dependency on ostream from runtime

Remove remaining direct external references from runtime to C++ library binaries

Remove runtime dependences on lib/common

SetPos() and SetRec()

Instantiate templates for input

Begin input; rearrange locking, deal with CLOSE races

View()

Update error message in test to agree with compiler change

First cut at real input

More robust I/O runtime error handling

Debugging of REAL input

Add iostat.{h,cpp}

Rename runtime/numeric-* to runtime/edit-*

Move templates around, templatize integer output editing

Move LOGICAL and CHARACTER output from io-api.cpp to edit-output.cpp

Change pointer argument to reference

More list-directed input

Complex list-directed input

Use enum class Direction rather than bool for templates

Catch up with changes to master

Undo reformatting of Lower code

Use record number instead of subscripts for internal unit

Unformatted sequential backspace

Testing and debugging

Dodge bogus GCC warning

Add <cstddef> for std::size_t to fix CI build

Address review comments

Original-commit: flang-compiler/f18@50406b3496
Reviewed-on: https://github.com/flang-compiler/f18/pull/1053
2020-03-11 13:23:39 -07:00
Tim Keith a40dbe7c41 [flang] Allow for vector subscript on LHS of assignment
Original-commit: flang-compiler/f18@38aefd41f0
Reviewed-on: https://github.com/flang-compiler/f18/pull/1062
2020-03-10 16:32:58 -07:00
Tim Keith 6ab50745c0 [flang] Fix scope accessibility check
The check for whether a private component is accessible was depending on
determining whether the source range of the current scope was within the
source range of the module that the component was declared in. This
could fail if the current scope was of kind `ImpliedDos` and had no
source range.

The fix is to add `Scope::Contains` to check the relationship by
traversing the parent links. These are created when the Scope is so are
always reliable. The source range of a scope is built up over time.

Original-commit: flang-compiler/f18@d787108637
Reviewed-on: https://github.com/flang-compiler/f18/pull/1060
2020-03-10 15:31:02 -07:00
Tim Keith a0a1f519c0 [flang] Perform definability checks on LHS of assignment
If the pure context check succeeds, call `WhyNotModifiable` to verify
the LHS can be modified.

Detect assignment to whole assumed-size array.

Change `IsVariable` to return false for a parameter or a component or
array reference whose base it a parameter.

When analyzing an assignment statement, report an error if the LHS is
a constant expression. Otherwise it might get folded and when we detect
the problem later the error will be confusing.

Handle Substring on LHS of assignment. Change ExtractDataRef and IsVariable
to work on a Substring.

Fix IsImpliedShape and IsAssumedSize predicates in ArraySpec.

Fix C709 check in check-declarations.cpp.

Original-commit: flang-compiler/f18@f2d2657aab
Reviewed-on: https://github.com/flang-compiler/f18/pull/1050
2020-03-09 17:25:12 -07:00
Steve Scalpone e0ca7b447b [flang] Fix for 'wrong constant folding of assumed-rank array' (flang-compiler/f18#1010)
https://github.com/flang-compiler/f18/issues/990

Original-commit: flang-compiler/f18@d971333025
Reviewed-on: https://github.com/flang-compiler/f18/pull/1010
2020-03-05 08:06:58 -08:00
Steve Scalpone e94ee41ec2 [flang] Don't link to libm (flang-compiler/f18#1038)
* Don't link to libm on windows

* Don't link to libm in Unix as well

Original-commit: flang-compiler/f18@a807862ab8
Reviewed-on: https://github.com/flang-compiler/f18/pull/1038
2020-03-05 05:40:44 -08:00
Tim Keith 47452b9691 [flang] Improve checking of structure constructor arguments
When a misparsed FunctionReference was converted to a StructureConstructor,
the components accessed were not checked for accessibility.

The conversion happens in expression analysis so that where the accessibity
must be checked. So move `CheckAccessibleComponent` to `tools.h` so that it
can be shared by `resolve-names.cpp` and `expression.cpp`.

Add FindModuleContaining to help implement this and use it other places.

Check that an access-spec can only appear in a module.

Remove some unnecessary "semantics::" qualifiers.

Original-commit: flang-compiler/f18@99ce156e49
Reviewed-on: https://github.com/flang-compiler/f18/pull/1046
2020-03-03 13:24:09 -08:00
Tim Keith 3495c78214 [flang] Improve array element errors
When something is parsed as an array element it was sometimes intended
to be a function call or structure constructor. So if the base name is
not found the errors can be confusing. This is an attempt to improve
them.

When the subscript list is empty, it was probably meant to be a function
call, so report that the name is not a function.

If the base is a scalar but there are subscripts, report that it is not
an array.

Original-commit: flang-compiler/f18@e2fd5333ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/1039
2020-03-02 16:45:02 -08:00
Tim Keith 2a00c617d6 [flang] Expression analysis on DataStmtConstant
Data statements contains expressions but they are not wrapped in one of
the kinds of parse tree nodes that are analyzed, like `parser::Expr`.
So potential errors were not discovered.

Change `ExprChecker` to handle `DataStmtConstant` and analyze any
expressions that are contained in it. Note that the analyzed form of
the expression is not yet saved in the parse tree.

Original-commit: flang-compiler/f18@8bdaf0a521
Reviewed-on: https://github.com/flang-compiler/f18/pull/1044
2020-03-02 07:59:29 -08:00
Varun Jayathirtha 92c1f6bb98 [flang] Add semantic checks C8104, C8105. Add tests for C8103, C8104, C8105
Original-commit: flang-compiler/f18@8134fc477e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1037
2020-02-27 15:55:46 -08:00