[flang-commits] [flang] [Flang] Extra check for character length in pointer allocation (PR #95145)
via flang-commits
flang-commits at lists.llvm.org
Tue Jun 11 09:59:11 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 5275aed4d0195e5db214e6638d29b0b702d16b3c f4dbdd542220815954166d54ef2c948e3e04638c -- flang/lib/Semantics/check-allocate.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/flang/lib/Semantics/check-allocate.cpp b/flang/lib/Semantics/check-allocate.cpp
index 4473434582..389d3afa66 100644
--- a/flang/lib/Semantics/check-allocate.cpp
+++ b/flang/lib/Semantics/check-allocate.cpp
@@ -418,16 +418,16 @@ static bool HaveCompatibleTypeParameters(
}
}
-static bool HaveCompatibleLengths(
- const DeclTypeSpec &type1, const DeclTypeSpec &type2, const Symbol &symbol) {
+static bool HaveCompatibleLengths(const DeclTypeSpec &type1,
+ const DeclTypeSpec &type2, const Symbol &symbol) {
if (type1.category() == DeclTypeSpec::Character &&
type2.category() == DeclTypeSpec::Character) {
auto v1{
evaluate::ToInt64(type1.characterTypeSpec().length().GetExplicit())};
auto v2{
evaluate::ToInt64(type2.characterTypeSpec().length().GetExplicit())};
- if (!type1.characterTypeSpec().length().isDeferred() && IsPointer(symbol)
- && !v1 && v2)
+ if (!type1.characterTypeSpec().length().isDeferred() && IsPointer(symbol) &&
+ !v1 && v2)
return false;
return !v1 || !v2 || *v1 == *v2;
} else {
@@ -510,7 +510,8 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) {
"Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec"_err_en_US);
return false;
}
- if (!HaveCompatibleLengths(*type_, *allocateInfo_.typeSpec, *ultimate_)) { // C934
+ if (!HaveCompatibleLengths(
+ *type_, *allocateInfo_.typeSpec, *ultimate_)) { // C934
context.Say(name_.source,
"Character length of allocatable object in ALLOCATE must be the same as the type-spec"_err_en_US);
return false;
``````````
</details>
https://github.com/llvm/llvm-project/pull/95145
More information about the flang-commits
mailing list