blob: ffdb4c9144571cd1dc9790e5e872e9783979d39d [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Charles Li85dec552015-12-10 01:07:17 +00002// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
4
Douglas Gregor8d2ad872009-05-15 21:18:27 +00005template <typename T> struct S {
6 S() { }
7 S(T t);
8};
9
10template struct S<int>;
11
12void f() {
13 S<int> s1;
14 S<int> s2(10);
15}
Douglas Gregor9f44d142010-05-21 21:25:08 +000016
17namespace PR7184 {
18 template<typename T>
19 void f() {
20 typedef T type;
21 void g(int array[sizeof(type)]);
22 }
23
24 template void f<int>();
25}
Douglas Gregorebada0772010-06-17 23:14:26 +000026
27namespace UsedAttr {
28 template<typename T>
29 void __attribute__((used)) foo() {
30 T *x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
31 }
32
33 void bar() {
34 foo<int>(); // expected-note{{instantiation of}}
35 }
36}
Douglas Gregor1501f162011-06-22 18:16:25 +000037
38namespace PR9654 {
39 typedef void ftype(int);
40
41 template<typename T>
42 ftype f;
43
44 void g() {
45 f<int>(0);
46 }
47}
Richard Smithcd1c0552011-07-01 19:46:12 +000048
49namespace AliasTagDef {
50 template<typename T>
51 T f() {
Charles Li85dec552015-12-10 01:07:17 +000052 using S = struct {
53#if __cplusplus <= 199711L
54 // expected-warning@-2 {{alias declarations are a C++11 extension}}
55#endif
Richard Smithcd1c0552011-07-01 19:46:12 +000056 T g() {
57 return T();
58 }
59 };
60 return S().g();
61 }
62
63 int n = f<int>();
64}
Douglas Gregorb7c00832011-07-05 18:30:26 +000065
66namespace PR10273 {
67 template<typename T> void (f)(T t) {}
68
69 void g() {
70 (f)(17);
71 }
72}
Argyrios Kyrtzidis91486222013-11-27 08:34:14 +000073
74namespace rdar15464547 {
75 class A {
76 A();
77 };
78
79 template <typename R> class B {
80 public:
81 static void meth1();
82 static void meth2();
83 };
84
85 A::A() {
86 extern int compile_time_assert_failed;
87 B<int>::meth2();
88 }
89
90 template <typename R> void B<R>::meth1() {
91 extern int compile_time_assert_failed;
92 }
93
94 template <typename R> void B<R>::meth2() {
95 extern int compile_time_assert_failed;
96 }
97}