2
0

dr9xx.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
  2. // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
  3. // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
  4. // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
  5. #if __cplusplus < 201103L
  6. // expected-no-diagnostics
  7. #endif
  8. namespace std {
  9. __extension__ typedef __SIZE_TYPE__ size_t;
  10. template<typename T> struct initializer_list {
  11. const T *p; size_t n;
  12. initializer_list(const T *p, size_t n);
  13. };
  14. }
  15. namespace dr990 { // dr990: 3.5
  16. #if __cplusplus >= 201103L
  17. struct A { // expected-note 2{{candidate}}
  18. A(std::initializer_list<int>); // expected-note {{candidate}}
  19. };
  20. struct B {
  21. A a;
  22. };
  23. B b1 { };
  24. B b2 { 1 }; // expected-error {{no viable conversion from 'int' to 'dr990::A'}}
  25. B b3 { { 1 } };
  26. struct C {
  27. C();
  28. C(int);
  29. C(std::initializer_list<int>) = delete; // expected-note {{here}}
  30. };
  31. C c1[3] { 1 }; // ok
  32. C c2[3] { 1, {2} }; // expected-error {{call to deleted}}
  33. struct D {
  34. D();
  35. D(std::initializer_list<int>);
  36. D(std::initializer_list<double>);
  37. };
  38. D d{};
  39. #endif
  40. }
  41. namespace dr948 { // dr948: 3.7
  42. #if __cplusplus >= 201103L
  43. class A {
  44. public:
  45. constexpr A(int v) : v(v) { }
  46. constexpr operator int() const { return v; }
  47. private:
  48. int v;
  49. };
  50. constexpr int id(int x)
  51. {
  52. return x;
  53. }
  54. void f() {
  55. if (constexpr int i = id(101)) { }
  56. switch (constexpr int i = id(2)) { default: break; case 2: break; }
  57. for (; constexpr int i = id(0); ) { }
  58. while (constexpr int i = id(0)) { }
  59. if (constexpr A i = 101) { }
  60. switch (constexpr A i = 2) { default: break; case 2: break; }
  61. for (; constexpr A i = 0; ) { }
  62. while (constexpr A i = 0) { }
  63. }
  64. #endif
  65. }