annotate clang/test/SemaTemplate/instantiate-scope.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +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 -std=c++11 -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 template<typename ...T> struct X {
anatofuz
parents:
diff changeset
4 void f(int);
anatofuz
parents:
diff changeset
5 void f(...);
anatofuz
parents:
diff changeset
6 static int n;
anatofuz
parents:
diff changeset
7 };
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 template<typename T, typename U> using A = T;
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 // These definitions are OK, X<A<T, decltype(...)>...> is equivalent to X<T...>
anatofuz
parents:
diff changeset
12 // so this defines the member of the primary template.
anatofuz
parents:
diff changeset
13 template<typename ...T>
anatofuz
parents:
diff changeset
14 void X<A<T, decltype(f(T()))>...>::f(int) {} // expected-error {{undeclared}}
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 template<typename ...T>
anatofuz
parents:
diff changeset
17 int X<A<T, decltype(f(T()))>...>::n = 0; // expected-error {{undeclared}}
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 struct Y {}; void f(Y);
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 void g() {
anatofuz
parents:
diff changeset
22 // OK, substitution succeeds.
anatofuz
parents:
diff changeset
23 X<Y>().f(0);
anatofuz
parents:
diff changeset
24 X<Y>::n = 1;
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 // Error, substitution fails; this should not be treated as a SFINAE-able
anatofuz
parents:
diff changeset
27 // condition, so we don't select X<void>::f(...).
anatofuz
parents:
diff changeset
28 X<void>().f(0); // expected-note {{instantiation of}}
anatofuz
parents:
diff changeset
29 X<void>::n = 1; // expected-note {{instantiation of}}
anatofuz
parents:
diff changeset
30 }