xref: /llvm-project/clang/test/SemaCUDA/autoret-global.cu (revision 24337db616668125b55781a82d7651800934ae4a)
1 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
2 
3 #include "Inputs/cuda.h"
4 
5 template <typename T>
foo()6 __global__ T foo() {
7   // expected-note@-1 {{kernel function type 'T ()' must have void return type}}
8 }
9 
f0()10 void f0() {
11   foo<void><<<0, 0>>>();
12   foo<int><<<0, 0>>>();
13   // expected-error@-1 {{no matching function for call to 'foo'}}
14 }
15 
f1()16 __global__ auto f1() {
17 }
18 
f2(int x)19 __global__ auto f2(int x) {
20   return x + 1;
21   // expected-error@-2 {{kernel function type 'auto (int)' must have void return type}}
22 }
23 
24 template <bool Cond, typename T = void> struct enable_if { typedef T type; };
25 template <typename T> struct enable_if<false, T> {};
26 
27 template <int N>
28 __global__
bar()29 auto bar() -> typename enable_if<N == 1>::type {
30   // expected-note@-1 {{requirement '3 == 1' was not satisfied [with N = 3]}}
31 }
32 
33 template <int N>
34 __global__
bar()35 auto bar() -> typename enable_if<N == 2>::type {
36   // expected-note@-1 {{requirement '3 == 2' was not satisfied [with N = 3]}}
37 }
38 
f3()39 void f3() {
40   bar<1><<<0, 0>>>();
41   bar<2><<<0, 0>>>();
42   bar<3><<<0, 0>>>();
43   // expected-error@-1 {{no matching function for call to 'bar'}}
44 }
45