blob: 087ede2b89cbbc1028b3bed96fa4d3c789075265 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor49f25ec2009-05-15 21:18:27 +00002template <typename T> struct S {
3 S() { }
4 S(T t);
5};
6
7template struct S<int>;
8
9void f() {
10 S<int> s1;
11 S<int> s2(10);
12}
Douglas Gregorb212d9a2010-05-21 21:25:08 +000013
14namespace PR7184 {
15 template<typename T>
16 void f() {
17 typedef T type;
18 void g(int array[sizeof(type)]);
19 }
20
21 template void f<int>();
22}
Douglas Gregorc070cc62010-06-17 23:14:26 +000023
24namespace UsedAttr {
25 template<typename T>
26 void __attribute__((used)) foo() {
27 T *x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
28 }
29
30 void bar() {
31 foo<int>(); // expected-note{{instantiation of}}
32 }
33}
Douglas Gregor1d441ee2011-06-22 18:16:25 +000034
35namespace PR9654 {
36 typedef void ftype(int);
37
38 template<typename T>
39 ftype f;
40
41 void g() {
42 f<int>(0);
43 }
44}
Richard Smithc89edf52011-07-01 19:46:12 +000045
46namespace AliasTagDef {
47 template<typename T>
48 T f() {
49 using S = struct { // expected-warning {{C++0x}}
50 T g() {
51 return T();
52 }
53 };
54 return S().g();
55 }
56
57 int n = f<int>();
58}
Douglas Gregor5cbe1012011-07-05 18:30:26 +000059
60namespace PR10273 {
61 template<typename T> void (f)(T t) {}
62
63 void g() {
64 (f)(17);
65 }
66}