[flang-commits] [flang] 6ac5047 - [flang] Escape '%' in %VAL/%REF messages (#94331)
via flang-commits
flang-commits at lists.llvm.org
Tue Jun 4 09:12:02 PDT 2024
Author: Leandro Lupori
Date: 2024-06-04T18:11:58+02:00
New Revision: 6ac5047aa6bf12644e38afb188bd8d821a181ba5
URL: https://github.com/llvm/llvm-project/commit/6ac5047aa6bf12644e38afb188bd8d821a181ba5
DIFF: https://github.com/llvm/llvm-project/commit/6ac5047aa6bf12644e38afb188bd8d821a181ba5.diff
LOG: [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.
Added:
Modified:
flang/lib/Semantics/check-call.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 51369f4b55a65..72576942e62cb 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -961,7 +961,7 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
if ((arg.isPercentRef() || arg.isPercentVal()) &&
dummy.IsPassedByDescriptor(procedure.IsBindC())) {
messages.Say(
- "%VAL or %REF are not allowed for %s that must be passed by means of a descriptor"_err_en_US,
+ "%%VAL or %%REF are not allowed for %s that must be passed by means of a descriptor"_err_en_US,
dummyName);
}
if (arg.isPercentVal() &&
More information about the flang-commits
mailing list