Commit Graph

3274 Commits

Author SHA1 Message Date
Jean Perier 1a4af2e45e [flang] preserve symbol in DescriptorInquiry
Do not use ultimate symbols in DescriptorInquiry. Using the ultimate
symbol may lead to issues later for at least two reasons:

- The original symbols may have volatile/asynchronous attributes that
  the ultimate may not have. Later phases working on the DescriptorInquiry
  would then not apply potential care required by these attributes.
- HostAssociatedDetails symbols are used by OpenMP for symbols with
  special OpenMP attributes inside OpenMP region (e.g variables with
  private attribute), so it is very important to preserve this
  aspect in the DescriptorInquiry, that would otherwise apply on the
  symbol outside of the region.

Differential Revision: https://reviews.llvm.org/D104385
2021-06-17 12:42:08 +02:00
peter klausler 562bfe1274 [flang] Complain about more cases of calls to insufficiently defined procedures
When a function is called in a specification expression, it must be
sufficiently defined, and cannot be a recursive call (10.1.11(5)).
The best fix for this is to change the contract for the procedure
characterization infrastructure to catch and report such errors,
and to guarantee that it does emit errors on failed characterizations.
Some call sites were adjusted to avoid cascades.

Differential Revision: https://reviews.llvm.org/D104330
2021-06-16 18:20:59 -07:00
peter klausler fc4f457fcc [flang] Fix ARM/POWER test failure (folding20.f90)
Recent code for folding MINVAL() didn't allow for architectures
whose C/C++ char type is unsigned, so the value of the maximum
Fortran character was incorrect.  This was caught by the
folding20.f90 test.  The fix is to avoid numeric_limits<> and
use hard values for max signed integers of various character kinds.

Pushing into llvm-project/main to restore ARM/POWER buildbots.
2021-06-16 16:41:08 -07:00
peter klausler fdf33771fe [flang] Implement runtime for IALL & IANY
We had IPARITY (xor-reduction) but I missed IALL (and)
and IANY (or).

Differential Revision: https://reviews.llvm.org/D104339
2021-06-16 14:54:36 -07:00
peter klausler c375ec8613 [flang] Use a "double-double" accumulator in SUM
Use a "double-double" accumulator, a/k/a Kahan summation,
in the SUM intrinsic in the runtime for real & complex.
This seems to be the best-recommended technique for reducing
error, as opposed to the initial implementation of SUM's
distinct accumulators for positive and negative items.

Differential Revision: https://reviews.llvm.org/D104338
2021-06-16 14:29:39 -07:00
peter klausler 47f18af55f [flang] Fold MAXVAL & MINVAL
Implement constant folding for the reduction transformational
intrinsic functions MAXVAL and MINVAL.

In anticipation of more folding work to follow, with (I hope)
some common infrastructure, these two have been implemented in a
new header file.

Differential Revision: https://reviews.llvm.org/D104337
2021-06-16 14:06:34 -07:00
Andrzej Warzynski 46446e398b [flang][driver] Add missing `! REQUIRES` LIT directive
The test added in https://reviews.llvm.org/D104305 will only work with
the new driver and should be marked as such.

Sending this without a review as it's fairly straightforward and fixes
test failures for developers that don't want to build the new driver.
2021-06-16 21:00:13 +00:00
peter klausler ec3049c79b [flang] Cope with errors with array constructors
When a program attempts to put something like a subprogram
into an array constructor, emit an error rather than crashing.

Differential Revision: https://reviews.llvm.org/D104336
2021-06-16 13:44:20 -07:00
peter klausler e5813a683a [flang] Fix crashes on calls to non-procedures
When a procedure reference is attempted to an entity that just
isn't a procedure, say so.

Differential Revision: https://reviews.llvm.org/D104329
2021-06-16 12:48:54 -07:00
peter klausler 3061334e0d [flang] Don't crash on some bogus expressions
Recover more gracefully from user errors in expressions.

Differential Revision: https://reviews.llvm.org/D104326
2021-06-16 12:26:39 -07:00
peter klausler 8ba9ee46e4 [flang] Correct the subscripts used for arguments to character intrinsics
When chasing down another unrelated bug, I noticed that the
implementations of various character intrinsic functions assume
that the lower bounds of (some of) their arguments were 1.
This isn't necessarily the case, so I've cleaned them up, tweaked
the unit tests to exercise the fix, and regularized the allocation
pattern used for results to use SetBounds() before Allocate() rather
than the old original Descriptor::Allocate() wrapper around
CFI_allocate().

