annotate gcc/testsuite/g++.old-deja/g++.bugs/900322_01.C @ 145:1830386684a0

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