diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -4299,6 +4299,7 @@ /// Check if the specified type is the CUDA device builtin surface type. bool Type::isCUDADeviceBuiltinSurfaceType() const { + assert(!isDependentType()); if (const auto *RT = getAs()) return RT->getDecl()->hasAttr(); return false; @@ -4306,6 +4307,7 @@ /// Check if the specified type is the CUDA device builtin texture type. bool Type::isCUDADeviceBuiltinTextureType() const { + assert(!isDependentType()); if (const auto *RT = getAs()) return RT->getDecl()->hasAttr(); return false; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -362,8 +362,9 @@ auto Target = IdentifyCUDATarget(FD); if (FD && Target != CFT_Host) { const auto *VD = dyn_cast(D); - if (VD && VD->hasGlobalStorage() && !VD->hasAttr() && - !VD->hasAttr() && !VD->hasAttr() && + if (VD && VD->hasGlobalStorage() && !VD->getType()->isDependentType() && + !VD->hasAttr() && !VD->hasAttr() && + !VD->hasAttr() && !VD->getType()->isCUDADeviceBuiltinSurfaceType() && !VD->getType()->isCUDADeviceBuiltinTextureType() && !VD->isConstexpr() && !VD->getType().isConstQualified())