annotate gcc/testsuite/g++.dg/cpp0x/addressof2.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // LWG2296 - addressof should be constexpr
kono
parents:
diff changeset
2 // { dg-do compile { target c++11 } }
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 template <typename T>
kono
parents:
diff changeset
5 constexpr inline T *
kono
parents:
diff changeset
6 addressof (T &x) noexcept
kono
parents:
diff changeset
7 {
kono
parents:
diff changeset
8 return __builtin_addressof (x);
kono
parents:
diff changeset
9 }
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 auto a = __builtin_addressof (1); // { dg-error "lvalue required as unary" }
kono
parents:
diff changeset
12 auto b = addressof (1); // { dg-error "cannot bind non-const lvalue reference of type" }
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 struct S { int s : 5; int t; void foo (); } s;
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 auto c = __builtin_addressof (s);
kono
parents:
diff changeset
17 auto d = addressof (s);
kono
parents:
diff changeset
18 auto e = __builtin_addressof (s.s); // { dg-error "attempt to take address of bit-field" }
kono
parents:
diff changeset
19 auto f = addressof (s.s); // { dg-error "cannot bind bitfield" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
20 auto g = __builtin_addressof (S{}); // { dg-error "taking address of rvalue" }
111
kono
parents:
diff changeset
21 auto h = addressof (S{}); // { dg-error "cannot bind non-const lvalue reference of type" }
kono
parents:
diff changeset
22 auto i = __builtin_addressof (S::t); // { dg-error "invalid use of non-static data member" }
kono
parents:
diff changeset
23 auto j = __builtin_addressof (S::foo); // { dg-error "invalid use of non-static member function" }
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 void
kono
parents:
diff changeset
26 foo (bool b)
kono
parents:
diff changeset
27 {
kono
parents:
diff changeset
28 lab:;
kono
parents:
diff changeset
29 char c;
kono
parents:
diff changeset
30 long long int d;
kono
parents:
diff changeset
31 auto k = __builtin_addressof (lab); // { dg-error "was not declared in this scope" }
kono
parents:
diff changeset
32 auto l = __builtin_addressof (b ? c : d); // { dg-error "lvalue required as unary" }
kono
parents:
diff changeset
33 }