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
37 lines
1.4 KiB
C++
37 lines
1.4 KiB
C++
//===-------lib/Semantics/check-data.h ------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef FORTRAN_SEMANTICS_CHECK_DATA_H_
|
|
#define FORTRAN_SEMANTICS_CHECK_DATA_H_
|
|
|
|
#include "flang/Parser/parse-tree.h"
|
|
#include "flang/Parser/tools.h"
|
|
#include "flang/Semantics/expression.h"
|
|
#include "flang/Semantics/semantics.h"
|
|
#include "flang/Semantics/tools.h"
|
|
|
|
namespace Fortran::semantics {
|
|
class DataChecker : public virtual BaseChecker {
|
|
public:
|
|
explicit DataChecker(SemanticsContext &context) : exprAnalyzer_{context} {}
|
|
void Leave(const parser::DataStmtRepeat &);
|
|
void Leave(const parser::DataStmtConstant &);
|
|
void Leave(const parser::DataStmtObject &);
|
|
void Enter(const parser::DataImpliedDo &);
|
|
void Leave(const parser::DataImpliedDo &);
|
|
void Leave(const parser::DataIDoObject &);
|
|
|
|
private:
|
|
evaluate::ExpressionAnalyzer exprAnalyzer_;
|
|
template <typename T> void CheckIfConstantSubscript(const T &);
|
|
void CheckSubscript(const parser::SectionSubscript &);
|
|
bool CheckAllSubscriptsInDataRef(const parser::DataRef &, parser::CharBlock);
|
|
};
|
|
} // namespace Fortran::semantics
|
|
#endif // FORTRAN_SEMANTICS_CHECK_DATA_H_
|