annotate clang/test/SemaTemplate/metafun-apply.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 1d019706d866
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
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 struct add_pointer {
anatofuz
parents:
diff changeset
4 template<typename T>
anatofuz
parents:
diff changeset
5 struct apply {
anatofuz
parents:
diff changeset
6 typedef T* type;
anatofuz
parents:
diff changeset
7 };
anatofuz
parents:
diff changeset
8 };
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 struct add_reference {
anatofuz
parents:
diff changeset
11 template<typename T>
anatofuz
parents:
diff changeset
12 struct apply {
anatofuz
parents:
diff changeset
13 typedef T& type; // expected-error{{cannot form a reference to 'void'}}
anatofuz
parents:
diff changeset
14 };
anatofuz
parents:
diff changeset
15 };
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 struct bogus {
anatofuz
parents:
diff changeset
18 struct apply { // expected-note{{declared as a non-template here}}
anatofuz
parents:
diff changeset
19 typedef int type;
anatofuz
parents:
diff changeset
20 };
anatofuz
parents:
diff changeset
21 };
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 template<typename MetaFun, typename T>
anatofuz
parents:
diff changeset
24 struct apply1 {
anatofuz
parents:
diff changeset
25 typedef typename MetaFun::template apply<T>::type type; // expected-note{{in instantiation of template class 'add_reference::apply<void>' requested here}} \
anatofuz
parents:
diff changeset
26 // expected-error{{'apply' following the 'template' keyword does not refer to a template}}
anatofuz
parents:
diff changeset
27 };
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 int i;
anatofuz
parents:
diff changeset
30 apply1<add_pointer, int>::type ip = &i;
anatofuz
parents:
diff changeset
31 apply1<add_reference, int>::type ir = i;
anatofuz
parents:
diff changeset
32 apply1<add_reference, float>::type fr = i; // expected-error{{non-const lvalue reference to type 'float' cannot bind to a value of unrelated type 'int'}}
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 void test() {
anatofuz
parents:
diff changeset
35 apply1<add_reference, void>::type t; // expected-note{{in instantiation of template class 'apply1<add_reference, void>' requested here}}
anatofuz
parents:
diff changeset
36
anatofuz
parents:
diff changeset
37 apply1<bogus, int>::type t2; // expected-note{{in instantiation of template class 'apply1<bogus, int>' requested here}}
anatofuz
parents:
diff changeset
38 }
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40