instantiate-decl-init.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. // expected-no-diagnostics
  3. // PR5426 - the non-dependent obj would be fully processed and wrapped in a
  4. // CXXConstructExpr at definition time, which would lead to a failure at
  5. // instantiation time.
  6. struct arg {
  7. arg();
  8. };
  9. struct oldstylemove {
  10. oldstylemove(oldstylemove&);
  11. oldstylemove(const arg&);
  12. };
  13. template <typename T>
  14. void fn(T t, const arg& arg) {
  15. oldstylemove obj(arg);
  16. }
  17. void test() {
  18. fn(1, arg());
  19. }
  20. struct X0 { };
  21. struct X1 {
  22. explicit X1(const X0 &x0 = X0());
  23. };
  24. template<typename T>
  25. void f0() {
  26. X1 x1;
  27. }
  28. template void f0<int>();
  29. template void f0<float>();
  30. struct NonTrivial {
  31. NonTrivial();
  32. ~NonTrivial();
  33. };
  34. template<int N> void f1() {
  35. NonTrivial array[N];
  36. }
  37. template<> void f1<2>();
  38. namespace PR20346 {
  39. struct S { short inner_s; };
  40. struct outer_struct {
  41. wchar_t arr[32];
  42. S outer_s;
  43. };
  44. template <class T>
  45. void OpenFileSession() {
  46. // Ensure that we don't think the ImplicitValueInitExpr generated here
  47. // during the initial parse only initializes the first array element!
  48. outer_struct asdfasdf = {};
  49. };
  50. void foo() {
  51. OpenFileSession<int>();
  52. }
  53. }