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
let Documentation = [OpenCLAddressSpaceGenericDocs];
}
+def OpenCLNoSVM : Attr {
+ let Spellings = [GNU<"nosvm">];
+ let Subjects = SubjectList<[Var]>;
+ let Documentation = [OpenCLNoSVMDocs];
+ let LangOpts = [OpenCL];
+ let ASTNode = 0;
+}
+
def Deprecated : InheritableAttr {
let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
CXX11<"","deprecated", 201309>];
}];
}
+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``).
def err_attribute_requires_positive_integer : Error<
"%0 attribute requires a positive integral compile time constant expression">;
def err_attribute_requires_opencl_version : Error<
- "%0 attribute requires OpenCL version %1 or above">;
+ "%0 attribute requires OpenCL version %1%select{| or above}2">;
def warn_unsupported_target_attribute
: Warning<"Ignoring unsupported '%0' in the target attribute string">,
InGroup<IgnoredAttributes>;
"pointer to type %0 is invalid in OpenCL">;
def err_opencl_type_can_only_be_used_as_function_parameter : Error <
"type %0 can only be used as a function parameter in OpenCL">;
+def warn_opencl_attr_deprecated_ignored : Warning <
+ "%0 attribute is deprecated and ignored in OpenCL version %1">,
+ InGroup<IgnoredAttributes>;
// OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
def err_opencl_builtin_pipe_first_arg : Error<
D->addAttr(Internal);
}
+static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+ if (S.LangOpts.OpenCLVersion != 200)
+ S.Diag(Attr.getLoc(), diag::err_attribute_requires_opencl_version)
+ << Attr.getName() << "2.0" << 0;
+ else
+ S.Diag(Attr.getLoc(), diag::warn_opencl_attr_deprecated_ignored)
+ << Attr.getName() << "2.0";
+}
+
/// Handles semantic checking for features that are common to all attributes,
/// such as checking whether a parameter was properly specified, or the correct
/// number of arguments were passed, etc.
case AttributeList::AT_SwiftIndirectResult:
handleParameterABIAttr(S, D, Attr, ParameterABI::SwiftIndirectResult);
break;
+ case AttributeList::AT_OpenCLNoSVM:
+ handleOpenCLNoSVMAttr(S, D, Attr);
+ break;
case AttributeList::AT_InternalLinkage:
handleInternalLinkageAttr(S, D, Attr);
break;
if (S.getLangOpts().OpenCLVersion < 200) {
S.Diag(A.getLoc(), diag::err_attribute_requires_opencl_version)
- << A.getName() << "2.0";
+ << A.getName() << "2.0" << 1;
return nullptr;
}
--- /dev/null
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -cl-std=CL2.0 -D CL20 %s
+// RUN: %clang_cc1 -verify -x c -D NOCL %s
+
+#ifndef NOCL
+kernel void f(__attribute__((nosvm)) global int* a);
+#ifndef CL20
+// expected-error@-2 {{'nosvm' attribute requires OpenCL version 2.0}}
+#else
+// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in OpenCL version 2.0}}
+#endif
+
+__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