[AMDGPU][True16][CodeGen] true16 codegen pattern for v_med3_u/i16 (#121850)
[llvm-project.git] / clang / test / SemaTemplate / instantiate-pure-virtual-function.cpp
blobcaec42b6b77f9555e5e75aa5f9a085f56e61b1c9
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wundefined-func-template %s
3 namespace GH74016 {
4 template <typename T> class B {
5 public:
6 constexpr void foo(const T &) { bar(1); }
7 virtual constexpr void bar(unsigned int) = 0;
8 };
10 template <typename T> class D : public B<T> {
11 public:
12 constexpr void bar(unsigned int) override {}
15 void test() {
16 auto t = D<int>();
17 t.foo(0);
21 namespace call_pure_virtual_function_from_virtual {
22 template <typename T> class B {
23 public:
24 const void foo(const T &) { B::bar(1); } // expected-warning {{instantiation of function 'call_pure_virtual_function_from_virtual::B<int>::bar' required here, but no definition is available}}
25 // expected-note@-1 {{add an explicit instantiation declaration to suppress this warning if 'call_pure_virtual_function_from_virtual::B<int>::bar' is explicitly instantiated in another translation unit}}
26 virtual const void bar(unsigned int) = 0; // expected-note {{forward declaration of template entity is here}}
29 template <typename T> class D : public B<T> {
30 public:
31 const void bar(unsigned int) override {}
34 void test() {
35 auto t = D<int>();
36 t.foo(0); // expected-note {{in instantiation of member function 'call_pure_virtual_function_from_virtual::B<int>::foo' requested here}}
40 namespace non_pure_virtual_function {
41 template <typename T> class B {
42 public:
43 constexpr void foo(const T &) { bar(1); }
45 virtual constexpr void bar(unsigned int); // expected-warning {{inline function 'non_pure_virtual_function::B<int>::bar' is not defined}}
46 // expected-note@-1 {{forward declaration of template entity is here}}
47 // expected-note@-2 {{forward declaration of template entity is here}}
48 // expected-note@-3 {{forward declaration of template entity is here}}
51 template <typename T> class D : public B<T> { // expected-warning {{instantiation of function 'non_pure_virtual_function::B<int>::bar' required here, but no definition is available}}
52 // expected-warning@-1 {{instantiation of function 'non_pure_virtual_function::B<int>::bar' required here, but no definition is available}}
53 // expected-warning@-2 {{instantiation of function 'non_pure_virtual_function::B<int>::bar' required here, but no definition is available}}
54 // expected-note@-3 {{add an explicit instantiation declaration to suppress this warning if 'non_pure_virtual_function::B<int>::bar' is explicitly instantiated in another translation unit}}
55 // expected-note@-4 {{add an explicit instantiation declaration to suppress this warning if 'non_pure_virtual_function::B<int>::bar' is explicitly instantiated in another translation unit}}
56 // expected-note@-5 {{add an explicit instantiation declaration to suppress this warning if 'non_pure_virtual_function::B<int>::bar' is explicitly instantiated in another translation unit}}
57 // expected-note@-6 {{used here}}
59 public:
60 constexpr void bar(unsigned int) override { }
63 void test() {
64 auto t = D<int>();
65 t.foo(0);