Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp0x/addressof2.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
6 addressof (T &x) noexcept | 6 addressof (T &x) noexcept |
7 { | 7 { |
8 return __builtin_addressof (x); | 8 return __builtin_addressof (x); |
9 } | 9 } |
10 | 10 |
11 auto a = __builtin_addressof (1); // { dg-error "lvalue required as unary" } | 11 auto a = __builtin_addressof (1); // { dg-error "31:lvalue required as unary" } |
12 auto b = addressof (1); // { dg-error "cannot bind non-const lvalue reference of type" } | 12 auto b = addressof (1); // { dg-error "21:cannot bind non-const lvalue reference of type" } |
13 | 13 |
14 struct S { int s : 5; int t; void foo (); } s; | 14 struct S { int s : 5; int t; void foo (); } s; |
15 | 15 |
16 auto c = __builtin_addressof (s); | 16 auto c = __builtin_addressof (s); |
17 auto d = addressof (s); | 17 auto d = addressof (s); |
18 auto e = __builtin_addressof (s.s); // { dg-error "attempt to take address of bit-field" } | 18 auto e = __builtin_addressof (s.s); // { dg-error "33:attempt to take address of bit-field" } |
19 auto f = addressof (s.s); // { dg-error "cannot bind bitfield" } | 19 auto f = addressof (s.s); // { dg-error "23:cannot bind bit-field" } |
20 auto g = __builtin_addressof (S{}); // { dg-error "taking address of rvalue" } | 20 auto g = __builtin_addressof (S{}); // { dg-error "31:taking address of rvalue" } |
21 auto h = addressof (S{}); // { dg-error "cannot bind non-const lvalue reference of type" } | 21 auto h = addressof (S{}); // { dg-error "21:cannot bind non-const lvalue reference of type" } |
22 auto i = __builtin_addressof (S::t); // { dg-error "invalid use of non-static data member" } | 22 auto i = __builtin_addressof (S::t); // { dg-error "34:invalid use of non-static data member" } |
23 auto j = __builtin_addressof (S::foo); // { dg-error "invalid use of non-static member function" } | 23 auto j = __builtin_addressof (S::foo); // { dg-error "34:invalid use of non-static member function" } |
24 | 24 |
25 void | 25 void |
26 foo (bool b) | 26 foo (bool b) |
27 { | 27 { |
28 lab:; | 28 lab:; |
29 char c; | 29 char c; |
30 long long int d; | 30 long long int d; |
31 auto k = __builtin_addressof (lab); // { dg-error "was not declared in this scope" } | 31 auto k = __builtin_addressof (lab); // { dg-error "33:.lab. was not declared in this scope" } |
32 auto l = __builtin_addressof (b ? c : d); // { dg-error "lvalue required as unary" } | 32 auto l = __builtin_addressof (b ? c : d); // { dg-error "35:lvalue required as unary" } |
33 } | 33 } |