Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -2082,7 +2082,7 @@ // Check that D is not yet in DiagnosedConflictingDefinitions is required // to make sure that we issue an error only once. - if (lookupRepresentativeDecl(MangledName, OtherGD) && + if (D && lookupRepresentativeDecl(MangledName, OtherGD) && (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) && (OtherD = dyn_cast(OtherGD.getDecl())) && OtherD->hasInit() && @@ -2301,7 +2301,7 @@ unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D, unsigned AddrSpace) { - if (LangOpts.CUDA && LangOpts.CUDAIsDevice) { + if (D && LangOpts.CUDA && LangOpts.CUDAIsDevice) { if (D->hasAttr()) AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant); else if (D->hasAttr())