brintos

brintos / llvm-project-archived public Read only

0
0
Text · 706 B · 57cb42e Raw
31 lines · cpp
1// RUN: %clang_cc1 -std=c++14 -verify=both,expected %s -fexperimental-new-constant-interpreter2// RUN: %clang_cc1 -std=c++14 -verify=both,ref      %s3 4 5 6constexpr int(*null_ptr)() = nullptr;7constexpr int test4 = (*null_ptr)(); // both-error {{must be initialized by a constant expression}} \8                                     // both-note {{evaluates to a null function pointer}}9 10struct E {11  int n = 0;12  struct {13    void *x = this;14  };15  void *y = this;16};17constexpr E e1 = E();18static_assert(e1.x != e1.y, "");19constexpr E e2 = E{0};20static_assert(e2.x != e2.y, "");21 22struct S {23  int &&a = 2;24  int b[1]{a};25};26constexpr int foo() {27  S s{12};28  return s.b[0];29}30static_assert(foo() == 12, "");31