ABataev added inline comments.
================ Comment at: clang/lib/Sema/SemaOpenMP.cpp:15356 + Expr::EvalResult Result; + if (AE->getIdx()->EvaluateAsInt(Result, SemaRef.getASTContext())) { + if (!Result.Val.getInt().isNullValue()) { ---------------- cchen wrote: > ABataev wrote: > > Need to check that `AE->getIdx()` is not value dependent, otherwise it may > > crash > It seems Clang would catch the error before we do the analysis: > > ``` > orig.cpp:6:24: error: array subscript is not an integer > #pragma omp target map(a[b]) > ^ ~ > orig.cpp:15:3: note: in instantiation of function template specialization > 'gg<int, double>' requested here > gg<int, double>(a, c); > ^ > orig.cpp:8:5: error: array subscript is not an integer > a[b] = 10; > ^ ~ > 2 errors generated. > ``` > > Also, if we still need it, do we also check type dependent? 1. Yes, it will find incorrect expression at the instantiation. But what if you're working with the template? In this case, the expression can be value-dependent. 2. No, no need to check for type-dependence here, a check for value-dependent expression should be enough. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74970/new/ https://reviews.llvm.org/D74970 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits