2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.bugs / 900520_03.C
blob7978e386abaae10f98517f09fc8b530de003064a
1 // { dg-do assemble  }
2 // g++ 1.37.1 bug 900520_03
4 // The C++ Reference Manual says (in section 8.2.4):
6 //      When an identifier of array type appears in an expression, except
7 //      as the operand of sizeof or & or used to initialize a reference,
8 //      it is converted into a pointer to the first member of the array.
10 // One must assume from the verbage, that when the name of a non-const array
11 // object appears in one of the exempted contexts mentioned in this passage,
12 // that it is *not* automatically converted into a pointer value, but rather
13 // that it remains as an array type value, and that it may therefore also
14 // still be an lvalue, and may be used to initialize references.
16 // As the following code demonstrates, g++ does in fact treat the names
17 // of non-const array objects as valid initializers for reference-to-array
18 // type object in some (but not all) contexts.
20 // The exception is that g++ does not allow names which designate objects
21 // on incomplete array types to be used as actual parameters in function
22 // calls where the corresponding formal parameter is of a reference-to-array
23 // type.
25 // g++ does however allow other similar sorts of initializations of non-formal
26 // reference objects.
28 // 5/16/94 (jason): The 1/25/94 WP explicitly states in section 8.3.5 that
29 // parameter types may not contain pointers or references to arrays of unknown
30 // bound.  g++ is correct.
32 // keywords: reference types, array types, initialization, parameter passing
34 typedef int u_array[];
35 typedef u_array &u_array_ref;
37 void take_u_array_ref (u_array_ref arg) { } // { dg-error "" } reference to array of unknown bound in parmtype
39 extern u_array u_array_gbl_obj;
40 u_array_ref u_array_ref_gbl_obj0 = u_array_gbl_obj;     // OK
42 void test_local_initialization ()
44   u_array_ref u_array_ref_lcl_obj0 = u_array_gbl_obj;   // OK
47 void test_passing ()
49   take_u_array_ref (u_array_gbl_obj);