2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.bugs / 900519_03.C
blobb840ee79083a4741360bce5e53d5dddee65f8410
1 // { dg-do assemble  }
2 // g++ 1.37.1 bug 900519_03
4 // The C++ Reference Manual says (in section 8.4.3) "A reference to a 
5 // volatile T can be initialized with a volatile T or a plain T but not a
6 // const T.  A reference to a const T can be initialized with a const T or
7 // a plain T or something that can be converted into a plain T, but not a
8 // volatile T."
10 // g++ fails to disgnose such errors in most cases.
12 // keywords: references, initialization, type qualifiers
14 extern const int cint_obj;
15 extern volatile int vint_obj;
17 void take_cint_ref (const int& arg) { } // { dg-error "" } 
18 void take_vint_ref (volatile int& arg) { } // { dg-error "" } 
20 const int& global_cint_ref2 = vint_obj;         // { dg-error "" } 
22 volatile int& global_vint_ref1 = cint_obj;      // { dg-error "" } 
24 extern const int& extern_cint_ref;
25 extern volatile int& extern_vint_ref;
27 void test_0 ()
29   const int& local_cint_ref2 = vint_obj;        // { dg-error "" } 
31   volatile int& local_vint_ref1 = cint_obj;     // { dg-error "" } 
32
34 void test_1 ()
36   take_cint_ref (vint_obj);                     // { dg-error "" } 
38   take_vint_ref (cint_obj);                     // { dg-error "" } caught
41 void test_2 ()
43   take_cint_ref (extern_vint_ref);              // { dg-error "" } 
45   take_vint_ref (extern_cint_ref);              // { dg-error "" } 
48 int main () { return 0; }