Skip to content

Commit c1f8e04

Browse files
committed
[CUDA][HIP} Add a test for constexpr default ctor
Differential Revision: https://reviews.llvm.org/D68753 llvm-svn: 374502
1 parent 126158f commit c1f8e04

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

clang/test/SemaCUDA/constexpr-ctor.cu

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only \
2+
// RUN: -fcuda-is-device -verify=dev %s
3+
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only \
4+
// RUN: -verify=host %s
5+
6+
// host-no-diagnostics
7+
8+
#include "Inputs/cuda.h"
9+
10+
struct A {
11+
A(); // dev-note 2{{'A' declared here}}
12+
};
13+
14+
template <class T, int x> struct B {
15+
T a;
16+
constexpr B() = default; // dev-error 2{{reference to __host__ function 'A' in __host__ __device__ function}}
17+
};
18+
19+
__host__ void f() { B<A, 1> x; }
20+
__device__ void f() { B<A, 1> x; } // dev-note{{called by 'f'}}
21+
22+
struct foo {
23+
__host__ foo() { B<A, 2> x; }
24+
__device__ foo() { B<A, 2> x; } // dev-note{{called by 'foo'}}
25+
};
26+
27+
__host__ void g() { foo x; }
28+
__device__ void g() { foo x; } // dev-note{{called by 'g'}}
29+
30+
struct bar {
31+
__host__ bar() { B<A, 3> x; }
32+
__device__ bar() { B<A, 3> x; } // no error since no instantiation of bar
33+
};

0 commit comments

Comments
 (0)