Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 49f25ec | 2009-05-15 21:18:27 +0000 | [diff] [blame] | 2 | template <typename T> struct S { |
| 3 | S() { } |
| 4 | S(T t); |
| 5 | }; |
| 6 | |
| 7 | template struct S<int>; |
| 8 | |
| 9 | void f() { |
| 10 | S<int> s1; |
| 11 | S<int> s2(10); |
| 12 | } |
Douglas Gregor | b212d9a | 2010-05-21 21:25:08 +0000 | [diff] [blame] | 13 | |
| 14 | namespace 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 Gregor | c070cc6 | 2010-06-17 23:14:26 +0000 | [diff] [blame] | 23 | |
| 24 | namespace 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 Gregor | 1d441ee | 2011-06-22 18:16:25 +0000 | [diff] [blame] | 34 | |
| 35 | namespace 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 Smith | c89edf5 | 2011-07-01 19:46:12 +0000 | [diff] [blame] | 45 | |
| 46 | namespace AliasTagDef { |
| 47 | template<typename T> |
| 48 | T f() { |
Douglas Gregor | b3df138 | 2011-10-12 19:26:40 +0000 | [diff] [blame] | 49 | using S = struct { // expected-warning {{C++11}} |
Richard Smith | c89edf5 | 2011-07-01 19:46:12 +0000 | [diff] [blame] | 50 | T g() { |
| 51 | return T(); |
| 52 | } |
| 53 | }; |
| 54 | return S().g(); |
| 55 | } |
| 56 | |
| 57 | int n = f<int>(); |
| 58 | } |
Douglas Gregor | 5cbe101 | 2011-07-05 18:30:26 +0000 | [diff] [blame] | 59 | |
| 60 | namespace PR10273 { |
| 61 | template<typename T> void (f)(T t) {} |
| 62 | |
| 63 | void g() { |
| 64 | (f)(17); |
| 65 | } |
| 66 | } |