view gcc/testsuite/g++.dg/cpp2a/nontype-class1.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line source

// { dg-do compile { target c++2a } }
// { dg-additional-options "-fdelete-null-pointer-checks" }

struct A
{
  int i;
  constexpr A (int i): i(i) {}
  // auto operator<=> (const A&) = default;
};

template <A a>
struct B
{
  static constexpr int i = a.i;
  static constexpr A const* ap = &a;
};

template <A a>
struct C
{
  static constexpr A const* ap = &a;
};

static_assert(B<1>::i == 1);
static_assert(B<2>::i == 2);
static_assert(B<1>::ap == C<1>::ap);
static_assert(B<1>::ap != C<2>::ap);

// { dg-final { scan-assembler "_Z1fP1BIXtl1ALi1EEEE" } }
// { dg-final { scan-assembler "_ZTAXtl1ALi1EEE" } }
const void* f(B<1> *p) {
  constexpr int i = p->ap->i;
  return p->ap;
}