Mercurial > hg > CbC > CbC_gcc
comparison 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 |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 // PR c++/92831 | |
2 // { dg-do run { target c++11 } } | |
3 // { dg-options "" } | |
4 | |
5 template<typename T> using id = T; | |
6 struct S { S () : s (false) { ++c; } S (bool x) : s (x) { ++c; } ~S () { --c; }; bool s; static int c; }; | |
7 int S::c = 0; | |
8 | |
9 void | |
10 foo (int i) | |
11 { | |
12 const bool&& a | |
13 = id<S[3]>{false, true, false}[i].s | |
14 ? id<S[2]>{true, false}[i].s : id<S[4]>{true, false, true, false}[i].s; | |
15 if (S::c != (i ? 2 : 4)) | |
16 __builtin_abort (); | |
17 } | |
18 | |
19 void | |
20 baz (int i) | |
21 { | |
22 const bool&& a = id<S[3]>{false, true, false}[i].s | |
23 ? : id<S[4]>{true, false, true, false}[i].s; | |
24 if (S::c != (i ? 0 : 4)) | |
25 __builtin_abort (); | |
26 } | |
27 | |
28 int | |
29 main () | |
30 { | |
31 foo (0); | |
32 if (S::c != 0) | |
33 __builtin_abort (); | |
34 foo (1); | |
35 if (S::c != 0) | |
36 __builtin_abort (); | |
37 baz (0); | |
38 if (S::c != 0) | |
39 __builtin_abort (); | |
40 baz (1); | |
41 if (S::c != 0) | |
42 __builtin_abort (); | |
43 } |