Add diagnostic checks for missing mandatory arguments.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
You need to run clang-format on flang/lib/Evaluate/intrinsics.cpp. Pre-commit is failing now.
Thanks for looking into the bugs here and submitting this patch for review. I hope that my comments make sense; please let me know if they don't.
flang/lib/Evaluate/intrinsics.cpp | ||
---|---|---|
1470 | In the bits of f18 that run before lowering, we consistently use a more modern and strict coding convention that includes braced initialization on declarations for increased safety against inadvertent conversions. | |
1473 | I think that you probably need to test arguments.size() before indexing into it. I'd recommend using .at(0) rather than [0] for extra saftely. It may be the case that you can elicit these error messages from the general-case code by allowing MAX and MIN to use a two-element actualForDummy array to track A1= and A2= rather than bypassing its use altogether, which is what I think happens now. | |
1558 | Consider putting this code after the loop, before the call to your new function; it confused me a bit on the first reading by being in the loop here. It might also need to handle the case of zero actual arguments, which it won't see here. | |
1636 | Is this special case code for isMaxMin really needed here? Maybe the original general case code can be made to work. | |
flang/test/Semantics/call23.f90 | ||
29 | maybe also test A0=, A03= (which would sort before A1), and ABAD=. |
flang/lib/Evaluate/intrinsics.cpp | ||
---|---|---|
1465 | As far as I understand CheckMaxMinArgument, it is a per-argument check. For the case of max/min, we need to determine the position of the actual argument in the argument list. If keyword argument is used in the first two actual argument, we need to check all the other arguments till the end (i.e. for the worse case scenario - max(..., a1=x, a2=y)) in order to determine if any error situation is encountered. In my opinion, it is better to wait till all the keyword is collected and then do the check. | |
1473 | Yes, I need to check arguments.size(). I will change [0] to .at(0).
As far as I understand, the existing code makes max/min a special case because it can have infinite arguments. The logic for the general case relies on the keywords but max/min does not have in the table if the argument list is larger than 3. I may have missed something here. | |
1558 | Sure. I will move it after the loop for clarity. However, the zero actual arguments case is a different issue (https://github.com/llvm/llvm-project/issues/58921). | |
1639 | Will use dummy[1].keyword instead. | |
1641 | Will use dummy[0].keyword instead. | |
1644 | Will use dummy[0].keyword and dummy[1].keyword instead. | |
flang/test/Semantics/call23.f90 | ||
29 | Good point. I will add the variations. |
@klausler May I know what the debian build error is? I am trying to find a debian system to reproduce the problem.
@kkwli0, you may follow the links above in the Diff Detail section. There was a build failure for Diff 2, so if you go to https://reviews.llvm.org/D137742?id=475168, you will see x64 debian failed - and if you click on it you will get to https://buildkite.com/llvm-project/premerge-checks/builds/121619#01847714-2b4a-422f-8da3-f3efd92756d5
Long story short, there was a clang-format issue in flang/lib/Evaluate/intrinsics.cpp and Valentin pointed this out in https://reviews.llvm.org/D137742#3918803 :)
@clementval Do you have more comments? I don't know how to change from the "Needs Review" to "Accepted" state. Thanks.
Why not combining this with CheckMaxMinArgument?