1 // RUN
: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std
=CL1.0
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 -fsyntax-only -cl-std
=CL1.1 -DNOPEDANTIC
4 // RUN
: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std
=CL1.2 -DFP64
6 // Test with a target not supporting fp64.
7 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
8 // RUN
: %clang_cc1 -cl-std
=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
9 // RUN
: %clang_cc1 -cl-std
=clc
++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
11 // Test with some extensions enabled or disabled by cmd-line args
13 // Target does not support fp64 and fp16 - override it
14 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext
=+cl_khr_fp64
,+cl_khr_fp16
16 // Disable or enable all extensions
17 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext
=-all -DNOFP64 -DNOFP16
18 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext
=+all
19 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext
=+all
,-cl_khr_fp64 -DNOFP64
20 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext
=-all
,+cl_khr_fp64 -DNOFP16
21 // RUN
: %clang_cc1 -cl-std
=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext
=-all -DNOFP64 -DNOFP16
22 // RUN
: %clang_cc1 -cl-std
=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext
=+all -DFP64
23 // RUN
: %clang_cc1 -cl-std
=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext
=+all
,-__opencl_c_fp64
,-cl_khr_fp64 -DNOFP64
24 // RUN
: %clang_cc1 -cl-std
=clc
++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext
=-all -DNOFP64 -DNOFP16
25 // RUN
: %clang_cc1 -cl-std
=clc
++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext
=+all -DFP64
26 // RUN
: %clang_cc1 -cl-std
=clc
++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext
=+all
,-__opencl_c_fp64
,-cl_khr_fp64 -DNOFP64
29 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext
=-cl_khr_fp64 -cl-ext
=+cl_khr_fp64
30 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext
=-cl_khr_fp64
,+cl_khr_fp64
31 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -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
32 // 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
33 // RUN
: %clang_cc1 -cl-std
=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext
=-__opencl_c_fp64
,-cl_khr_fp64 -cl-ext
=+__opencl_c_fp64
,+cl_khr_fp64 -DFP64
34 // RUN
: %clang_cc1 -cl-std
=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext
=-__opencl_c_fp64
,+__opencl_c_fp64
,+cl_khr_fp64 -DFP64
35 // RUN
: %clang_cc1 -cl-std
=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext
=-__opencl_c_fp64
,-cl_khr_fp64 -DNOFP64
36 // RUN
: %clang_cc1 -cl-std
=clc
++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext
=-__opencl_c_fp64
,-cl_khr_fp64 -cl-ext
=+__opencl_c_fp64
,+cl_khr_fp64 -DFP64
37 // RUN
: %clang_cc1 -cl-std
=clc
++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext
=-__opencl_c_fp64
,+__opencl_c_fp64
,+cl_khr_fp64 -DFP64
38 // RUN
: %clang_cc1 -cl-std
=clc
++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext
=-__opencl_c_fp64
,-cl_khr_fp64 -DNOFP64
40 // Test with -finclude-default-header
, which includes opencl-c.h. opencl-c.h
41 // disables all extensions by default
, but supported core extensions for a
42 // particular OpenCL version must be re-enabled
(for example
, cl_khr_fp64 is
43 // enabled by default with -cl-std
=CL2.0
).
45 // RUN
: %clang_cc1 %s -triple amdgcn-unknown-unknown -verify -pedantic -fsyntax-only -cl-std
=CL2.0 -finclude-default-header
46 // RUN
: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std
=clc
++1.0
49 // expected-no-diagnostics
53 // expected-no-diagnostics
56 #if __OPENCL_CPP_VERSION__
== 100
57 // expected-no-diagnostics
60 #if
(defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__
< 120)
63 // expected-error
@-
2 {{type
'double
' requires cl_khr_fp64 support
}}
64 #elif
!defined
(NOPEDANTIC)
65 // expected-warning
@-
4{{Clang permits use of type
'double
' regardless pragma if
'cl_khr_fp64
' is supported
}}
69 // expected-error
@-
2 {{type
'double
' requires cl_khr_fp64 support
}}
70 #elif
!defined
(NOPEDANTIC)
71 // expected-warning
@-
4{{Clang permits use of type
'double
' regardless pragma if
'cl_khr_fp64
' is supported
}}
73 // FIXME
: this diagnostic depends on the extension pragma in the earlier versions.
74 // There is no indication that this behavior is expected.
75 (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
81 return __builtin_isnan
(x);
84 int isfinite
(float x
) {
85 return __builtin_isfinite
(x);
89 #pragma OPENCL EXTENSION cl_khr_fp64
: enable
91 // expected-warning
@-
2{{unsupported OpenCL extension
'cl_khr_fp64
' - ignoring
}}
94 #pragma OPENCL EXTENSION cl_khr_fp16
: enable
96 // expected-warning
@-
2{{unsupported OpenCL extension
'cl_khr_fp16
' - ignoring
}}
102 #if
((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__
>= 300) || __OPENCL_CPP_VERSION__
>= 202100)
103 // expected-error
@-
3{{use of type
'double
' requires cl_khr_fp64 and __opencl_c_fp64 support
}}
105 // expected-error
@-
5{{use of type
'double
' requires cl_khr_fp64 support
}}
109 typedef double double4 __attribute__
((ext_vector_type(4)));
110 double4 d4
= {0.0f
, 2.0f
, 3.0f
, 1.0f
};
112 #if
((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__
>= 300) || __OPENCL_CPP_VERSION__
>= 202100)
113 // expected-error
@-
4 {{use of type
'double
' requires cl_khr_fp64 and __opencl_c_fp64 support
}}
115 // expected-error
@-
6 {{use of type
'double
' requires cl_khr_fp64 support
}}
121 #if
((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__
>= 300) || __OPENCL_CPP_VERSION__
>= 202100)
122 // expected-warning
@-
3{{double precision constant requires cl_khr_fp64 and __opencl_c_fp64
, casting to single precision
}}
124 // expected-warning
@-
5{{double precision constant requires cl_khr_fp64
, casting to single precision
}}
129 #pragma OPENCL EXTENSION cl_khr_fp64
: disable
131 // expected-warning
@-
2{{unsupported OpenCL extension
'cl_khr_fp64
' - ignoring
}}
134 #if
(defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__
< 120)
138 // expected-error
@-
2 {{type
'double
' requires cl_khr_fp64 support
}}
139 #elif
!defined
(NOPEDANTIC)
140 // expected-warning
@-
4 {{Clang permits use of type
'double
' regardless pragma if
'cl_khr_fp64
' is supported
}}