|
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"
|
@@ -4117,21 +4116,26 @@ void OmpStructureChecker::CheckArraySection(
|
4117 | 4116 | // Detect this by looking for array accesses on character variables which are
|
4118 | 4117 | // not arrays.
|
4119 | 4118 | bool isSubstring{false};
|
4120 |
| - evaluate::ExpressionAnalyzer ea{context_}; |
4121 |
| - if (MaybeExpr expr = ea.Analyze(arrayElement.base)) { |
4122 |
| - std::optional<evaluate::Shape> shape = evaluate::GetShape(expr); |
4123 |
| - // Not an array: rank 0 |
4124 |
| - if (shape && shape->size() == 0) { |
4125 |
| - if (std::optional<evaluate::DynamicType> type = expr->GetType()) { |
4126 |
| - if (type->category() == evaluate::TypeCategory::Character) { |
4127 |
| - // Substrings are explicitly denied by the standard [6.0:163:9-11]. |
4128 |
| - // This is supported as an extension. This restriction was added in |
4129 |
| - // OpenMP 5.2. |
4130 |
| - isSubstring = true; |
4131 |
| - context_.Say(GetContext().clauseSource, |
4132 |
| - "The use of substrings in OpenMP argument lists has been disallowed since OpenMP 5.2."_port_en_US); |
4133 |
| - } else { |
4134 |
| - llvm_unreachable("Array indexing on a variable that isn't an array"); |
| 4119 | + // Cannot analyze a base of an assumed-size array on its own. If we know |
| 4120 | + // this is an array (assumed-size or not) we can ignore it, since we're |
| 4121 | + // looking for strings. |
| 4122 | + if (!IsAssumedSizeArray(*name.symbol)) { |
| 4123 | + evaluate::ExpressionAnalyzer ea{context_}; |
| 4124 | + if (MaybeExpr expr = ea.Analyze(arrayElement.base)) { |
| 4125 | + if (expr->Rank() == 0) { |
| 4126 | + // Not an array: rank 0 |
| 4127 | + if (std::optional<evaluate::DynamicType> type = expr->GetType()) { |
| 4128 | + if (type->category() == evaluate::TypeCategory::Character) { |
| 4129 | + // Substrings are explicitly denied by the standard [6.0:163:9-11]. |
| 4130 | + // This is supported as an extension. This restriction was added in |
| 4131 | + // OpenMP 5.2. |
| 4132 | + isSubstring = true; |
| 4133 | + context_.Say(GetContext().clauseSource, |
| 4134 | + "The use of substrings in OpenMP argument lists has been disallowed since OpenMP 5.2."_port_en_US); |
| 4135 | + } else { |
| 4136 | + llvm_unreachable( |
| 4137 | + "Array indexing on a variable that isn't an array"); |
| 4138 | + } |
4135 | 4139 | }
|
4136 | 4140 | }
|
4137 | 4141 | }
|
|
0 commit comments