blob: c27f3397cd79ea2f7e3f6ccbca59fcb8b54b3e97 [file] [log] [blame]
Yaxun Liu39cf40f2016-05-16 17:06:34 +00001// 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
Neil Hickey88c0fac2016-12-13 16:22:50 +00003// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64
Yaxun Liu39cf40f2016-05-16 17:06:34 +00004
5// Test with a target not supporting fp64.
Alexey Bader0ea07532016-11-01 15:50:52 +00006// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
7
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
12//
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
18//
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
24
Neil Hickey88c0fac2016-12-13 16:22:50 +000025#ifdef FP64
26// expected-no-diagnostics
27#endif
28
29#if __OPENCL_C_VERSION__ < 120
Yaxun Liu39cf40f2016-05-16 17:06:34 +000030void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
31 double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
32 (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
33}
Neil Hickey88c0fac2016-12-13 16:22:50 +000034#endif
Yaxun Liu39cf40f2016-05-16 17:06:34 +000035
Neil Hickey7b5ddab2016-12-14 13:18:48 +000036int isnan(float x) {
37 return __builtin_isnan(x);
38}
39
40int isfinite(float x) {
41 return __builtin_isfinite(x);
42}
43
Yaxun Liu39cf40f2016-05-16 17:06:34 +000044#pragma OPENCL EXTENSION cl_khr_fp64 : enable
45#ifdef NOFP64
46// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
47#endif
48
Alexey Bader0ea07532016-11-01 15:50:52 +000049#pragma OPENCL EXTENSION cl_khr_fp16 : enable
50#ifdef NOFP16
51// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp16' - ignoring}}
52#endif
53
Yaxun Liu39cf40f2016-05-16 17:06:34 +000054void f2(void) {
55 double d;
56#ifdef NOFP64
57// expected-error@-2{{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
58#endif
59
60 (void) 1.0;
Neil Hickey88c0fac2016-12-13 16:22:50 +000061
Yaxun Liu39cf40f2016-05-16 17:06:34 +000062#ifdef NOFP64
Neil Hickey88c0fac2016-12-13 16:22:50 +000063// expected-warning@-3{{double precision constant requires cl_khr_fp64, casting to single precision}}
Yaxun Liu39cf40f2016-05-16 17:06:34 +000064#endif
65}
66
67#pragma OPENCL EXTENSION cl_khr_fp64 : disable
68#ifdef NOFP64
69// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
70#endif
71
Neil Hickey88c0fac2016-12-13 16:22:50 +000072#if __OPENCL_C_VERSION__ < 120
Yaxun Liu39cf40f2016-05-16 17:06:34 +000073void f3(void) {
74 double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
75}
Neil Hickey88c0fac2016-12-13 16:22:50 +000076#endif