Skip to content

Commit 6ac5047

Browse files
authored
[flang] Escape '%' in %VAL/%REF messages (#94331)
flang/test/Semantics/call40.f90 was failing on Darwin: actual at 27: VAL or REF are not allowed for dummy argument 'a=' that must be passed by means of a descriptor expect at 27: %VAL or %REF are not allowed for dummy argument 'a=' that must be passed by means of a descriptor When messages.Say() is called with more arguments than just the fixed text message, the message is treated as a format string, passed to vsnprintf. Therefore, the '%' chars in it must be escaped. Note that no conversion happens when there is only a fixed text message. Escaping '%' in this case causes "%%" to be outputted. This can be confusing for someone expecting printf-like behavior. Processing these text messages with snprintf could solve this, as a future improvement.
1 parent 335fb94 commit 6ac5047

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flang/lib/Semantics/check-call.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
961961
if ((arg.isPercentRef() || arg.isPercentVal()) &&
962962
dummy.IsPassedByDescriptor(procedure.IsBindC())) {
963963
messages.Say(
964-
"%VAL or %REF are not allowed for %s that must be passed by means of a descriptor"_err_en_US,
964+
"%%VAL or %%REF are not allowed for %s that must be passed by means of a descriptor"_err_en_US,
965965
dummyName);
966966
}
967967
if (arg.isPercentVal() &&

0 commit comments

Comments
 (0)