Index: include/clang/Basic/Attr.td =================================================================== --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -239,6 +239,7 @@ def Borland : LangOpt<"Borland">; def CUDA : LangOpt<"CUDA">; def COnly : LangOpt<"CPlusPlus", 1>; +def OpenCL : LangOpt<"OpenCL">; // Defines targets for target-specific attributes. The list of strings should // specify architectures for which the target applies, based off the ArchType @@ -697,6 +698,13 @@ let Documentation = [OpenCLAddressSpaceGenericDocs]; } +def OpenCLNoSVM : Attr { + let Spellings = [GNU<"nosvm">]; + let Subjects = SubjectList<[Var]>; + let Documentation = [OpenCLNoSVMDocs]; + let LangOpts = [OpenCL]; +} + def Deprecated : InheritableAttr { let Spellings = [GCC<"deprecated">, Declspec<"deprecated">, CXX11<"","deprecated", 201309>]; Index: include/clang/Basic/AttrDocs.td =================================================================== --- include/clang/Basic/AttrDocs.td +++ include/clang/Basic/AttrDocs.td @@ -1648,6 +1648,17 @@ }]; } +def OpenCLNoSVMDocs : Documentation { + let Category = DocCatVariable; + let Content = [{ +OpenCL 2.0 supports the optional ``__attribute__((nosvm))`` qualifier for +pointer variable. It informs the compiler that the pointer does not refer +to a shared virtual memory region. See OpenCL v2.0 s6.7.2 for details. + +Since it is not widely used and has been removed from OpenCL 2.1, it is ignored +by Clang. + }]; +} def NullabilityDocs : DocumentationCategory<"Nullability Attributes"> { let Content = [{ Whether a particular pointer may be "null" is an important concern when working with pointers in the C family of languages. The various nullability attributes indicate whether a particular pointer can be null or not, which makes APIs more expressive and can help static analysis tools identify bugs involving null pointers. Clang supports several kinds of nullability attributes: the ``nonnull`` and ``returns_nonnull`` attributes indicate which function or method parameters and result types can never be null, while nullability type qualifiers indicate which pointer types can be null (``_Nullable``) or cannot be null (``_Nonnull``). Index: test/SemaOpenCL/nosvm.cl =================================================================== --- /dev/null +++ test/SemaOpenCL/nosvm.cl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -verify -x c -D NOT_OPENCL %s + +#ifndef NOT_OPENCL +kernel void f(__attribute__((nosvm)) global int* a); +__attribute__((nosvm)) void g(); // expected-warning {{'nosvm' attribute only applies to variables}} + +#else +void f(__attribute__((nosvm)) int* a); // expected-warning {{'nosvm' attribute ignored}} +#endif