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