Since there were few other remaining uses of the old original
Descriptor::Allocate() wrapper, I also converted them to the
new one and deleted the old one.

Differential Revision: https://reviews.llvm.org/D104325
2021-06-16 10:26:25 -07:00
Diana Picus 0ad051b5fc [flang] Check there's no dependency on C++ libs. NFC
Add a test to make sure the flang runtime doesn't pull in the C++
runtime libraries.

This is achieved by adding a C file that calls some functions from the
runtime (currently only CpuTime, but we should probably add anything
complicated enough, e.g. IO-related things). We force the C compiler to
use -std=c90 to make sure it's really in C mode (we don't really care
which version of the standard, this one is probably more widely
available). We only enable this test if CMAKE_C_COMPILER is set to
something (which is probably always true in practice).

This is a recommit of 7ddbf26, with 2 fixes:
* Replace C++ comments with C comments
* Only enable the test if libFortranRuntime.a exists (this might not be
the case if e.g. BUILD_SHARED_LIBS=On)

Differential Revision: https://reviews.llvm.org/D104290
2021-06-16 11:38:25 +00:00
Diana Picus dfa0f3ee0e Revert "[flang] Check there's no dependency on C++ libs"
This reverts commit 7ddbf26339.

This doesn't work if we're not building libFortranRuntime.a. I'll
recommit with a fix.
2021-06-16 11:09:08 +00:00
Diana Picus 10ae933b0b [flang] Fixup 7ddbf26339
Replace C++ comments with C-style comments (not sure why my C compiler
doesn't complain about this).
2021-06-16 09:43:07 +00:00
Diana Picus 45cd405dc0 [flang] Add clang-tidy check for braces around if
Flang diverges from the llvm coding style in that it requires braces
around the bodies of if/while/etc statements, even when the body is
a single statement.

This commit adds the readability-braces-around-statements check to
flang's clang-tidy config file. Hopefully the premerge bots will pick it
up and report violations in Phabricator.

We also explicitly disable the check in the directories corresponding to
the Lower and Optimizer libraries, which rely heavily on mlir and llvm
and therefore follow their coding style. Likewise for the tools
directory.

We also fix any outstanding violations in the runtime and in
lib/Semantics.

Differential Revision: https://reviews.llvm.org/D104100
2021-06-16 09:13:53 +00:00
Diana Picus 7ddbf26339 [flang] Check there's no dependency on C++ libs
Add a test to make sure the flang runtime doesn't pull in the C++
runtime libraries.

This is achieved by adding a C file that calls some functions from the
runtime (currently only CpuTime, but we should probably add anything
complicated enough, e.g. IO-related things). We force the C compiler to
use -std=c90 to make sure it's really in C mode (we don't really care
which version of the standard, this one is probably more widely
available). We only enable this test if CMAKE_C_COMPILER is set to
something (which is probably always true in practice).

Differential Revision: https://reviews.llvm.org/D104290
2021-06-16 08:23:43 +00:00
Andrzej Warzynski 062644bb39 [flang][nfc] Move `external-hello-world` to flang/examples
As `external-hello-world` is not really a test, I am moving it from
`flang/unittest/Runtime` to `flang/examples` (it makes a lot of sense as
an example). I've not modified the source code (apart from adjusting the
include paths).

Differential Revision: https://reviews.llvm.org/D104320
2021-06-16 08:00:50 +00:00
Andrzej Warzynski a6be6e31f1 [flang][driver] Add `-fdebug-dump-all`
The new option will run the semantic checks and then dump the parse tree
and all the symbols. This is equivalent to running the driver twice,
once with `-fdebug-dump-parse-tree` and then with
the `-fdebug-dump-symbols` action flag.

Currently we wouldn't be able to achieve the same by simply running:
```
flang-new -fc1 -fdebug-dump-parse-tree -fdebug-dump-symbols <input-file>
```
That's because the new driver will only run one frontend action per
invocation (both of the flags used here are action flags). Diverging
from this design would lead to costly compromises and it's best avoided.

We may want to consider re-designing our debugging actions (and action
options) in the future so that there's more code re-use. For now, I'm
focusing on making sure that we support all the major cases requested by
our users.

