Skip to content

Commit 3466fc9

Browse files
committed
Make sure warning is present before assignment
1 parent 4e4e5d8 commit 3466fc9

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

flang/lib/Common/Fortran.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
138138
(*y == CUDADataAttr::Managed || *y == CUDADataAttr::Unified ||
139139
*y == CUDADataAttr::Shared)) ||
140140
(!y && (isCudaUnified || isCudaManaged))) {
141-
if (y && *y == CUDADataAttr::Shared) {
141+
if (y && *y == CUDADataAttr::Shared && warning) {
142142
*warning = "SHARED attribute ignored"s;
143143
}
144144
return true;

flang/lib/Evaluate/characteristics.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,6 @@ bool DistinguishUtils::Distinguishable(
17621762
bool DistinguishUtils::Distinguishable(
17631763
const DummyDataObject &x, const DummyDataObject &y) const {
17641764
using Attr = DummyDataObject::Attr;
1765-
std::optional<std::string> warning;
17661765
if (Distinguishable(x.type, y.type, x.ignoreTKR | y.ignoreTKR)) {
17671766
return true;
17681767
} else if (x.attrs.test(Attr::Allocatable) && y.attrs.test(Attr::Pointer) &&
@@ -1772,7 +1771,7 @@ bool DistinguishUtils::Distinguishable(
17721771
x.intent != common::Intent::In) {
17731772
return true;
17741773
} else if (!common::AreCompatibleCUDADataAttrs(x.cudaDataAttr, y.cudaDataAttr,
1775-
x.ignoreTKR | y.ignoreTKR, &warning,
1774+
x.ignoreTKR | y.ignoreTKR, nullptr,
17761775
/*allowUnifiedMatchingRule=*/false)) {
17771776
return true;
17781777
} else if (features_.IsEnabled(

0 commit comments

Comments
 (0)