@@ -321,7 +321,7 @@ void SemaCUDA::EraseUnwantedMatches(
321
321
if (Matches.size () <= 1 )
322
322
return ;
323
323
324
- using Pair = std::pair<DeclAccessPair, FunctionDecl*>;
324
+ using Pair = std::pair<DeclAccessPair, FunctionDecl *>;
325
325
326
326
// Gets the CUDA function preference for a call from Caller to Match.
327
327
auto GetCFP = [&](const Pair &Match) {
@@ -504,7 +504,6 @@ bool SemaCUDA::inferTargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
504
504
}
505
505
}
506
506
507
-
508
507
// If no target was inferred, mark this member as __host__ __device__;
509
508
// it's the least restrictive option that can be invoked from any target.
510
509
bool NeedsH = true , NeedsD = true ;
@@ -679,16 +678,22 @@ void SemaCUDA::checkAllowedInitializer(VarDecl *VD) {
679
678
FD && FD->isDependentContext ())
680
679
return ;
681
680
681
+ bool IsSharedVar = VD->hasAttr <CUDASharedAttr>();
682
+ bool IsDeviceOrConstantVar =
683
+ !IsSharedVar &&
684
+ (VD->hasAttr <CUDADeviceAttr>() || VD->hasAttr <CUDAConstantAttr>());
685
+ if ((IsSharedVar || IsDeviceOrConstantVar) &&
686
+ VD->getType ().getQualifiers ().getAddressSpace () != LangAS::Default) {
687
+ Diag (VD->getLocation (), diag::err_cuda_address_space_gpuvar);
688
+ VD->setInvalidDecl ();
689
+ return ;
690
+ }
682
691
// Do not check dependent variables since the ctor/dtor/initializer are not
683
692
// determined. Do it after instantiation.
684
693
if (VD->isInvalidDecl () || !VD->hasInit () || !VD->hasGlobalStorage () ||
685
694
IsDependentVar (VD))
686
695
return ;
687
696
const Expr *Init = VD->getInit ();
688
- bool IsSharedVar = VD->hasAttr <CUDASharedAttr>();
689
- bool IsDeviceOrConstantVar =
690
- !IsSharedVar &&
691
- (VD->hasAttr <CUDADeviceAttr>() || VD->hasAttr <CUDAConstantAttr>());
692
697
if (IsDeviceOrConstantVar || IsSharedVar) {
693
698
if (HasAllowedCUDADeviceStaticInitializer (
694
699
*this , VD, IsSharedVar ? CICK_Shared : CICK_DeviceOrConstant))
0 commit comments