llvm-project/flang/lib/Parser
Peter Steinfeld 5a9497d689 [flang] Allow large and erroneous ac-implied-do's
We sometimes unroll an ac-implied-do of an array constructor into a flat list
of values.  We then re-analyze the array constructor that contains the
resulting list of expressions.  Such a list may or may not contain errors.

But when processing an array constructor with an unrolled ac-implied-do, the
compiler was building an expression to represent the extent of the resulting
array constructor containing the list of values.  The number of operands
in this extent expression was based on the number of elements in the
unrolled list of values.  For very large lists, this created an
expression so large that it could not be evaluated by the compiler
without overflowing the stack.

I fixed this by continuously folding the extent expression as each operand is
added to it.  I added the test .../flang/test/Semantics/array-constr-big.f90
that will cause the compiler to seg fault without this change.

Also, when the unrolled ac-implied-do expression contains errors, we were
repeating the same error message referencing the same source line for every
instance of the erroneous expression in the unrolled list.  This potentially
resulted in a very long list of messages for a single error in the source code.

I fixed this by comparing the message being emitted to the previously emitted
message.  If they are the same, I do not emit the message.  This change is also
tested by the new test array-constr-big.f90.

Several of the existing tests had duplicate error messages for the same source
line, and this change caused differences in their output.  So I adjusted the
tests to match the new message emitting behavior.

Differential Revision: https://reviews.llvm.org/D102210
2021-05-11 10:04:18 -07:00
..
CMakeLists.txt [flang][driver] Add options for unparsing 2021-02-16 09:32:51 +00:00
Fortran-parsers.cpp [flang] Fix parsing of WRITE(I+J) with more accurate look-ahead 2021-02-01 09:07:40 -08:00
basic-parsers.h [flang][MSVC] Use list<Message> rather than forward_list<> in Messages 2020-11-11 16:38:38 -08:00
char-block.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
char-buffer.cpp [flang][MSVC] Use list<Message> rather than forward_list<> in Messages 2020-11-11 16:38:38 -08:00
char-set.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
characters.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
debug-parser.cpp [flang] Support multiple CookedSource instances 2020-09-02 10:34:23 -07:00
debug-parser.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
executable-parsers.cpp [flang][openacc] Handle optional end directive in combined construct 2020-08-13 14:05:00 -04:00
expr-parsers.cpp [flang][msvc] Add explicit function template argument to applyLamda. NFC. 2020-09-22 14:22:08 -05:00
expr-parsers.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
instrumented-parser.cpp [flang] Support multiple CookedSource instances 2020-09-02 10:34:23 -07:00
io-parsers.cpp [flang] Fix parsing of WRITE(I+J) with more accurate look-ahead 2021-02-01 09:07:40 -08:00
message.cpp [flang] Allow large and erroneous ac-implied-do's 2021-05-11 10:04:18 -07:00
misc-parsers.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
openacc-parsers.cpp [openacc] Use TableGen enum for default clause value 2020-12-21 15:07:27 -05:00
openmp-parsers.cpp [flang][directive] Get rid of flangClassValue in TableGen 2021-01-19 10:28:46 -05:00
parse-tree.cpp [flang] Improve initializer semantics, esp. for component default values 2020-12-07 14:40:41 -08:00
parsing.cpp [flang] Order Symbols by source provenance 2021-03-16 15:25:15 -07:00
preprocessor.cpp [flang] Don't perform macro replacement unless *.F, *.F90, &c. 2021-02-11 11:25:41 -08:00
preprocessor.h [flang] Don't perform macro replacement unless *.F, *.F90, &c. 2021-02-11 11:25:41 -08:00
prescan.cpp [flang] Search for #include "file" in right directory (take 2) 2021-01-27 15:41:29 -08:00
prescan.h [flang] Rework preprocessing of stringification 2020-09-18 10:45:57 -07:00
program-parsers.cpp [flang] Clean up TODO comments and fix one (DATA constant ambiguity) 2020-12-15 13:36:07 -08:00
provenance.cpp [flang] Fix crash from -DMACRO= with empty replacement 2021-04-24 10:56:25 -07:00
source.cpp [flang] Search for #include "file" in right directory (take 2) 2021-01-27 15:41:29 -08:00
stmt-parser.h [flang][openacc] OpenACC 3.0 parser 2020-07-14 14:29:40 -04:00
token-parsers.h [flang][msvc] Split class declaration and constexpr variable definition. NFC. 2020-08-22 15:05:48 -05:00
token-sequence.cpp Do not dereference an array out of bound just to take its address 2020-09-21 12:08:30 +02:00
token-sequence.h [flang] Improve error handling for bad characters in source 2020-08-25 11:42:19 -07:00
tools.cpp [flang] Support for image selectors 2020-07-08 07:31:54 -07:00
type-parser-implementation.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
type-parsers.h [flang]Add Parser Support for Allocate Directive 2020-12-10 16:21:19 +00:00
unparse.cpp [flang] Save AllocateObject and PointerObject analyzed expression 2021-03-16 10:27:45 +01:00
user-state.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00