brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 48bc8fb Raw
73 lines · cpp
1// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx2a %s2// RUN: %clang_cc1 -std=c++23 -verify=expected %s3 4// p3: if the function is a constructor or destructor, its class shall not have5// any virtual base classes;6namespace vbase {7  struct A {};8  struct B : virtual A { // expected-note {{virtual}}9    constexpr ~B() {} // expected-error {{constexpr member function not allowed in struct with virtual base class}}10  };11}12 13namespace contents {14  struct A {15    constexpr ~A() {16      return;17      goto x; // cxx2a-warning {{use of this statement in a constexpr function is a C++23 extension}}18      x: ;19    }20  };21  struct B {22    constexpr ~B() {23    x:; // cxx2a-warning {{use of this statement in a constexpr function is a C++23 extension}}24    }25  };26  struct Nonlit { // cxx2a-note {{'Nonlit' is not literal because}}27    Nonlit();28  };29  struct C {30    constexpr ~C() {31      return;32      Nonlit nl; // cxx2a-error {{variable of non-literal type 'Nonlit' cannot be defined in a constexpr function before C++23}}33    }34  };35  struct D {36    constexpr ~D() {37      return;38      static int a; // cxx2a-warning {{definition of a static variable in a constexpr function is a C++23 extension}}39    }40  };41  struct E {42    constexpr ~E() {43      return;44      thread_local int e; // cxx2a-warning {{definition of a thread_local variable in a constexpr function is a C++23 extension}}45    }46  };47  struct F {48    constexpr ~F() {49      return;50      extern int f;51    }52  };53}54 55// p5: for every subobject of class type or (possibly multi-dimensional) array56// thereof, that class type shall have a constexpr destructor57namespace subobject {58  struct A {59    ~A();60  };61  struct B : A { // cxx2a-note {{here}}62    constexpr ~B() {} // cxx2a-error {{destructor cannot be declared constexpr because base class 'A' does not have a constexpr destructor}}63  };64  struct C {65    A a; // cxx2a-note {{here}}66    constexpr ~C() {} // cxx2a-error {{destructor cannot be declared constexpr because data member 'a' does not have a constexpr destructor}}67  };68  struct D : A {69    A a;70    constexpr ~D() = delete;71  };72}73