2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-05-16 05:18:27 +08:00
|
|
|
template <typename T> struct S {
|
|
|
|
S() { }
|
|
|
|
S(T t);
|
|
|
|
};
|
|
|
|
|
|
|
|
template struct S<int>;
|
|
|
|
|
|
|
|
void f() {
|
|
|
|
S<int> s1;
|
|
|
|
S<int> s2(10);
|
|
|
|
}
|
2010-05-22 05:25:08 +08:00
|
|
|
|
|
|
|
namespace PR7184 {
|
|
|
|
template<typename T>
|
|
|
|
void f() {
|
|
|
|
typedef T type;
|
|
|
|
void g(int array[sizeof(type)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
template void f<int>();
|
|
|
|
}
|
2010-06-18 07:14:26 +08:00
|
|
|
|
|
|
|
namespace UsedAttr {
|
|
|
|
template<typename T>
|
|
|
|
void __attribute__((used)) foo() {
|
|
|
|
T *x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void bar() {
|
|
|
|
foo<int>(); // expected-note{{instantiation of}}
|
|
|
|
}
|
|
|
|
}
|
2011-06-23 02:16:25 +08:00
|
|
|
|
|
|
|
namespace PR9654 {
|
|
|
|
typedef void ftype(int);
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
ftype f;
|
|
|
|
|
|
|
|
void g() {
|
|
|
|
f<int>(0);
|
|
|
|
}
|
|
|
|
}
|
2011-07-02 03:46:12 +08:00
|
|
|
|
|
|
|
namespace AliasTagDef {
|
|
|
|
template<typename T>
|
|
|
|
T f() {
|
2011-10-13 03:26:40 +08:00
|
|
|
using S = struct { // expected-warning {{C++11}}
|
2011-07-02 03:46:12 +08:00
|
|
|
T g() {
|
|
|
|
return T();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return S().g();
|
|
|
|
}
|
|
|
|
|
|
|
|
int n = f<int>();
|
|
|
|
}
|
2011-07-06 02:30:26 +08:00
|
|
|
|
|
|
|
namespace PR10273 {
|
|
|
|
template<typename T> void (f)(T t) {}
|
|
|
|
|
|
|
|
void g() {
|
|
|
|
(f)(17);
|
|
|
|
}
|
|
|
|
}
|
2013-11-27 16:34:14 +08:00
|
|
|
|
|
|
|
namespace rdar15464547 {
|
|
|
|
class A {
|
|
|
|
A();
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename R> class B {
|
|
|
|
public:
|
|
|
|
static void meth1();
|
|
|
|
static void meth2();
|
|
|
|
};
|
|
|
|
|
|
|
|
A::A() {
|
|
|
|
extern int compile_time_assert_failed;
|
|
|
|
B<int>::meth2();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename R> void B<R>::meth1() {
|
|
|
|
extern int compile_time_assert_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename R> void B<R>::meth2() {
|
|
|
|
extern int compile_time_assert_failed;
|
|
|
|
}
|
|
|
|
}
|