| 1 |
// { dg-additional-options "-fmodules-ts" } |
| 2 |
|
| 3 |
import M; |
| 4 |
|
| 5 |
int main() { |
| 6 |
// These are all OK |
| 7 |
function(); |
| 8 |
int a = var; |
| 9 |
klass k; |
| 10 |
klass_tmpl<int> kt; |
| 11 |
klass_tmpl<int*> ktp; |
| 12 |
no_odr_use(); |
| 13 |
|
| 14 |
function_tmpl<ok_inst_tag>(); |
| 15 |
function_tmpl<ok_inst_tag*>(); |
| 16 |
int b = var_tmpl<ok_inst_tag>; |
| 17 |
int c = var_tmpl<ok_inst_tag*>; |
| 18 |
int d = *ptr; |
| 19 |
int e = dynamic_var; |
| 20 |
|
| 21 |
// But don't ignore exposures in these cases |
| 22 |
function_tmpl<int>(); // { dg-message "required from here" } |
| 23 |
int x = var_tmpl<int>; // { dg-message "required from here" } |
| 24 |
int y = var_tmpl<int*>; // { dg-message "required from here" } |
| 25 |
int z = *ptr_tmpl<int>; // { dg-message "required from here" } |
| 26 |
|
| 27 |
// And decls initialized to a TU-local value are not constant here |
| 28 |
// Unfortunately the error does not currently point to this decl |
| 29 |
constexpr int& r = constant_ref; |
| 30 |
// { dg-error "is not a constant expression" "" { target *-*-* } 0 } |
| 31 |
} |
| 32 |
|
| 33 |
// The errors occur in a different file, so we just test that all the |
| 34 |
// needed "required from here"s are found above. |
| 35 |
// { dg-error "instantiation exposes TU-local entity" "" { target *-*-* } 0 } |
| 36 |
// { dg-bogus "required from here" "" { target *-*-* } 0 } |