Add semantic check for occurrence of multiple list items in aligned clause for simd directive. Also adds a test case
Details
Diff Detail
Event Timeline
Thanks @arnamoy10 for this patch.
Did you try the other approach that I mentioned using FindClause? I am guessing FindClause will only return a single clause and hence cannot be used directly. Would adding another function (if a similar one does not exist) which returns multiple clauses (using equal_range) work? This way we do not need to use the clauseList.
Exactly. FindClause did not work for me for the reason mentioned above. I had this idea of using equal_range as well (and a new function). Thanks for confirming. Let me work on that and submit an updated patch.
Updated code through the use of newly introduced FindClauseMult() function, which returns an iterator from the multimap, in case where multiple occurrence of a clause happens within a directive.
flang/lib/Semantics/check-omp-structure.cpp | ||
---|---|---|
610 | I think alignedVars{} is preferred. | |
619 | Would it be better use the symbol corresponding to the name? And use a SymbolSet to store the symbols associated with the variables? @tskeith In general what is preferable, comparing names of variables or symbols associated with them? | |
630 | Can this go into the condition portion of the for loop from which it is breaking? |
flang/lib/Semantics/check-omp-structure.cpp | ||
---|---|---|
610 | The default initialization for a set is empty, so just std::set<std::string> alignedVars; is best. | |
619 | You can have different symbols with the same name, so these aren't equivalent. In this case, I agree that SymbolSet seems appropriate. Even when you want a set of names, it's better to save them as parser::CharBlock rather than making new std::string objects. | |
625 | Why not just return here to simplify the logic? |
flang/lib/Semantics/check-omp-structure.cpp | ||
---|---|---|
619 | Thanks @tskeith. @arnamoy10 if you switch to using symbols, then add a test which has a private clause in between the align clauses. align(x) private(x) align(x) |
Addressing reviewers' comments:
- Use of SymbolSet instead of searching by variable name.
- Change function name to FindClauses()
- One more test scenario to check aligned(a) private(a) aligned(a)
- Simplified loop logic in case of Sema error
LGTM. Please address all lint/clang-format errors. Please wait for @tskeith or @clementval to approve.
Thanks for your work here. Hope you can take this forward in the flow.
flang/lib/Semantics/check-directive-structure.h | ||
---|---|---|
208 | Nit: Naming the type here is probably better. Is there an issue? | |
flang/lib/Semantics/check-omp-structure.cpp | ||
12 | Nit: Please fix the ordering warning above. | |
flang/test/Semantics/omp-simd-aligned.f90 | ||
8 | Nit: can you add a test with one more variable? |
LGTM. Please address small comments.
flang/lib/Semantics/check-directive-structure.h | ||
---|---|---|
208 | +1 to @kiranchandramohan comment. | |
flang/lib/Semantics/check-omp-structure.cpp | ||
619 | Please fix the clang-format warning. | |
628 | Remove blank line. |
flang/lib/Semantics/check-directive-structure.h | ||
---|---|---|
208 | Do you mean replace auto? |
flang/lib/Semantics/check-directive-structure.h | ||
---|---|---|
208 | Yes. |
flang/test/Semantics/omp-simd-aligned.f90 | ||
---|---|---|
8 | @kiranchandramohan We already have a test with two variables at Line 28, do we need one more? |
- Using type info in the FindClauses() function instead of auto
- (hopefully) clang-formatted
flang/test/Semantics/omp-simd-aligned.f90 | ||
---|---|---|
8 | I meant an error with two variables repeating. |
Is the name following a convention? What about FindClauses instead?