Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 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 |
Neil Hickey | 88c0fac | 2016-12-13 16:22:50 +0000 | [diff] [blame^] | 3 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64 |
Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 4 | |
| 5 | // Test with a target not supporting fp64. |
Alexey Bader | 0ea0753 | 2016-11-01 15:50:52 +0000 | [diff] [blame] | 6 | // 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 Golin | 6a051ba | 2016-11-14 12:19:18 +0000 | [diff] [blame] | 26 | |
Neil Hickey | 88c0fac | 2016-12-13 16:22:50 +0000 | [diff] [blame^] | 27 | #ifdef FP64 |
| 28 | // expected-no-diagnostics |
| 29 | #endif |
| 30 | |
| 31 | #if __OPENCL_C_VERSION__ < 120 |
Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 32 | void 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 Hickey | 88c0fac | 2016-12-13 16:22:50 +0000 | [diff] [blame^] | 36 | #endif |
Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 37 | |
| 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 Bader | 0ea0753 | 2016-11-01 15:50:52 +0000 | [diff] [blame] | 43 | #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 Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 48 | void 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 Hickey | 88c0fac | 2016-12-13 16:22:50 +0000 | [diff] [blame^] | 55 | |
Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 56 | #ifdef NOFP64 |
Neil Hickey | 88c0fac | 2016-12-13 16:22:50 +0000 | [diff] [blame^] | 57 | // expected-warning@-3{{double precision constant requires cl_khr_fp64, casting to single precision}} |
Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 58 | #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 Hickey | 88c0fac | 2016-12-13 16:22:50 +0000 | [diff] [blame^] | 66 | #if __OPENCL_C_VERSION__ < 120 |
Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 67 | void f3(void) { |
| 68 | double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}} |
| 69 | } |
Neil Hickey | 88c0fac | 2016-12-13 16:22:50 +0000 | [diff] [blame^] | 70 | #endif |