1 | // RUN: %clang_cc1 -fsyntax-only -Wundefined-func-template -Wundefined-var-template -verify %s |
2 | |
3 | // Test that a diagnostic is emitted when an entity marked with the |
4 | // exclude_from_explicit_instantiation attribute is not defined in |
5 | // the current TU but it is used (and it is hence implicitly |
6 | // instantiated). |
7 | |
8 | #define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation)) |
9 | |
10 | template <class T> |
11 | struct Foo { |
12 | EXCLUDE_FROM_EXPLICIT_INSTANTIATION void non_static_member_function(); // expected-note{{forward declaration of template entity is here}} |
13 | EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void static_member_function(); // expected-note{{forward declaration of template entity is here}} |
14 | EXCLUDE_FROM_EXPLICIT_INSTANTIATION static int static_data_member; // expected-note{{forward declaration of template entity is here}} |
15 | struct EXCLUDE_FROM_EXPLICIT_INSTANTIATION nested { |
16 | static int static_member_function(); // expected-note{{forward declaration of template entity is here}} |
17 | }; |
18 | }; |
19 | |
20 | extern template struct Foo<int>; |
21 | |
22 | void use() { |
23 | Foo<int> foo; |
24 | |
25 | foo.non_static_member_function(); // expected-warning{{instantiation of function 'Foo<int>::non_static_member_function' required here, but no definition is available}} |
26 | // expected-note@-1 {{add an explicit instantiation}} |
27 | |
28 | Foo<int>::static_member_function(); // expected-warning{{instantiation of function 'Foo<int>::static_member_function' required here, but no definition is available}} |
29 | // expected-note@-1 {{add an explicit instantiation}} |
30 | |
31 | (void)Foo<int>::static_data_member; // expected-warning{{instantiation of variable 'Foo<int>::static_data_member' required here, but no definition is available}} |
32 | // expected-note@-1 {{add an explicit instantiation}} |
33 | |
34 | Foo<int>::nested::static_member_function(); // expected-warning{{instantiation of function 'Foo<int>::nested::static_member_function' required here, but no definition is available}} |
35 | // expected-note@-1 {{add an explicit instantiation}} |
36 | } |
37 | |