mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-13 19:32:41 +00:00
c14cf92b5a
Implements part of the legacy "DEC structures" feature from VMS Fortran. STRUCTUREs are processed as if they were derived types with SEQUENCE. DATA-like object entity initialization is supported as well (e.g., INTEGER FOO/666/) since it was used for default component initialization in structures. Anonymous components (named %FILL) are also supported. These features, and UNION/MAP, were already being parsed. An omission in the collection of structure field names in the case of nested structures with entity declarations was fixed in the parser. Structures are supported in modules, but this is mostly for testing purposes. The names of fields in structures accessed via USE association cannot appear with dot notation in client code (at least not yet). DEC structures antedate Fortran 90, so their actual use in applications should not involve modules. This patch does not implement UNION/MAP, since that feature would impose difficulties later in lowering them to MLIR types. In the meantime, if they appear, semantics will issue a "not yet implemented" error message. Differential Revision: https://reviews.llvm.org/D117151
54 lines
1.8 KiB
C++
54 lines
1.8 KiB
C++
//===-- lib/Semantics/data-to-inits.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_DATA_TO_INITS_H_
|
|
#define FORTRAN_SEMANTICS_DATA_TO_INITS_H_
|
|
|
|
#include "flang/Common/default-kinds.h"
|
|
#include "flang/Common/interval.h"
|
|
#include "flang/Evaluate/initial-image.h"
|
|
#include <list>
|
|
#include <map>
|
|
|
|
namespace Fortran::parser {
|
|
struct DataStmtSet;
|
|
struct DataStmtValue;
|
|
}
|
|
namespace Fortran::evaluate {
|
|
class ExpressionAnalyzer;
|
|
}
|
|
namespace Fortran::semantics {
|
|
|
|
class Symbol;
|
|
|
|
struct SymbolDataInitialization {
|
|
using Range = common::Interval<common::ConstantSubscript>;
|
|
explicit SymbolDataInitialization(std::size_t bytes) : image{bytes} {}
|
|
SymbolDataInitialization(SymbolDataInitialization &&) = default;
|
|
evaluate::InitialImage image;
|
|
std::list<Range> initializedRanges;
|
|
};
|
|
|
|
using DataInitializations = std::map<const Symbol *, SymbolDataInitialization>;
|
|
|
|
// Matches DATA statement variables with their values and checks
|
|
// compatibility.
|
|
void AccumulateDataInitializations(DataInitializations &,
|
|
evaluate::ExpressionAnalyzer &, const parser::DataStmtSet &);
|
|
|
|
// For legacy DATA-style initialization extension: integer n(2)/1,2/
|
|
void AccumulateDataInitializations(DataInitializations &,
|
|
evaluate::ExpressionAnalyzer &, const Symbol &,
|
|
const std::list<common::Indirection<parser::DataStmtValue>> &);
|
|
|
|
void ConvertToInitializers(
|
|
DataInitializations &, evaluate::ExpressionAnalyzer &);
|
|
|
|
} // namespace Fortran::semantics
|
|
#endif // FORTRAN_SEMANTICS_DATA_TO_INITS_H_
|