Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -6287,6 +6287,8 @@ void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) { if (Decl->getType().hasAddressSpace()) return; + if (Decl->getType().isDependentType()) + return; if (VarDecl *Var = dyn_cast(Decl)) { QualType Type = Var->getType(); if (Type->isSamplerT() || Type->isVoidType()) Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp =================================================================== --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3630,7 +3630,7 @@ // in every situation. // This approach was copied from TemplateDeclInstantiator::VisitVarDecl if (SemaRef.getLangOpts().OpenCL) - SemaRef.deduceOpenCLAddressSpace(Var); + SemaRef.deduceOpenCLAddressSpace(Var); // Substitute the nested name specifier, if any. if (SubstQualifier(D, Var)) @@ -4815,7 +4815,7 @@ // reliable in every situation. // This approach was copied from TemplateDeclInstantiator::VisitVarDecl if (getLangOpts().OpenCL) - deduceOpenCLAddressSpace(VarSpec); + deduceOpenCLAddressSpace(VarSpec); return VarSpec; }