instantiate-function-2.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. template <typename T> struct S {
  3. S() { }
  4. S(T t);
  5. };
  6. template struct S<int>;
  7. void f() {
  8. S<int> s1;
  9. S<int> s2(10);
  10. }
  11. namespace PR7184 {
  12. template<typename T>
  13. void f() {
  14. typedef T type;
  15. void g(int array[sizeof(type)]);
  16. }
  17. template void f<int>();
  18. }
  19. namespace UsedAttr {
  20. template<typename T>
  21. void __attribute__((used)) foo() {
  22. T *x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
  23. }
  24. void bar() {
  25. foo<int>(); // expected-note{{instantiation of}}
  26. }
  27. }
  28. namespace PR9654 {
  29. typedef void ftype(int);
  30. template<typename T>
  31. ftype f;
  32. void g() {
  33. f<int>(0);
  34. }
  35. }
  36. namespace AliasTagDef {
  37. template<typename T>
  38. T f() {
  39. using S = struct { // expected-warning {{C++11}}
  40. T g() {
  41. return T();
  42. }
  43. };
  44. return S().g();
  45. }
  46. int n = f<int>();
  47. }
  48. namespace PR10273 {
  49. template<typename T> void (f)(T t) {}
  50. void g() {
  51. (f)(17);
  52. }
  53. }
  54. namespace rdar15464547 {
  55. class A {
  56. A();
  57. };
  58. template <typename R> class B {
  59. public:
  60. static void meth1();
  61. static void meth2();
  62. };
  63. A::A() {
  64. extern int compile_time_assert_failed;
  65. B<int>::meth2();
  66. }
  67. template <typename R> void B<R>::meth1() {
  68. extern int compile_time_assert_failed;
  69. }
  70. template <typename R> void B<R>::meth2() {
  71. extern int compile_time_assert_failed;
  72. }
  73. }