-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang] Escape '%' in %VAL/%REF messages #94331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-flang-semantics Author: Leandro Lupori (luporl) Changesflang/test/Semantics/call40.f90 was failing on Darwin: When messages.Say() is called with more arguments than just the Note that no conversion happens when there is only a fixed text Full diff: https://github.com/llvm/llvm-project/pull/94331.diff 1 Files Affected:
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 97c685fa0b2c0..41a2d50b136b8 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() &&
|
Why is this failing only on Darwin? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other instances in the code, please grep for them and change them too.
Changing the other instances of %VAL/%REF result in The problem is that format specifications, such as |
Ok, understood. Please merge soon; I think that this bug also affects Windows CI (when it doesn't run out of memory). |
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.