From c72c2367617c79a126e40734523c82f7b9c8aadf Mon Sep 17 00:00:00 2001 From: "Chen, Sheng S" Date: Mon, 12 May 2025 10:16:30 +0800 Subject: [PATCH] [SYCLomatic] Fix the internal error when the auto deduce failed. Signed-off-by: Chen, Sheng S --- clang/include/clang/AST/ASTContext.h | 5 +++++ .../dpct/internal_error/auto_deduce_fail_in_kernel.cu | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 clang/test/dpct/internal_error/auto_deduce_fail_in_kernel.cu diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 13caee30ae59..aa2f3cad275d 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -2511,7 +2511,12 @@ class ASTContext : public RefCountedBase { CharUnits getTypeSizeInChars(const Type *T) const; std::optional getTypeSizeInCharsIfKnown(QualType Ty) const { +#ifdef SYCLomatic_CUSTOMIZATION + if (Ty->isIncompleteType() || Ty->isDependentType() || + Ty->isUndeducedType()) +#else if (Ty->isIncompleteType() || Ty->isDependentType()) +#endif return std::nullopt; return getTypeSizeInChars(Ty); } diff --git a/clang/test/dpct/internal_error/auto_deduce_fail_in_kernel.cu b/clang/test/dpct/internal_error/auto_deduce_fail_in_kernel.cu new file mode 100644 index 000000000000..28db774d0b27 --- /dev/null +++ b/clang/test/dpct/internal_error/auto_deduce_fail_in_kernel.cu @@ -0,0 +1,11 @@ +// RUN: dpct --out-root %T %s --cuda-include-path="%cuda-path/include" > %T/auto_deduce_output.txt 2>&1 || true +// RUN: grep "dpct internal error" %T/auto_deduce_output.txt | wc -l > %T/wc_auto_deduce_output.txt || true +// RUN: FileCheck %s --match-full-lines --input-file %T/wc_auto_deduce_output.txt +// RUN: rm -rf %T + +// CHECK: 0 + +__device__ void test_auto() { + + auto tid = get_tid(); +}