[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / attr-exclude_from_explicit_instantiation.explicit_instantiation.cpp
blob379ab0a3eb00e246fb2cb1bbeaa697b778ffc859
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // Test that explicit instantiations do not instantiate entities
4 // marked with the exclude_from_explicit_instantiation attribute.
6 #define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))
8 template <class T>
9 struct Foo {
10 EXCLUDE_FROM_EXPLICIT_INSTANTIATION inline void non_static_member_function1();
12 EXCLUDE_FROM_EXPLICIT_INSTANTIATION void non_static_member_function2();
14 EXCLUDE_FROM_EXPLICIT_INSTANTIATION static inline void static_member_function1();
16 EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void static_member_function2();
18 EXCLUDE_FROM_EXPLICIT_INSTANTIATION static int static_data_member;
20 struct EXCLUDE_FROM_EXPLICIT_INSTANTIATION member_class1 {
21 static void non_static_member_function() { using Fail = typename T::fail; }
24 struct member_class2 {
25 EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void non_static_member_function() { using Fail = typename T::fail; }
29 template <class T>
30 inline void Foo<T>::non_static_member_function1() { using Fail = typename T::fail; }
32 template <class T>
33 void Foo<T>::non_static_member_function2() { using Fail = typename T::fail; }
35 template <class T>
36 inline void Foo<T>::static_member_function1() { using Fail = typename T::fail; }
38 template <class T>
39 void Foo<T>::static_member_function2() { using Fail = typename T::fail; }
41 template <class T>
42 int Foo<T>::static_data_member = T::fail;
44 // expected-no-diagnostics
45 template struct Foo<int>;