annotate clang/test/SemaTemplate/instantiate-member-expr.cpp @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 0572611fdcc8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify %s -pedantic
anatofuz
parents:
diff changeset
2 template<typename T>
anatofuz
parents:
diff changeset
3 struct S {
anatofuz
parents:
diff changeset
4 S() { }
anatofuz
parents:
diff changeset
5 };
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 template<typename T>
anatofuz
parents:
diff changeset
8 struct vector {
anatofuz
parents:
diff changeset
9 void push_back(const T&) { int a[sizeof(T) ? -1: -1]; } // expected-error {{array with a negative size}}
anatofuz
parents:
diff changeset
10 };
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 class ExprEngine {
anatofuz
parents:
diff changeset
13 public:
anatofuz
parents:
diff changeset
14 typedef vector<S<void *> >CheckersOrdered;
anatofuz
parents:
diff changeset
15 CheckersOrdered Checkers;
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 template <typename CHECKER>
anatofuz
parents:
diff changeset
18 void registerCheck(CHECKER *check) {
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
19 Checkers.push_back(S<void *>()); // expected-note {{in instantiation of member function 'vector<S<void *>>::push_back' requested here}}
150
anatofuz
parents:
diff changeset
20 }
anatofuz
parents:
diff changeset
21 };
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 class RetainReleaseChecker { };
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 void f(ExprEngine& Eng) {
anatofuz
parents:
diff changeset
26 Eng.registerCheck(new RetainReleaseChecker); // expected-note {{in instantiation of function template specialization 'ExprEngine::registerCheck<RetainReleaseChecker>' requested here}}
anatofuz
parents:
diff changeset
27 }
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 // PR 5838
anatofuz
parents:
diff changeset
30 namespace test1 {
anatofuz
parents:
diff changeset
31 template<typename T> struct A {
anatofuz
parents:
diff changeset
32 int a;
anatofuz
parents:
diff changeset
33 };
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 template<typename T> struct B : A<float>, A<T> {
anatofuz
parents:
diff changeset
36 void f() {
anatofuz
parents:
diff changeset
37 a = 0; // should not be ambiguous
anatofuz
parents:
diff changeset
38 }
anatofuz
parents:
diff changeset
39 };
anatofuz
parents:
diff changeset
40 template struct B<int>;
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 struct O {
anatofuz
parents:
diff changeset
43 int a;
anatofuz
parents:
diff changeset
44 template<typename T> struct B : A<T> {
anatofuz
parents:
diff changeset
45 void f() {
anatofuz
parents:
diff changeset
46 a = 0; // expected-error {{'test1::O::a' is not a member of class 'test1::O::B<int>'}}
anatofuz
parents:
diff changeset
47 }
anatofuz
parents:
diff changeset
48 };
anatofuz
parents:
diff changeset
49 };
anatofuz
parents:
diff changeset
50 template struct O::B<int>; // expected-note {{in instantiation}}
anatofuz
parents:
diff changeset
51 }
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 // PR7248
anatofuz
parents:
diff changeset
54 namespace test2 {
anatofuz
parents:
diff changeset
55 template <class T> struct A {
anatofuz
parents:
diff changeset
56 void foo() {
anatofuz
parents:
diff changeset
57 T::bar(); // expected-error {{type 'int' cannot}}
anatofuz
parents:
diff changeset
58 }
anatofuz
parents:
diff changeset
59 };
anatofuz
parents:
diff changeset
60
anatofuz
parents:
diff changeset
61 template <class T> class B {
anatofuz
parents:
diff changeset
62 void foo(A<T> a) {
anatofuz
parents:
diff changeset
63 a.test2::template A<T>::foo(); // expected-note {{in instantiation}}
anatofuz
parents:
diff changeset
64 }
anatofuz
parents:
diff changeset
65 };
anatofuz
parents:
diff changeset
66
anatofuz
parents:
diff changeset
67 template class B<int>;
anatofuz
parents:
diff changeset
68 }
anatofuz
parents:
diff changeset
69
anatofuz
parents:
diff changeset
70 namespace PR14124 {
anatofuz
parents:
diff changeset
71 template<typename T> struct S {
anatofuz
parents:
diff changeset
72 int value;
anatofuz
parents:
diff changeset
73 };
anatofuz
parents:
diff changeset
74 template<typename T> void f() { S<T>::value; } // expected-error {{invalid use of non-static data member 'value'}}
anatofuz
parents:
diff changeset
75 template void f<int>(); // expected-note {{in instantiation of}}
anatofuz
parents:
diff changeset
76
anatofuz
parents:
diff changeset
77 struct List { List *next; };
anatofuz
parents:
diff changeset
78 template<typename T, T *(T::*p) = &T::next> struct A {};
anatofuz
parents:
diff changeset
79 A<List> a; // ok
anatofuz
parents:
diff changeset
80 void operator&(struct Whatever);
anatofuz
parents:
diff changeset
81 template<typename T, T *(T::*p) = &T::next> struct B {};
anatofuz
parents:
diff changeset
82 B<List> b; // still ok
anatofuz
parents:
diff changeset
83 }