blob: 48e6e09b670d532647d8a7f401af5fa78d60e8dc [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
3
4// Test with a target not supporting fp64.
Alexey Bader0ea07532016-11-01 15:50:52 +00005// 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 Liu39cf40f2016-05-16 17:06:34 +000025
26void 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 Bader0ea07532016-11-01 15:50:52 +000036#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 Liu39cf40f2016-05-16 17:06:34 +000041void 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 Hickeyeb62b172016-09-19 11:42:14 +000049// expected-warning@-2{{double precision constant requires cl_khr_fp64, casting to single precision}}
Yaxun Liu39cf40f2016-05-16 17:06:34 +000050#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
58void f3(void) {
59 double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
60}