| 1 |
// Report error if dllimport attribute in definition itself. |
| 2 |
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw* x86_64-*-mingw* } } |
| 3 |
|
| 4 |
__attribute__((dllimport)) void bar () { } // { dg-error "definition" } |
| 5 |
|
| 6 |
__attribute__((dllimport)) int foo = 1; // { dg-error "definition" } |
| 7 |
|
| 8 |
void faz() |
| 9 |
{ |
| 10 |
__attribute__((dllimport)) int faa = 1; // { dg-error "definition" } |
| 11 |
faa++; |
| 12 |
} |
| 13 |
|
| 14 |
__attribute__((dllimport)) int fee (1); // { dg-error "definition" } |
| 15 |
|
| 16 |
|
| 17 |
// In-class initialization of a static data member is not a definition. |
| 18 |
struct F |
| 19 |
{ |
| 20 |
__attribute__ ((dllimport)) static const int i = 1; // OK |
| 21 |
}; |
| 22 |
|
| 23 |
// Reference the dllimport'd static data member. |
| 24 |
void f () |
| 25 |
{ |
| 26 |
const int* j = &F::i; |
| 27 |
} |
| 28 |
|
| 29 |
struct G |
| 30 |
{ |
| 31 |
__attribute__ ((dllimport)) static const int i = 1; |
| 32 |
}; |
| 33 |
|
| 34 |
// Define the static data member _without_ the dllimport. |
| 35 |
// This should override the prior declaration with dllimport. |
| 36 |
|
| 37 |
const int G::i; // { dg-warning "dllimport ignored" } |
| 38 |
|