FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.bugs / 900322_01.C
blob48ae6006f10bddf51e62ea69c314ebe48af5e73d
1 // g++ 1.37.1 bug 900322_01
3 // ** Old, obsolete commentary:
4 // **************************************************************************
5 // The ANSI C standard, in section 3.1.2.5 (first paragraph) differentiates
6 // types into three disjoint sets, i.e object types, function types, and
7 // incomplete types.
9 // Also in 3.1.2.5 (page 24) the standard says that the element type of
10 // an array type is an object type.
12 // Later in that same section the standard also notes that array types with
13 // unknown size are considered incomplete types (page 25).  (Struct & union
14 // types which have only been "forward declared" are also incomplete types.)
16 // Some experts infer this to mean that it is not legal to specify or to
17 // construct an array *type* whose element type is an incomplete type.
19 // This interpretation suggests that the statements indicated below contain
20 // errors.
22 // g++ fails to flag all of the indicated statements with errors (even when
23 // the -pedantic option is used).
24 // **************************************************************************
26 // The above commentary is wrong.  (jason 1998/11/13)
27 // In fact, the lines marked OK are well-formed; the prohibition is only
28 // against forming array types with multiple unknown bounds.  This prohibition
29 // is found in 8.3.4 [dcl.array].
31 // It is also ill-formed to create an object of incomplete type.
33 // keywords: incomplete types, arrays, element types
35 extern int extern_two_d [] [];          // ERROR - invalid declaration
36 int tenative_two_d [] [];               // ERROR - caught by g++
37 static int static_two_d [] [];          // ERROR - caught by g++
39 int (*pointer_to_two_d)[][];            // ERROR - invalid declaration
41 void function_0 (int arg [] []) {       // ERROR - invalid declaration
44 typedef int int_one_d_type [];
45 typedef int_one_d_type int_two_d_type[];// ERROR - invalid declaration
47 struct s;
49 extern struct s extern_s_array [10];    // OK
50 struct s tenative_s_array [10];         // ERROR - object with incomplete type
51 static struct s static_s_array [10];    // ERROR - object with incomplete type
53 struct s (*pointer_to_s_array) [];      // OK
55 void function_1 (struct s arg []) {     // OK
58 typedef struct s s_type;
59 typedef s_type s_one_d_type [10];       // OK
61 int main () { return 0; }