brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 31c691b Raw
76 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++11 %s2 3namespace MissingOnTemplate {4  template<typename T> void foo(T) noexcept(true); // expected-note {{previous}}5  template<typename T> void foo(T); // expected-error {{missing exception specification 'noexcept(true)'}}6  void test() { foo(0); }7}8 9struct UseBeforeComplete1 {10  ~UseBeforeComplete1(); // expected-note {{previous}}11  struct X {12    friend UseBeforeComplete1::~UseBeforeComplete1() noexcept; // expected-warning {{previously declared with an implicit}}13  };14};15 16struct ThrowingDtor { ~ThrowingDtor() noexcept(false); };17struct UseBeforeComplete2 {18  ~UseBeforeComplete2(); // expected-note {{previous}}19  struct X {20    friend UseBeforeComplete2::~UseBeforeComplete2() noexcept; // expected-error {{does not match previous}}21  };22  ThrowingDtor td;23};24 25struct UseBeforeComplete3 {26  ~UseBeforeComplete3();27  struct X {28    friend UseBeforeComplete3::~UseBeforeComplete3(); // ok, implicitly noexcept(true)29  };30};31static_assert(noexcept(UseBeforeComplete3()), "");32 33struct UseBeforeComplete4 {34  ~UseBeforeComplete4();35  struct X {36    friend UseBeforeComplete4::~UseBeforeComplete4(); // ok, implicitly noexcept(false)37  };38  ThrowingDtor td;39};40static_assert(!noexcept(UseBeforeComplete4()), "");41 42namespace AssignmentOp {43  struct D1;44  struct D2;45  struct B {46    B &operator=(const B&);47    virtual D1 &operator=(const D1&) noexcept; // expected-note {{overridden}}48    virtual D2 &operator=(const D2&) noexcept; // expected-note {{overridden}}49  };50  struct D1 : B {}; // expected-error {{more lax}}51  struct D2 : B {52    D2 &operator=(const D2&); // expected-error {{more lax}}53  };54}55 56namespace OverloadedFunctions {57 58template <typename T>59void f(T&) noexcept;60 61template <typename T, int N>62void f(T (&arr)[N]) noexcept(noexcept(f(*arr)));63 64template <typename T>65inline void f(T&) noexcept {}66 67template <typename T, int N>68inline void f(T (&arr)[N]) noexcept(noexcept(f(*arr))) {}69 70void g() {71    int x[1];72    f(x);73}74 75}76