blob: 367652ccdd22742c9c4197819d7893b88b88e1fa [file] [log] [blame]
Yaxun Liu5b746652016-12-18 05:18:55 +00001// Test this without pch.
Andrew Savonichev52d674d2018-10-29 11:14:01 +00002// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
Yaxun Liu5b746652016-12-18 05:18:55 +00003
4// Test with pch.
Andrew Savonichev52d674d2018-10-29 11:14:01 +00005// RUN: %clang_cc1 -x cl %S/extension-begin.h -triple spir-unknown-unknown -emit-pch -o %t.pch -pedantic
6// RUN: %clang_cc1 %s -triple spir-unknown-unknown -include-pch %t.pch -DIMPLICIT_INCLUDE -DUSE_PCH -fsyntax-only -verify -pedantic
Yaxun Liu5b746652016-12-18 05:18:55 +00007
Andrew Savonichev52d674d2018-10-29 11:14:01 +00008// Test with modules
9// RUN: rm -rf %t.modules
10// RUN: mkdir -p %t.modules
11//
12// RUN: %clang_cc1 -cl-std=CL1.2 -DIMPLICIT_INCLUDE -include %S/extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.modules %s -verify -pedantic
13//
14// RUN: rm -rf %t.modules
15// RUN: mkdir -p %t.modules
16//
17// RUN: %clang_cc1 -cl-std=CL2.0 -DIMPLICIT_INCLUDE -include %S/extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.modules %s -verify -pedantic
Yaxun Liu5b746652016-12-18 05:18:55 +000018
Andrew Savonichev9ed325e2019-06-03 13:02:43 +000019#pragma OPENCL EXTENSION my_ext : enable
20#ifndef IMPLICIT_INCLUDE
21// expected-warning@-2 {{unknown OpenCL extension 'my_ext' - ignoring}}
22// expected-warning@+2 {{unknown OpenCL extension 'my_ext' - ignoring}}
23#endif // IMPLICIT_INCLUDE
24#pragma OPENCL EXTENSION my_ext : disable
25
Andrew Savonichev52d674d2018-10-29 11:14:01 +000026#ifndef IMPLICIT_INCLUDE
27#include "extension-begin.h"
28#endif // IMPLICIT_INCLUDE
29#ifndef USE_PCH
30// expected-warning@extension-begin.h:4 {{expected 'disable' - ignoring}}
31// expected-warning@extension-begin.h:5 {{expected 'disable' - ignoring}}
32// expected-warning@extension-begin.h:21 {{OpenCL extension end directive mismatches begin directive - ignoring}}
33#endif // USE_PCH
Yaxun Liu5b746652016-12-18 05:18:55 +000034
35#pragma OPENCL EXTENSION my_ext : enable
36void test_f1(void) {
37 struct A test_A1;
38 f();
39 g(0);
40}
41
42#pragma OPENCL EXTENSION my_ext : disable
43void test_f2(void) {
44 struct A test_A2; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
45 const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
46 TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext extension to be enabled}}
47 PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const struct A *') requires my_ext extension to be enabled}}
Joey Gouly186791d2017-06-30 14:23:01 +000048 f(); // expected-error {{use of declaration 'f' requires my_ext extension to be enabled}}
Yaxun Liu5b746652016-12-18 05:18:55 +000049 g(0); // expected-error {{no matching function for call to 'g'}}
Andrew Savonichev97754f42018-11-07 13:07:18 +000050 // expected-note@extension-begin.h:18 {{candidate unavailable as it requires OpenCL extension 'my_ext' to be enabled}}
Andrew Savonichev52d674d2018-10-29 11:14:01 +000051 // expected-note@extension-begin.h:23 {{candidate function not viable: requires 0 arguments, but 1 was provided}}
Yaxun Liu5b746652016-12-18 05:18:55 +000052}
53