[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / clang / test / SemaOpenCL / extensions.cl
blob55dbd1d5eede8a39873e6bba845fa70eca8ac3f2
1 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
2 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
3 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64
5 // Test with a target not supporting fp64.
6 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
8 // Test with some extensions enabled or disabled by cmd-line args
9 //
10 // Target does not support fp64 and fp16 - override it
11 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+cl_khr_fp64,+cl_khr_fp16
13 // Disable or enable all extensions
14 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
15 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all
16 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64
17 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16
19 // Concatenating
20 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64
21 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64,+cl_khr_fp64
22 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64
23 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64
25 // Test with -finclude-default-header, which includes opencl-c.h. opencl-c.h
26 // disables all extensions by default, but supported core extensions for a
27 // particular OpenCL version must be re-enabled (for example, cl_khr_fp64 is
28 // enabled by default with -cl-std=CL2.0).
30 // RUN: %clang_cc1 %s -triple amdgcn-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header
31 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++
33 #ifdef _OPENCL_H_
34 // expected-no-diagnostics
35 #endif
37 #ifdef FP64
38 // expected-no-diagnostics
39 #endif
41 #ifdef __OPENCL_CPP_VERSION__
42 // expected-no-diagnostics
43 #endif
45 #if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120)
46 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
47 double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
48 (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
50 #endif
52 #ifndef _OPENCL_H_
53 int isnan(float x) {
54 return __builtin_isnan(x);
57 int isfinite(float x) {
58 return __builtin_isfinite(x);
60 #endif
62 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
63 #ifdef NOFP64
64 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
65 #endif
67 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
68 #ifdef NOFP16
69 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp16' - ignoring}}
70 #endif
72 void f2(void) {
73 double d;
74 #ifdef NOFP64
75 // expected-error@-2{{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
76 #endif
78 typedef double double4 __attribute__((ext_vector_type(4)));
79 double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f};
80 #ifdef NOFP64
81 // expected-error@-3 {{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
82 // expected-error@-3 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 extension to be enabled}}
83 #endif
85 (void) 1.0;
87 #ifdef NOFP64
88 // expected-warning@-3{{double precision constant requires cl_khr_fp64, casting to single precision}}
89 #endif
92 #pragma OPENCL EXTENSION cl_khr_fp64 : disable
93 #ifdef NOFP64
94 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
95 #endif
97 #if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120)
98 void f3(void) {
99 double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
101 #endif