|
16 | 16 | #include "flang/Common/idioms.h"
|
17 | 17 | #include "flang/Common/indirection.h"
|
18 | 18 | #include "flang/Common/visit.h"
|
19 |
| -#include "flang/Evaluate/shape.h" |
20 | 19 | #include "flang/Evaluate/tools.h"
|
21 | 20 | #include "flang/Evaluate/type.h"
|
22 | 21 | #include "flang/Parser/char-block.h"
|
@@ -4151,21 +4150,26 @@ void OmpStructureChecker::CheckArraySection(
|
4151 | 4150 | // Detect this by looking for array accesses on character variables which are
|
4152 | 4151 | // not arrays.
|
4153 | 4152 | bool isSubstring{false};
|
4154 |
| - evaluate::ExpressionAnalyzer ea{context_}; |
4155 |
| - if (MaybeExpr expr = ea.Analyze(arrayElement.base)) { |
4156 |
| - std::optional<evaluate::Shape> shape = evaluate::GetShape(expr); |
4157 |
| - // Not an array: rank 0 |
4158 |
| - if (shape && shape->size() == 0) { |
4159 |
| - if (std::optional<evaluate::DynamicType> type = expr->GetType()) { |
4160 |
| - if (type->category() == evaluate::TypeCategory::Character) { |
4161 |
| - // Substrings are explicitly denied by the standard [6.0:163:9-11]. |
4162 |
| - // This is supported as an extension. This restriction was added in |
4163 |
| - // OpenMP 5.2. |
4164 |
| - isSubstring = true; |
4165 |
| - context_.Say(GetContext().clauseSource, |
4166 |
| - "The use of substrings in OpenMP argument lists has been disallowed since OpenMP 5.2."_port_en_US); |
4167 |
| - } else { |
4168 |
| - llvm_unreachable("Array indexing on a variable that isn't an array"); |
| 4153 | + // Cannot analyze a base of an assumed-size array on its own. If we know |
| 4154 | + // this is an array (assumed-size or not) we can ignore it, since we're |
| 4155 | + // looking for strings. |
| 4156 | + if (!IsAssumedSizeArray(*name.symbol)) { |
| 4157 | + evaluate::ExpressionAnalyzer ea{context_}; |
| 4158 | + if (MaybeExpr expr = ea.Analyze(arrayElement.base)) { |
| 4159 | + if (expr->Rank() == 0) { |
| 4160 | + // Not an array: rank 0 |
| 4161 | + if (std::optional<evaluate::DynamicType> type = expr->GetType()) { |
| 4162 | + if (type->category() == evaluate::TypeCategory::Character) { |
| 4163 | + // Substrings are explicitly denied by the standard [6.0:163:9-11]. |
| 4164 | + // This is supported as an extension. This restriction was added in |
| 4165 | + // OpenMP 5.2. |
| 4166 | + isSubstring = true; |
| 4167 | + context_.Say(GetContext().clauseSource, |
| 4168 | + "The use of substrings in OpenMP argument lists has been disallowed since OpenMP 5.2."_port_en_US); |
| 4169 | + } else { |
| 4170 | + llvm_unreachable( |
| 4171 | + "Array indexing on a variable that isn't an array"); |
| 4172 | + } |
4169 | 4173 | }
|
4170 | 4174 | }
|
4171 | 4175 | }
|
|
0 commit comments