rsmith added inline comments. ================ Comment at: clang/lib/Parse/ParsePragma.cpp:172 @@ +171,3 @@ + PragmaForceCUDAHostDeviceStartHandler(Sema &Actions) + : PragmaHandler("force_cuda_host_device_begin"), Actions(Actions) {} + void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, ---------------- I think this would be more consistent with the behavior of our other pragmas as two tokens rather than one:
#pragma clang force_cuda_host_device begin #pragma clang force_cuda_host_device end It's also more extensible this way, for instance if we later want some kind of push/pop mechanism to temporarily leave force-host-device mode. (Maybe we could even use `#pragma clang cuda force_host_device begin`, but I'm fine with either choice there.) ================ Comment at: clang/lib/Sema/SemaCUDA.cpp:466-472 @@ +465,9 @@ + + if (ForceCUDAHostDeviceDepth > 0) { + if (!NewD->hasAttr<CUDAHostAttr>()) + NewD->addAttr(CUDAHostAttr::CreateImplicit(Context)); + if (!NewD->hasAttr<CUDADeviceAttr>()) + NewD->addAttr(CUDADeviceAttr::CreateImplicit(Context)); + return; + } + ---------------- Does this apply within template instantiations? I'm concerned about two cases: 1) Eagerly-instantiated declarations whose instantiation is triggered within one of these scopes: ``` template<typename T> auto f() { return T(); } template<typename T> struct X { void f(); }; #pragma clang force_cuda_host_device_begin int n = f<int>(); // is f<int> implicitly __host__ __device__? X<int> x; // is X<int>::f implicitly __host__ __device__? #pragma clang force_cuda_host_device_end ``` 2) Template instantiation at the end of the TU if we have a begin but no end: ``` template<typename T> int f() { return T(); } #pragma clang force_cuda_host_device_begin int n = f<int>(); // is f<int> implicitly __host__ __device__? ``` I would expect the answer in each case to be that the function is __host__. Even if these do work correctly already, please add some testcases. https://reviews.llvm.org/D24975 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits