| 1 | // { dg-options "-O2" } |
| 2 | // { dg-do run { target c++11 } } |
| 3 | // { dg-require-normal-mode "" } |
| 4 | // { dg-require-effective-target cxx11_abi } |
| 5 | |
| 6 | // Copyright (C) 2015-2025 Free Software Foundation, Inc. |
| 7 | // |
| 8 | // This file is part of the GNU ISO C++ Library. This library is free |
| 9 | // software; you can redistribute it and/or modify it under the |
| 10 | // terms of the GNU General Public License as published by the |
| 11 | // Free Software Foundation; either version 3, or (at your option) |
| 12 | // any later version. |
| 13 | |
| 14 | // This library is distributed in the hope that it will be useful, |
| 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | // GNU General Public License for more details. |
| 18 | |
| 19 | // You should have received a copy of the GNU General Public License along |
| 20 | // with this library; see the file COPYING3. If not see |
| 21 | // <http://www.gnu.org/licenses/>. |
| 22 | |
| 23 | #include <list> |
| 24 | #include <iterator> |
| 25 | #include <testsuite_hooks.h> |
| 26 | |
| 27 | __attribute__((__noinline__, __noclone__)) |
| 28 | void testm(std::list<short>& l) |
| 29 | { |
| 30 | bool b = std::distance(l.begin(), l.end()) == l.size(); |
| 31 | VERIFY( __builtin_constant_p(b) ); |
| 32 | VERIFY( b ); |
| 33 | } |
| 34 | |
| 35 | __attribute__((__noinline__, __noclone__)) |
| 36 | void testc(const std::list<short>& l) |
| 37 | { |
| 38 | bool b = std::distance(l.begin(), l.end()) == l.size(); |
| 39 | VERIFY( __builtin_constant_p(b) ); |
| 40 | VERIFY( b ); |
| 41 | } |
| 42 | |
| 43 | int main() |
| 44 | { |
| 45 | #if ! __NO_INLINE__ |
| 46 | std::list<short> l; |
| 47 | testm(l); |
| 48 | testc(l); |
| 49 | #endif |
| 50 | } |