| 1 |
// { dg-do assemble } |
| 2 |
// g++ 1.37.1 bug 900519_02 |
| 3 |
|
| 4 |
// The C++ Reference Manual says (in section 8.4.3) "A reference to a plain |
| 5 |
// T can only be initialized with a plain T" however g++ allows the |
| 6 |
// initialization of plain references with qualified objects in many cases. |
| 7 |
|
| 8 |
// keywords: references, initialization, type qualifiers |
| 9 |
|
| 10 |
extern const int cint_obj = 9; |
| 11 |
volatile int vint_obj = 9; |
| 12 |
|
| 13 |
void take_int_ref (int& arg) { } // { dg-message "" } referenced by errors below |
| 14 |
|
| 15 |
int& global_int_ref0 = cint_obj; // { dg-error "" } |
| 16 |
int& global_int_ref1 = vint_obj; // { dg-error "" } |
| 17 |
|
| 18 |
extern const int& cint_ref; |
| 19 |
extern volatile int& vint_ref; |
| 20 |
|
| 21 |
void test_0 () |
| 22 |
{ |
| 23 |
int& local_int_ref0 = cint_obj; // { dg-error "" } |
| 24 |
int& local_int_ref1 = vint_obj; // { dg-error "" } |
| 25 |
|
| 26 |
take_int_ref (cint_obj); // { dg-error "" } caught |
| 27 |
take_int_ref (vint_obj); // { dg-error "" } |
| 28 |
|
| 29 |
take_int_ref (cint_ref); // { dg-error "" } |
| 30 |
take_int_ref (vint_ref); // { dg-error "" } |
| 31 |
} |
| 32 |
|
| 33 |
int main () { return 0; } |