| 1 | // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors |
| 2 | // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors |
| 3 | // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors |
| 4 | // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors |
| 5 | |
| 6 | namespace dr1213 { // dr1213: 7 |
| 7 | #if __cplusplus >= 201103L |
| 8 | using T = int[3]; |
| 9 | int &&r = T{}[1]; |
| 10 | |
| 11 | using T = decltype((T{})); |
| 12 | using U = decltype((T{}[2])); |
| 13 | using U = int &&; |
| 14 | |
| 15 | // Same thing but in a case where we consider overloaded operator[]. |
| 16 | struct ConvertsToInt { |
| 17 | operator int(); |
| 18 | }; |
| 19 | struct X { int array[1]; }; |
| 20 | using U = decltype(X().array[ConvertsToInt()]); |
| 21 | |
| 22 | // We apply the same rule to vector subscripting. |
| 23 | typedef int V4Int __attribute__((__vector_size__(sizeof(int) * 4))); |
| 24 | typedef int EV4Int __attribute__((__ext_vector_type__(4))); |
| 25 | using U = decltype(V4Int()[0]); |
| 26 | using U = decltype(EV4Int()[0]); |
| 27 | #endif |
| 28 | } |
| 29 | |
| 30 | namespace dr1250 { // dr1250: 3.9 |
| 31 | struct Incomplete; |
| 32 | |
| 33 | struct Base { |
| 34 | virtual const Incomplete *meow() = 0; |
| 35 | }; |
| 36 | |
| 37 | struct Derived : Base { |
| 38 | virtual Incomplete *meow(); |
| 39 | }; |
| 40 | } |
| 41 | |
| 42 | namespace dr1265 { // dr1265: 5 |
| 43 | #if __cplusplus >= 201103L |
| 44 | auto a = 0, b() -> int; // expected-error {{declaration with trailing return type must be the only declaration in its group}} |
| 45 | auto b() -> int, d = 0; // expected-error {{declaration with trailing return type must be the only declaration in its group}} |
| 46 | auto e() -> int, f() -> int; // expected-error {{declaration with trailing return type must be the only declaration in its group}} |
| 47 | #endif |
| 48 | |
| 49 | #if __cplusplus >= 201402L |
| 50 | auto g(), h = 0; // expected-error {{function with deduced return type must be the only declaration in its group}} |
| 51 | auto i = 0, j(); // expected-error {{function with deduced return type must be the only declaration in its group}} |
| 52 | auto k(), l(); // expected-error {{function with deduced return type must be the only declaration in its group}} |
| 53 | #endif |
| 54 | } |
| 55 | |
| 56 | namespace dr1295 { // dr1295: 4 |
| 57 | struct X { |
| 58 | unsigned bitfield : 4; |
| 59 | }; |
| 60 | |
| 61 | X x = {1}; |
| 62 | |
| 63 | unsigned const &r1 = static_cast<X &&>(x).bitfield; // expected-error 0-1{{C++11}} |
| 64 | unsigned const &r2 = static_cast<unsigned &&>(x.bitfield); // expected-error 0-1{{C++11}} |
| 65 | |
| 66 | template<unsigned &r> struct Y {}; |
| 67 | Y<x.bitfield> y; |
| 68 | #if __cplusplus <= 201402L |
| 69 | // expected-error@-2 {{does not refer to any declaration}} expected-note@-3 {{here}} |
| 70 | #else |
| 71 | // expected-error@-4 {{refers to subobject}} |
| 72 | #endif |
| 73 | |
| 74 | #if __cplusplus >= 201103L |
| 75 | const unsigned other = 0; |
| 76 | using T = decltype(true ? other : x.bitfield); |
| 77 | using T = unsigned; |
| 78 | #endif |
| 79 | } |
| 80 | |
| 81 | |