Skip to content

Commit f654e02

Browse files
authored
[SYCLomatic] Fix internal error when the template argument decls are empty (#2844)
Signed-off-by: Chen, Sheng S <sheng.s.chen@intel.com>
1 parent 9f8c46d commit f654e02

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

clang/lib/DPCT/RuleInfra/ExprAnalysis.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,8 @@ void ExprAnalysis::analyzeExpr(const UnaryExprOrTypeTraitExpr *UETT) {
870870
}
871871

872872
inline void ExprAnalysis::analyzeExpr(const UnresolvedLookupExpr *ULE) {
873-
RefString = ULE->decls().begin().getDecl()->getQualifiedNameAsString();
873+
if (ULE != nullptr && !ULE->decls().empty())
874+
RefString = ULE->decls().begin().getDecl()->getQualifiedNameAsString();
874875
}
875876

876877
void ExprAnalysis::analyzeExpr(const ExplicitCastExpr *Cast) {

clang/test/dpct/internal_error/auto_deduce_fail_in_kernel.cu

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,23 @@ __device__ void test_auto() {
99

1010
auto tid = get_tid();
1111
}
12+
13+
namespace test {
14+
15+
enum norm_type_ {
16+
NORM1,
17+
NORM2,
18+
ABS_MAX,
19+
ABS_MIN
20+
};
21+
22+
template <typename T, bool fixed, int nColor, int... N>
23+
double norm(const GaugeField &u, int d, norm_type_ type, IntList<nColor, N...>) {
24+
double norm_ = 0.0;
25+
if constexpr (sizeof...(N) > 0) {
26+
norm<T, fixed>(u, d, type, IntList<N...>());
27+
}
28+
return norm_;
29+
}
30+
31+
} // namespace test

0 commit comments

Comments
 (0)