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 |
| 3 | |
| 4 | // Test with a target not supporting fp64. |
Alexey Bader | 0ea0753 | 2016-11-01 15:50:52 +0000 | [diff] [blame^] | 5 | // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16 |
| 6 | |
| 7 | // Test with some extensions enabled or disabled by cmd-line args |
| 8 | // |
| 9 | // Target does not support fp64 and fp16 - override it |
| 10 | // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+cl_khr_fp64,+cl_khr_fp16 |
| 11 | // |
| 12 | // Disable or enable all extensions |
| 13 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16 |
| 14 | // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all |
| 15 | // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64 |
| 16 | // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16 |
| 17 | // |
| 18 | // Concatenating |
| 19 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64 |
| 20 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64,+cl_khr_fp64 |
| 21 | // 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 |
| 22 | // 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 |
| 23 | |
| 24 | |
Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 25 | |
| 26 | void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}} |
| 27 | double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}} |
| 28 | (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}} |
| 29 | } |
| 30 | |
| 31 | #pragma OPENCL EXTENSION cl_khr_fp64 : enable |
| 32 | #ifdef NOFP64 |
| 33 | // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}} |
| 34 | #endif |
| 35 | |
Alexey Bader | 0ea0753 | 2016-11-01 15:50:52 +0000 | [diff] [blame^] | 36 | #pragma OPENCL EXTENSION cl_khr_fp16 : enable |
| 37 | #ifdef NOFP16 |
| 38 | // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp16' - ignoring}} |
| 39 | #endif |
| 40 | |
Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 41 | void f2(void) { |
| 42 | double d; |
| 43 | #ifdef NOFP64 |
| 44 | // expected-error@-2{{use of type 'double' requires cl_khr_fp64 extension to be enabled}} |
| 45 | #endif |
| 46 | |
| 47 | (void) 1.0; |
| 48 | #ifdef NOFP64 |
Neil Hickey | eb62b17 | 2016-09-19 11:42:14 +0000 | [diff] [blame] | 49 | // expected-warning@-2{{double precision constant requires cl_khr_fp64, casting to single precision}} |
Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 50 | #endif |
| 51 | } |
| 52 | |
| 53 | #pragma OPENCL EXTENSION cl_khr_fp64 : disable |
| 54 | #ifdef NOFP64 |
| 55 | // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}} |
| 56 | #endif |
| 57 | |
| 58 | void f3(void) { |
| 59 | double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}} |
| 60 | } |