• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64
4
5// Test with a target not supporting fp64.
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// Test with -finclude-default-header, which includes opencl-c.h. opencl-c.h
26// disables all extensions by default, but supported core extensions for a
27// particular OpenCL version must be re-enabled (for example, cl_khr_fp64 is
28// enabled by default with -cl-std=CL2.0).
29//
30// RUN: %clang_cc1 %s -triple amdgcn-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header
31// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++
32
33#ifdef _OPENCL_H_
34// expected-no-diagnostics
35#endif
36
37#ifdef FP64
38// expected-no-diagnostics
39#endif
40
41#ifdef __OPENCL_CPP_VERSION__
42// expected-no-diagnostics
43#endif
44
45#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120)
46void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
47  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
48  (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
49}
50#endif
51
52#ifndef _OPENCL_H_
53int isnan(float x) {
54    return __builtin_isnan(x);
55}
56
57int isfinite(float x) {
58    return __builtin_isfinite(x);
59}
60#endif
61
62#pragma OPENCL EXTENSION cl_khr_fp64 : enable
63#ifdef NOFP64
64// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
65#endif
66
67#pragma OPENCL EXTENSION cl_khr_fp16 : enable
68#ifdef NOFP16
69// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp16' - ignoring}}
70#endif
71
72void f2(void) {
73  double d;
74#ifdef NOFP64
75// expected-error@-2{{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
76#endif
77
78  typedef double double4 __attribute__((ext_vector_type(4)));
79  double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f};
80#ifdef NOFP64
81// expected-error@-3 {{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
82// expected-error@-3 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 extension to be enabled}}
83#endif
84
85  (void) 1.0;
86
87#ifdef NOFP64
88// expected-warning@-3{{double precision constant requires cl_khr_fp64, casting to single precision}}
89#endif
90}
91
92#pragma OPENCL EXTENSION cl_khr_fp64 : disable
93#ifdef NOFP64
94// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
95#endif
96
97#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120)
98void f3(void) {
99  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
100}
101#endif
102