Differential Revision: https://reviews.llvm.org/D104305
2021-06-16 07:54:27 +00:00
Peter Steinfeld bda1f2936e [flang] Add semantic check for the RANDOM_SEED intrinsic
I added the only check that wasn't already tested along with tests for
many valid and invalid arguments.

Differential Revision: https://reviews.llvm.org/D104318
2021-06-15 21:27:54 -07:00
Isaac Perry 80ea006ef9 [flang] [openmp] Add Fortran specific semantic check 4 for OpenMP Allocate directive.
This patch adds the 4th Fortran specific semantic check for the OpenMP
allocate directive: "If a list item has the SAVE attribute, is a common
block name, or is declared in the scope of a module, then only predefined
memory allocator parameters can be used in the allocator clause".

Code in this patch was based on code from https://reviews.llvm.org/D93549/new/.

Differential Revision: https://reviews.llvm.org/D102400
2021-06-15 16:04:04 +01:00
Asher Mancinelli c58cf692f4 [flang] Move buffer runtime test to GTest
Move buffer unit test from Runtime directory to RuntimeGtest
directory and use GTest. Test coverage is only maintained.

Differential Revision: https://reviews.llvm.org/D102335
Reviewed By: awarzynski, klausler
2021-06-14 10:13:32 -07:00
Peter Steinfeld b88fa0e39f [flang] Fix compilation problem with rename of "MemRefDataFlow"
Revision https://reviews.llvm.org/D104190 renamed MemRefDataFlow -> AffineScalarReplacement.  After this rename, mlir failed to build.  With this change, all of clang, mlir, and flang build and test correctly.

Differential Revision: https://reviews.llvm.org/D104223
2021-06-14 07:01:11 -07:00
Diana Picus 166192eb78 [flang] Add POSIX implementation for CPU_TIME
Add an implementation for CPU_TIME using the POSIX function
clock_gettime. I think on most POSIX systems this will be included for
free via <ctime>, which corresponds to "time.h" (YMMV, we can fix the
code if the need arises).

Detecting that clock_gettime is available is tricky. For instance, commit
827407a86a used the following incantation in f18-parse-demo.cpp:

  #if _POSIX_C_SOURCE >= 199309L && _POSIX_TIMERS > 0 && _POSIX_CPUTIME && \
    defined CLOCK_PROCESS_CPUTIME_ID

This doesn't work on my AArch64 Ubuntu system, which provides
clock_gettime but doesn't define _POSIX_TIMERS. Since finding the right
combination of macros requires infinite time, patience and access to
sundry POSIX systems, we should probably try a different approach.

This patch attempts to use SFINAE instead of the preprocessor to choose
an implementation for CPU_TIME. We define a helper function template
which helps us check if clock_gettime is available (and has the
interface we expect). I hope the comments explain it well enough.

