| 1 | // { dg-do compile { target c++11 } } |
| 2 | // { dg-require-cstdint "" } |
| 3 | // { dg-additional-options "-Wsystem-headers" } |
| 4 | // 2008-07-03 Chris Fairles <[email protected]> |
| 5 | |
| 6 | // Copyright (C) 2008-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 |
| 20 | // along with this library; see the file COPYING3. If not see |
| 21 | // <http://www.gnu.org/licenses/>. |
| 22 | |
| 23 | #include <ratio> |
| 24 | |
| 25 | void |
| 26 | test01() |
| 27 | { |
| 28 | std::ratio_add<std::ratio<INTMAX_MAX, 1>, std::ratio<1>>::type r1 |
| 29 | __attribute__((unused)); |
| 30 | } |
| 31 | |
| 32 | void |
| 33 | test02() |
| 34 | { |
| 35 | std::ratio_multiply<std::ratio<-INTMAX_MAX, 2>, std::ratio<3, 2>>::type r1 |
| 36 | __attribute__((unused)); |
| 37 | std::ratio_multiply<std::ratio<INTMAX_MAX>, std::ratio<INTMAX_MAX>>::type r2 |
| 38 | __attribute__((unused)); |
| 39 | } |
| 40 | |
| 41 | // { dg-error "required from here" "" { target *-*-* } 28 } |
| 42 | // { dg-error "expected initializer" "" { target *-*-* } 28 } |
| 43 | // { dg-error "expected initializer" "" { target *-*-* } 35 } |
| 44 | // { dg-error "expected initializer" "" { target *-*-* } 37 } |
| 45 | // { dg-error "overflow in addition" "" { target *-*-* } 0 } |
| 46 | // { dg-error "overflow in multiplication" "" { target *-*-* } 103 } |
| 47 | // { dg-error "overflow in multiplication" "" { target *-*-* } 105 } |
| 48 | // { dg-error "overflow in multiplication" "" { target *-*-* } 107 } |
| 49 | // { dg-error "overflow in constant expression" "" { target *-*-* } 0 } |
| 50 | // { dg-error "narrowing conversion" "" { target *-*-* } 0 } |
| 51 | // { dg-error "overflow in expression" "" { target *-*-* } 114 } |
| 52 | // { dg-prune-output "out of range" } |
| 53 | // { dg-prune-output "not usable in a constant expression" } |