delegating-constructors.cpp 708 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
  2. namespace PR10457 {
  3. class string
  4. {
  5. string(const char* str, unsigned);
  6. public:
  7. template <unsigned N>
  8. string(const char (&str)[N])
  9. : string(str) {} // expected-error{{constructor for 'string<6>' creates a delegation cycle}}
  10. };
  11. void f() {
  12. string s("hello");
  13. }
  14. struct Foo {
  15. Foo(int) { }
  16. template <typename T>
  17. Foo(T, int i) : Foo(i) { }
  18. };
  19. void test_Foo()
  20. {
  21. Foo f(1, 1);
  22. }
  23. }
  24. namespace PR12890 {
  25. class Document
  26. {
  27. public:
  28. Document() = default;
  29. template <class T>
  30. explicit
  31. Document(T&& t) : Document()
  32. {
  33. }
  34. };
  35. void f()
  36. {
  37. Document d(1);
  38. }
  39. }