forked from OSchip/llvm-project
[flang] Add Symbol::IsArray()
Add and use IsArray for symbols, meaning: it is an object entity with shape. Original-commit: flang-compiler/f18@31c1a37f03 Reviewed-on: https://github.com/flang-compiler/f18/pull/277 Tree-same-pre-rewrite: false
This commit is contained in:
parent
da46e49a01
commit
7c4e86b7e2
|
@ -2358,11 +2358,9 @@ void DeclarationVisitor::CheckAccessibility(
|
|||
void DeclarationVisitor::CheckScalarIntegerType(const parser::Name &name) {
|
||||
if (name.symbol != nullptr) {
|
||||
const Symbol &symbol{*name.symbol};
|
||||
if (const auto *details{symbol.detailsIf<ObjectEntityDetails>()}) {
|
||||
if (details->IsArray()) {
|
||||
Say(name, "Variable '%s' is not scalar"_err_en_US);
|
||||
return;
|
||||
}
|
||||
if (symbol.IsArray()) {
|
||||
Say(name, "Variable '%s' is not scalar"_err_en_US);
|
||||
return;
|
||||
}
|
||||
if (auto *type{symbol.GetType()}) {
|
||||
if (!type->IsNumeric(TypeCategory::Integer)) {
|
||||
|
@ -2536,7 +2534,7 @@ Symbol &DeclarationVisitor::DeclareObjectEntity(
|
|||
SetType(name, *type);
|
||||
}
|
||||
if (!arraySpec().empty()) {
|
||||
if (!details->shape().empty()) {
|
||||
if (details->IsArray()) {
|
||||
Say(name,
|
||||
"The dimensions of '%s' have already been declared"_err_en_US);
|
||||
} else {
|
||||
|
@ -3372,11 +3370,9 @@ void ConstructVisitor::Post(const parser::ConcurrentControl &x) {
|
|||
if (auto *type{prev->GetType()}) {
|
||||
symbol.SetType(*type);
|
||||
}
|
||||
if (const auto *details{prev->detailsIf<ObjectEntityDetails>()}) {
|
||||
if (details->IsArray()) {
|
||||
SayWithDecl(name, *prev, "Index variable '%s' is not scalar"_err_en_US);
|
||||
return;
|
||||
}
|
||||
if (prev->IsArray()) {
|
||||
SayWithDecl(name, *prev, "Index variable '%s' is not scalar"_err_en_US);
|
||||
return;
|
||||
}
|
||||
}
|
||||
CheckScalarIntegerType(name);
|
||||
|
|
|
@ -214,6 +214,11 @@ void Symbol::SetType(const DeclTypeSpec &type) {
|
|||
details_);
|
||||
}
|
||||
|
||||
bool Symbol::IsArray() const {
|
||||
const auto *details{std::get_if<ObjectEntityDetails>(&details_)};
|
||||
return details && details->IsArray();
|
||||
}
|
||||
|
||||
bool Symbol::IsSubprogram() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
|
|
|
@ -452,6 +452,7 @@ public:
|
|||
|
||||
void SetType(const DeclTypeSpec &);
|
||||
|
||||
bool IsArray() const;
|
||||
bool IsSubprogram() const;
|
||||
bool IsSeparateModuleProc() const;
|
||||
bool HasExplicitInterface() const {
|
||||
|
|
Loading…
Reference in New Issue