blob: b03428ad33bbeeeb75356344c8188f7e326890aa [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
25
Renato Golin6a051ba2016-11-14 12:19:18 +000026
Neil Hickey88c0fac2016-12-13 16:22:50 +000027#ifdef FP64
28// expected-no-diagnostics
29#endif
30
31#if __OPENCL_C_VERSION__ < 120
Yaxun Liu39cf40f2016-05-16 17:06:34 +000032void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
33 double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
34 (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
35}
Neil Hickey88c0fac2016-12-13 16:22:50 +000036#endif
Yaxun Liu39cf40f2016-05-16 17:06:34 +000037
38#pragma OPENCL EXTENSION cl_khr_fp64 : enable
39#ifdef NOFP64
40// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
41#endif
42
Alexey Bader0ea07532016-11-01 15:50:52 +000043#pragma OPENCL EXTENSION cl_khr_fp16 : enable
44#ifdef NOFP16
45// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp16' - ignoring}}
46#endif
47
Yaxun Liu39cf40f2016-05-16 17:06:34 +000048void f2(void) {
49 double d;
50#ifdef NOFP64
51// expected-error@-2{{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
52#endif
53
54 (void) 1.0;
Neil Hickey88c0fac2016-12-13 16:22:50 +000055
Yaxun Liu39cf40f2016-05-16 17:06:34 +000056#ifdef NOFP64
Neil Hickey88c0fac2016-12-13 16:22:50 +000057// expected-warning@-3{{double precision constant requires cl_khr_fp64, casting to single precision}}
Yaxun Liu39cf40f2016-05-16 17:06:34 +000058#endif
59}
60
61#pragma OPENCL EXTENSION cl_khr_fp64 : disable
62#ifdef NOFP64
63// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
64#endif
65
Neil Hickey88c0fac2016-12-13 16:22:50 +000066#if __OPENCL_C_VERSION__ < 120
Yaxun Liu39cf40f2016-05-16 17:06:34 +000067void f3(void) {
68 double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
69}
Neil Hickey88c0fac2016-12-13 16:22:50 +000070#endif