[flang-rt] Fix warnings

This patch fixes:

  flang-rt/include/flang-rt/runtime/emit-encoded.h:67:27: error:
  implicit conversion from 'const char16_t' to 'char32_t' may change
  the meaning of the represented code unit
  [-Werror,-Wcharacter-conversion]

  flang-rt/lib/runtime/edit-input.cpp:1114:18: error: implicit
  conversion from 'char32_t' to 'char16_t' may lose precision and
  change the meaning of the represented code unit
  [-Werror,-Wcharacter-conversion]

  flang-rt/lib/runtime/edit-input.cpp:1133:18: error: implicit
  conversion from 'char32_t' to 'char16_t' may lose precision and
  change the meaning of the represented code unit
  [-Werror,-Wcharacter-conversion]

  flang-rt/lib/runtime/edit-input.cpp:1033:14: error: implicit
  conversion from 'char32_t' to 'char16_t' may lose precision and
  change the meaning of the represented code unit
  [-Werror,-Wcharacter-conversion]

  flang-rt/lib/runtime/edit-input.cpp:986:14: error: implicit
  conversion from 'char32_t' to 'char16_t' may lose precision and
  change the meaning of the represented code unit
  [-Werror,-Wcharacter-conversion]
This commit is contained in:
Kazu Hirata
2025-05-15 17:46:00 -07:00
parent 8d3a70770f
commit 56aa935bec
2 changed files with 5 additions and 5 deletions

View File

@@ -64,7 +64,7 @@ RT_API_ATTRS bool EmitEncoded(
} else {
// CHARACTER kind conversion for internal output
while (chars-- > 0) {
char32_t buffer = *data++;
char32_t buffer = static_cast<char32_t>(*data++);
char *p{reinterpret_cast<char *>(&buffer)};
if constexpr (!isHostLittleEndian) {
p += sizeof(buffer) - internalKind;

View File

@@ -983,7 +983,7 @@ static RT_API_ATTRS bool EditDelimitedCharacterInput(
}
}
if (length > 0) {
*x++ = *ch;
*x++ = static_cast<CHAR>(*ch);
--length;
}
}
@@ -1030,7 +1030,7 @@ static RT_API_ATTRS bool EditListDirectedCharacterInput(
break;
}
if (length > 0) {
*x++ = *ch;
*x++ = static_cast<CHAR>(*ch);
--length;
} else if (edit.IsNamelist()) {
// GNU compatibility
@@ -1111,7 +1111,7 @@ RT_API_ATTRS bool EditCharacterInput(IoStatementState &io, const DataEdit &edit,
(sizeof *x == 2 && *ucs > 0xffff)) {
*x++ = '?';
} else {
*x++ = *ucs;
*x++ = static_cast<CHAR>(*ucs);
}
--lengthChars;
} else if (chunkBytes == 0) {
@@ -1130,7 +1130,7 @@ RT_API_ATTRS bool EditCharacterInput(IoStatementState &io, const DataEdit &edit,
(sizeof *x == 2 && buffer > 0xffff)) {
*x++ = '?';
} else {
*x++ = buffer;
*x++ = static_cast<CHAR>(buffer);
}
--lengthChars;
}