This approach has the advantage that it keeps the detection of
clock_gettime close to the code that uses it. An alternative would be to
use CMake to check for the symbol (I personally haven't used this before
so I don't know if there are any quirks).

Differential Revision: https://reviews.llvm.org/D104020
2021-06-14 09:41:11 +00:00
Diana Picus 57e85622bb [flang] Add initial implementation for CPU_TIME
Add an implementation for CPU_TIME based on std::clock(), which should
be available on all the platforms that we support.

Also add a test that's basically just a sanity check to make sure we
return positive values and that the value returned at the start of some
amount of work is larger than the one returned after the end.

Differential Revision: https://reviews.llvm.org/D104019
2021-06-14 07:48:09 +00:00
Michael Kruse dbc262968f [Flang][test] Fix Windows buildbot.
Commit 1b241b9b40 /
patch https://reviews.llvm.org/D104130 introduced an new test which
calls a UNIX shell script. Add
REQUIRES: shell
to not run it on Windows.
2021-06-11 23:25:33 -05:00
Peter Steinfeld 1b241b9b40 [flang] Handle multiple USE statements for the same module
It's possible to have several USE statements for the same module that
have different mixes of rename clauses and ONLY clauses.  The presence
of a rename cause has the effect of hiding a previously associated name,
and the presence of an ONLY clause forces the name to be visible even in
the presence of a rename.

I fixed this by keeping track of the names that appear on rename and ONLY
clauses.  Then, when processing the USE association of a name, I check to see
if it previously appeared in a rename clause and not in a USE clause.  If so, I
remove its USE associated symbol.  Also, when USE associating all of the names
in a module, I do not USE associate names that have appeared in rename clauses.

I also added a test.

Differential Revision: https://reviews.llvm.org/D104130
2021-06-11 12:27:19 -07:00
Michael Kruse 7836d058c7 [Flang] Compile fix after D99459.
Fix Flang build after addition of a new OpenMP clauses for a Clang
patch (D99459). Flang is using TableGen to generation the declaration
of clause checks and the new clause was missing a definiton.
2021-06-10 21:01:09 -05:00
Zachary Selk a0bd24453b [flang] Fixed simple typo in runtime code
Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D104034
2021-06-10 11:14:25 -06:00
Michael Kruse 0112f6ac71 [Flang][Runtime][tests] Escape regex special character.
The second argument of `ASSERT_DEATH` describes a regular expression, in
which parentheses have special meaning. Matches of literal parentheses
need to be escaped.

Fixes failure of InvalidFormatFailure.ParenMismatch and
InvalidFormatFailure.ParenMismatch when gtest is compiled with MSVC's
regex implementation.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D104011
2021-06-10 11:30:23 -05:00
Michael Kruse 58c3f20bbf [flang][windows] Run regression tests under Windows. NFCI.
Allow the lit test suite to run under Windows. This encompasses the following changes:

 * Define `lit_tools_dir` for flang's test configuration
 * Replace `(<command> || true)` idiom with `not <command>`
 * Add `REQUIRES: shell` on tests that invoke a shell script

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D89368
2021-06-10 05:13:44 -05:00
Diana Picus 35b0ddab0e [flang] Define the API for CPU_TIME
CPU_TIME takes a single real scalar INTENT(OUT) argument. We can
therefore return a double and let lowering handle casting that to the
precision used for the default real kind.

Differential Revision: https://reviews.llvm.org/D103805
2021-06-09 08:20:58 +00:00
David Blaikie 49454ebc56 .clang-tidy: Disable misc-no-recursion in general/across the monorepo 2021-06-08 08:31:33 -07:00
David Blaikie c5d56fec50 NFC: .clang-tidy: Inherit configs from parents to improve maintainability
In the interests of disabling misc-no-recursion across LLVM (this seems
like a stylistic choice that is not consistent with LLVM's
style/development approach) this NFC preliminary change adjusts all the
.clang-tidy files to inherit from their parents as much as possible.

This change specifically preserves all the quirks of the current configs
in order to make it easier to review as NFC.

I validatad the change is NFC as follows:

for X in `cat ../files.txt`;
do
  mkdir -p ../tmp/$(dirname $X)
  touch $(dirname $X)/blaikie.cpp
  clang-tidy -dump-config $(dirname $X)/blaikie.cpp > ../tmp/$(dirname $X)/after
  rm $(dirname $X)/blaikie.cpp
done

(similarly for the "before" state, without this patch applied)

for X in `cat ../files.txt`;
do
  echo $X
  diff \
    ../tmp/$(dirname $X)/before \
    <(cat ../tmp/$(dirname $X)/after \
      | sed -e "s/,readability-identifier-naming\(.*\),-readability-identifier-naming/\1/" \
      | sed -e "s/,-llvm-include-order\(.*\),llvm-include-order/\1/" \
      | sed -e "s/,-misc-no-recursion\(.*\),misc-no-recursion/\1/" \
      | sed -e "s/,-clang-diagnostic-\*\(.*\),clang-diagnostic-\*/\1/")
done

(using sed to strip some add/remove pairs to reduce the diff and make it easier to read)

The resulting report is:
  .clang-tidy
  clang/.clang-tidy
  2c2
  < Checks:          'clang-diagnostic-*,clang-analyzer-*,-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-readability-identifier-naming,-misc-no-recursion'
  ---
  > Checks:          'clang-diagnostic-*,clang-analyzer-*,-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion'
  compiler-rt/.clang-tidy
  2c2
  < Checks:          'clang-diagnostic-*,clang-analyzer-*,-*,clang-diagnostic-*,llvm-*,-llvm-header-guard,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes'
  ---
  > Checks:          'clang-diagnostic-*,clang-analyzer-*,-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-llvm-header-guard'
  flang/.clang-tidy
  2c2
  < Checks:          'clang-diagnostic-*,clang-analyzer-*,-*,llvm-*,-llvm-include-order,misc-*,-misc-no-recursion,-misc-unused-parameters,-misc-non-private-member-variables-in-classes'
  ---
  > Checks:          'clang-diagnostic-*,clang-analyzer-*,-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-llvm-include-order,-misc-no-recursion'
  flang/include/flang/Lower/.clang-tidy
  flang/include/flang/Optimizer/.clang-tidy
  flang/lib/Lower/.clang-tidy
  flang/lib/Optimizer/.clang-tidy
  lld/.clang-tidy
  lldb/.clang-tidy
  llvm/tools/split-file/.clang-tidy
  mlir/.clang-tidy

The `clang/.clang-tidy` change is a no-op, disabling an option that was never enabled.
The compiler-rt and flang changes are no-op reorderings of the same flags.

(side note, the .clang-tidy file in parallel-libs is broken and crashes
clang-tidy because it uses "lowerCase" as the style instead of "lower_case" -
so I'll deal with that separately)

Differential Revision: https://reviews.llvm.org/D103842
2021-06-08 08:25:59 -07:00
Stuart Ellis e1da3297d2 [flang][driver] Add support for the "-init-only" option
Adding the `-init-only` option and corresponding frontend action to
generate a diagnostic.

`-init-only` vs `-test-io`:
`-init-only` ignores the input (it never calls the prescanner)
`-test-io` is similar to `-init-only`, but does read and print the input
without calling the prescanner.

This patch also adds a Driver test to check this action.

Reviewed By: awarzynski, AMDChirag

Differential Revision: https://reviews.llvm.org/D102849
2021-06-07 15:40:26 +01:00
Peter Steinfeld 2b795ec682 [flang] Check for undefined derived types
It's possible to specify refer to an undefined derived type as the type of a
component of another derived type and then never define the type of the
component.  We were not detecting this situation.  To fix this, I
changed the value of isForwardReferenced_ in the symbol's
DerivedTypeDetails and checked for it when performing other derived type
checks.

I also had to record the fact that error messages were previously
emitted for the same problem in some cases so that I could avoid
duplicate messages.

I also added a test.

Differential Revision: https://reviews.llvm.org/D103714
2021-06-04 14:33:52 -07:00
Arnamoy Bhattacharyya f2622a150a [flang][OpenMP] Add semantic check to allow only loop iteration variables in a `linear` clause within `distribute` construct.
Implement the following semantic check:

"A list item may not appear in a linear clause, unless it is the loop iteration variable."

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D100224
2021-06-04 17:32:25 -04:00
peter klausler dfecbcae0d [flang] CheckConformance: tristate-ify result
To ensure that errors are emitted by CheckConformance and
its callers in all situations, it's necessary for the returned result
of that function to distinguish between three possible
outcomes: the arrays are known to conform at compilation time,
the arrays are known to not conform (and a message has been
produced), and an indeterminate result in which is not possible
to determine conformance.  So convert CheckConformance's
result into an optional<bool>, and convert its confusing
Boolean flag arguments into a bit-set of named flags too.

Differential Revision: https://reviews.llvm.org/D103654
2021-06-04 11:19:14 -07:00
Andrzej Warzynski 2b4c9bc4d4 [flang][driver] Add checks for missing option arguments
With this patch, the following invocation of the frontend driver will
return an error:
```
flang-new -fc1 input-file.f90 -o
```
Similar logic applies to other options that require arguments.

Similar checks are already available in the compiler driver, flang-new
(that's implemented in clangDriver).

Differential Revision: https://reviews.llvm.org/D103554
2021-06-04 15:16:56 +01:00
Andrzej Warzynski 20bd2142d4 [flang][driver] Add support for `-module-suffix`
This option is supported in `f18`, but not yet available in `flang-new`.
It is required in order to call `flang-new` from the `flang` bash
script.

Differential Revision: https://reviews.llvm.org/D103613
2021-06-04 13:58:04 +01:00
Jean Perier 1971960a6f [flang] Generate type info symbols outside of derived type scopes
A recent change was made in https://reviews.llvm.org/D101482 to cope
with kind parameters. It had the side effect of generating some type
info symbols inside derived type scopes. Derived type scope symbols
are meant for components, and other/later compilation phases might
choke when finding compiler generated symbols there that are not
components.

This patch preserves the fix from D101482 while still generating the
symbols outside of derived type scopes.

Differential Revision: https://reviews.llvm.org/D103621
2021-06-04 14:30:29 +02:00
Diana Picus 263a89c9b7 [flang] Change capitalization for Adjustl/r
Rename the definitions of the character runtime functions Adjustl and
Adjustr (used to be AdjustL and AdjustR respectively).

Also add unit tests (and move some of the helpers to the top of the
file, since they're now used in more than one place).

Differential Revision: https://reviews.llvm.org/D103392
2021-06-04 08:34:53 +00:00
peter klausler 69a82d7c08 [flang] Fix spurious "already declared" errors for interfaces
When a subroutine or function symbol is defined in an INTERFACE
block, it's okay if a symbol of the same name appears in a
scope between the global scope and the scope of the INTERFACE.

Differential Revision: https://reviews.llvm.org/D103580
2021-06-03 15:30:43 -07:00
peter klausler 73c3530f5e [flang] Catch errors in function calls instead of crashing
Add some missing error messages, and permit the appearance
of EntityDetails symbols in dummy argument type characterization.

Differential Revision: https://reviews.llvm.org/D103576
2021-06-03 15:20:39 -07:00
peter klausler c1a024053d [flang] Emit error about missing interface when needed
When a procedure pointer with no interface is called by a
function reference, complain about the lack.

Differential Revision: https://reviews.llvm.org/D103573
2021-06-03 15:19:54 -07:00
peter klausler e712a92b8f [flang] Fix crash on structure constructor as selector
In something like "ASSOCIATE(X=>T(1))", the "T(1)" is parsed
as a Variable because it looks like a function reference or
array reference; if it turns out to be a structure constructor,
which is something we can't know until we're able to attempt
generic interface resolution in semantics, the parse tree needs
to be fixed up by replacing the Variable with an Expr.

The compiler could already do this for putative function references
encapsulated as Exprs, so this patch moves some code around and
adds parser::Selector to the overloads of expression analysis.

Differential Revision: https://reviews.llvm.org/D103572
2021-06-03 14:48:30 -07:00
peter klausler ac9641753b [flang] Support known constant lengths in DynamicType
The constexpr-capable class evaluate::DynamicType represented
CHARACTER length only with a nullable pointer into the declared
parameters of types in the symbol table, which works fine for
anything with a declaration but turns out to not suffice to
describe the results of the ACHAR() and CHAR() intrinsic
functions.  So extend DynamicType to also accommodate known
constant CHARACTER lengths, too; use them for ACHAR & CHAR;
clean up several use sites and fix regressions found in test.

Differential Revision: https://reviews.llvm.org/D103571
2021-06-03 14:25:22 -07:00
peter klausler f8f7002828 [flang] Catch procedure pointer interface error
A procedure pointer is allowed to name a specific intrinsic function
from F'2018 table 16.2 as its interface, but not other intrinsic
procedures.  Catch this error, and thereby also fix a crash resulting
from a failure later in compilation from failed characteristics;
while here, also catch the similar error with initializers.

Differential Revision: https://reviews.llvm.org/D103570
2021-06-03 14:02:42 -07:00
peter klausler e7a53f1e04 [flang] Accept BOZ in array constructors w/o types
As a benign extension common to other Fortran compilers,
accept BOZ literals in array constructors w/o explicit
types, treating them as integers.

Differential Revision: https://reviews.llvm.org/D103569
2021-06-03 13:37:11 -07:00
peter klausler 6fa5353a56 [flang] Fix folding of CMPLX
The code for folding calls to the intrinsic function CMPLX was
incorrectly dependent on the number of arguments to distinguish its
two cases (conversion from one kind of complex to another, and
composition of a complex value from real & imaginary parts).
This was wrong since the optional KIND= argument has already been
taken into account by intrinsic processing; instead, the type of
the first argument should decide the issue.

Differential Revision: https://reviews.llvm.org/D103568
2021-06-03 13:11:31 -07:00
peter klausler 1dff8637b1 [flang] Fix crashes due to failure to find a subprogram
In error recovery situations, the mappings from source locations
to scopes were failing in a way that tripped some asserts.
Specifically, FindPureProcedureContaining() wasn't coping well
when starting at the global scope.  (And since the global scope
no longer has a source range, clean up the Semantics constructor
to avoid confusion.)

Differential Revision: https://reviews.llvm.org/D103567
2021-06-03 12:45:43 -07:00