1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2
3 namespace PR15360 {
4 template<typename R, typename U, R F>
5 U f() { return &F; } // expected-error{{cannot take the address of an rvalue of type 'int (*)(int)'}} expected-error{{cannot take the address of an rvalue of type 'int *'}}
test()6 void test() {
7 f<int(int), int(*)(int), nullptr>(); // expected-note{{in instantiation of}}
8 f<int[3], int*, nullptr>(); // expected-note{{in instantiation of}}
9 }
10 }
11
12 namespace CanonicalNullptr {
13 template<typename T> struct get { typedef T type; };
14 struct X {};
15 template<typename T, typename get<T *>::type P = nullptr> struct A {};
16 template<typename T, typename get<decltype((T(), nullptr))>::type P = nullptr> struct B {};
17 template<typename T, typename get<T X::*>::type P = nullptr> struct C {};
18
19 template<typename T> A<T> MakeA();
20 template<typename T> B<T> MakeB();
21 template<typename T> C<T> MakeC();
22 A<int> a = MakeA<int>();
23 B<int> b = MakeB<int>();
24 C<int> c = MakeC<int>();
25 }
26
27 namespace Auto {
28 template<auto> struct A { }; // expected-error {{until C++17}}
29 }
30
31 namespace check_conversion_early {
32 struct X {};
33 template<int> struct A {};
34 template<X &x> struct A<x> {}; // expected-error {{not implicitly convertible}}
35
operator intcheck_conversion_early::Y36 struct Y { constexpr operator int() const { return 0; } };
37 template<Y &y> struct A<y> {}; // expected-error {{cannot be deduced}} expected-note {{'y'}}
38 }
39
40 namespace ReportCorrectParam {
41 template <int a, unsigned b, int c>
TempFunc()42 void TempFunc() {}
43
Useage()44 void Useage() {
45 //expected-error@+2 {{no matching function}}
46 //expected-note@-4 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'b'}}
47 TempFunc<1, -1, 1>();
48 }
49 }
50
51 namespace PR42513 {
52 template<typename X, int Ret = WidgetCtor((X*)nullptr)> void f();
53 constexpr int WidgetCtor(struct X1*);
54
55 struct X1 {
56 friend constexpr int WidgetCtor(X1*);
57 };
58 template<typename X1>
59 struct StandardWidget {
WidgetCtor(X1 *)60 friend constexpr int WidgetCtor(X1*) {
61 return 0;
62 }
63 };
64 template struct StandardWidget<X1>;
65
use()66 void use() { f<X1>(); }
67 }
68