Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/constexpr-inst1.C

raw
1 // Test that we don't uselessly instantiate f<A> immediately while parsing g.
2 // Doing so is permitted by the standard, but has no benefit and breaks code
3 // unnecessarily.
4
5 // { dg-do compile { target c++11 } }
6
7 // -O activates the call to maybe_constant_value in cp_fold.
8 // { dg-additional-options -O }
9
10 template <class T>
11 constexpr int f (const T* p) { return p->i; }
12
13 constexpr int g(const struct A* p) { return f(p); }
14
15 struct A { int i; };
16
17 // Instantiating f<A> at EOF works fine.