Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/g++.dg/ext/temp-extend1.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/g++.dg/ext/temp-extend1.C Thu Feb 13 11:34:05 2020 +0900 @@ -0,0 +1,43 @@ +// PR c++/92831 +// { dg-do run { target c++11 } } +// { dg-options "" } + +template<typename T> using id = T; +struct S { S () : s (false) { ++c; } S (bool x) : s (x) { ++c; } ~S () { --c; }; bool s; static int c; }; +int S::c = 0; + +void +foo (int i) +{ + const bool&& a + = id<S[3]>{false, true, false}[i].s + ? id<S[2]>{true, false}[i].s : id<S[4]>{true, false, true, false}[i].s; + if (S::c != (i ? 2 : 4)) + __builtin_abort (); +} + +void +baz (int i) +{ + const bool&& a = id<S[3]>{false, true, false}[i].s + ? : id<S[4]>{true, false, true, false}[i].s; + if (S::c != (i ? 0 : 4)) + __builtin_abort (); +} + +int +main () +{ + foo (0); + if (S::c != 0) + __builtin_abort (); + foo (1); + if (S::c != 0) + __builtin_abort (); + baz (0); + if (S::c != 0) + __builtin_abort (); + baz (1); + if (S::c != 0) + __builtin_abort (); +}