brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 11bc423 Raw
124 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-deprecated-builtins2 3namespace rdar12240916 {4 5struct S2 {6  S2(const S2&);7  S2();8};9 10struct S { // expected-note {{not complete}}11  S x; // expected-error {{incomplete type}}12  S2 y;13};14 15S foo() {16  S s;17  return s;18}19 20struct S3; // expected-note {{forward declaration}}21 22struct S4 {23  S3 x; // expected-error {{incomplete type}}24  S2 y;25};26 27struct S3 {28  S4 x;29  S2 y;30};31 32S4 foo2() {33  S4 s;34  return s;35}36 37}38 39namespace rdar12542261 {40 41template <class _Tp>42struct check_complete43{44  static_assert(sizeof(_Tp) > 0, "Type must be complete.");45};46 47 48template<class _Rp>49class function // expected-note 2 {{candidate}}50{51public:52  template<class _Fp>53  function(_Fp, typename check_complete<_Fp>::type* = 0);  // expected-note {{candidate}}54};55 56void foobar()57{58  auto LeftCanvas = new Canvas(); // expected-error {{unknown type name}}59  function<void()> m_OnChange = [&, LeftCanvas]() { }; // expected-error {{no viable conversion}}60}61 62}63 64namespace b6981007 {65  struct S {}; // expected-note 3{{candidate}}66  void f() {67    S s(1, 2, 3); // expected-error {{no matching}}68    for (auto x : s) {69      // We used to attempt to evaluate the initializer of this variable,70      // and crash because it has an undeduced type.71      const int &n(x);72      constexpr int k = sizeof(x);73    }74  }75}76 77namespace incorrect_auto_type_deduction_for_typo {78struct S {79  template <typename T> S(T t) {80    (void)sizeof(t);81    (void)new auto(t);82  }83};84 85void Foo(S);86 87void test(int some_number) {  // expected-note {{'some_number' declared here}}88  auto x = sum_number;  // expected-error {{use of undeclared identifier 'sum_number'; did you mean 'some_number'?}}89  auto lambda = [x] {};90  Foo(lambda);91}92}93 94namespace pr29091 {95  struct X{ X(const X &x); };96  struct Y: X { using X::X; };97  bool foo() { return __has_nothrow_constructor(Y); }98  bool bar() { return __has_nothrow_copy(Y); }99 100  struct A { template <typename T> A(); };101  struct B : A { using A::A; };102  bool baz() { return __has_nothrow_constructor(B); }103  bool qux() { return __has_nothrow_copy(B); }104}105 106namespace undeduced_field {107template<class T>108struct Foo {109  typedef T type;110};111 112struct Bar {113  Bar();114  // The missing expression makes A undeduced.115  static constexpr auto A = ;  // expected-error {{expected expression}}116                               // expected-error@-1 {{declaration of variable 'A' with deduced type 'const auto' requires an initializer}}117 118  Foo<decltype(A)>::type B;  // The type of B is also undeduced (wrapped in Elaborated).119};120 121// This used to crash when trying to get the layout of B.122Bar x;123}124