view gcc/testsuite/g++.dg/cpp0x/constexpr-builtin2.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// PR c++/54021
// { dg-do compile { target c++11 } }

extern int nonconst_func(int);
constexpr int identity(int x) { return x; }
constexpr int zero() { return identity(0); }
constexpr int one() { return identity(1); }

// These are the same.  Only the latter is accepted, though.
constexpr int rejected_const_4(int x)
{ return __builtin_constant_p(x) ? 4 : nonconst_func(x); }
constexpr int accepted_const_4(int x)
{ return identity(__builtin_constant_p(x)) ? 4 : nonconst_func(x); }

// This is rejected.  I would like it to work.
constexpr int four = accepted_const_4(1);