Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Charles Li | 85dec55 | 2015-12-10 01:07:17 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
| 4 | |
Douglas Gregor | 8d2ad87 | 2009-05-15 21:18:27 +0000 | [diff] [blame] | 5 | template <typename T> struct S { |
| 6 | S() { } |
| 7 | S(T t); |
| 8 | }; |
| 9 | |
| 10 | template struct S<int>; |
| 11 | |
| 12 | void f() { |
| 13 | S<int> s1; |
| 14 | S<int> s2(10); |
| 15 | } |
Douglas Gregor | 9f44d14 | 2010-05-21 21:25:08 +0000 | [diff] [blame] | 16 | |
| 17 | namespace 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 Gregor | ebada077 | 2010-06-17 23:14:26 +0000 | [diff] [blame] | 26 | |
| 27 | namespace 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 Gregor | 1501f16 | 2011-06-22 18:16:25 +0000 | [diff] [blame] | 37 | |
| 38 | namespace 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 Smith | cd1c055 | 2011-07-01 19:46:12 +0000 | [diff] [blame] | 48 | |
| 49 | namespace AliasTagDef { |
| 50 | template<typename T> |
| 51 | T f() { |
Charles Li | 85dec55 | 2015-12-10 01:07:17 +0000 | [diff] [blame] | 52 | using S = struct { |
| 53 | #if __cplusplus <= 199711L |
| 54 | // expected-warning@-2 {{alias declarations are a C++11 extension}} |
| 55 | #endif |
Richard Smith | cd1c055 | 2011-07-01 19:46:12 +0000 | [diff] [blame] | 56 | T g() { |
| 57 | return T(); |
| 58 | } |
| 59 | }; |
| 60 | return S().g(); |
| 61 | } |
| 62 | |
| 63 | int n = f<int>(); |
| 64 | } |
Douglas Gregor | b7c0083 | 2011-07-05 18:30:26 +0000 | [diff] [blame] | 65 | |
| 66 | namespace PR10273 { |
| 67 | template<typename T> void (f)(T t) {} |
| 68 | |
| 69 | void g() { |
| 70 | (f)(17); |
| 71 | } |
| 72 | } |
Argyrios Kyrtzidis | 9148622 | 2013-11-27 08:34:14 +0000 | [diff] [blame] | 73 | |
| 74 | namespace 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 | } |