| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
#include "Inputs/cuda.h" |
| 4 |
|
| 5 |
//------------------------------------------------------------------------------ |
| 6 |
// Test 1: collision between two bases |
| 7 |
|
| 8 |
struct A1_with_host_ctor { |
| 9 |
A1_with_host_ctor() {} |
| 10 |
}; |
| 11 |
|
| 12 |
struct B1_with_device_ctor { |
| 13 |
__device__ B1_with_device_ctor() {} |
| 14 |
}; |
| 15 |
|
| 16 |
struct C1_with_collision : A1_with_host_ctor, B1_with_device_ctor { |
| 17 |
}; |
| 18 |
|
| 19 |
// expected-note@-3 {{candidate constructor (the implicit default constructor}} not viable |
| 20 |
// expected-note@-4 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}} |
| 21 |
// expected-note@-5 {{candidate constructor (the implicit copy constructor}} not viable |
| 22 |
// expected-note@-6 {{candidate constructor (the implicit move constructor) not viable}} |
| 23 |
|
| 24 |
void hostfoo1() { |
| 25 |
C1_with_collision c; // expected-error {{no matching constructor}} |
| 26 |
} |
| 27 |
|
| 28 |
//------------------------------------------------------------------------------ |
| 29 |
// Test 2: collision between two fields |
| 30 |
|
| 31 |
struct C2_with_collision { |
| 32 |
A1_with_host_ctor aa; |
| 33 |
B1_with_device_ctor bb; |
| 34 |
}; |
| 35 |
|
| 36 |
// expected-note@-5 {{candidate constructor (the implicit default constructor}} not viable |
| 37 |
// expected-note@-6 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}} |
| 38 |
// expected-note@-7 {{candidate constructor (the implicit copy constructor}} not viable |
| 39 |
// expected-note@-8 {{candidate constructor (the implicit move constructor) not viable}} |
| 40 |
|
| 41 |
void hostfoo2() { |
| 42 |
C2_with_collision c; // expected-error {{no matching constructor}} |
| 43 |
|
| 44 |
} |
| 45 |
|
| 46 |
//------------------------------------------------------------------------------ |
| 47 |
// Test 3: collision between a field and a base |
| 48 |
|
| 49 |
struct C3_with_collision : A1_with_host_ctor { |
| 50 |
B1_with_device_ctor bb; |
| 51 |
}; |
| 52 |
|
| 53 |
// expected-note@-4 {{candidate constructor (the implicit default constructor}} not viable |
| 54 |
// expected-note@-5 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}} |
| 55 |
// expected-note@-6 {{candidate constructor (the implicit copy constructor}} not viable |
| 56 |
// expected-note@-7 {{candidate constructor (the implicit move constructor) not viable}} |
| 57 |
|
| 58 |
void hostfoo3() { |
| 59 |
C3_with_collision c; // expected-error {{no matching constructor}} |
| 60 |
} |