[flang-commits] [flang] [flang][cuda] Avoid false positive on multi device symbol with components (PR #192513)

Zhen Wang via flang-commits flang-commits at lists.llvm.org
Thu Apr 16 12:13:18 PDT 2026


================
@@ -1130,6 +1130,43 @@ template semantics::UnorderedSymbolSet CollectCudaSymbols(
 template semantics::UnorderedSymbolSet CollectCudaSymbols(
     const Expr<SubscriptInteger> &);
 
+std::vector<SymbolVector> GetSymbolVectors(const Expr<SomeType> &expr) {
+  SymbolVector symbols{GetSymbolVector(expr)};
+  std::reverse(symbols.begin(), symbols.end());
+
+  std::vector<SymbolVector> symbolVectors;
+
+  SymbolVector crtSymbols;
+  for (const Symbol &sym : symbols) {
+    bool isComponent{sym.owner().IsDerivedType()};
+    if (isComponent) {
+      crtSymbols.push_back(sym);
----------------
wangzpgi wrote:

Maybe we can hoist out this `crtSymbols.push_back(sym);` since it's used in both if and else branches?

https://github.com/llvm/llvm-project/pull/192513


More information about the flang-commits mailing list