File tree Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 1+ // RUN: %clang_cc1 -verify -std=c2y %s
2+ // RUN: %clang_cc1 -verify -std=c23 %s
3+ // RUN: %clang_cc1 -verify -std=c17 %s
4+ // RUN: %clang_cc1 -verify -std=c11 %s
5+ // RUN: %clang_cc1 -verify -std=c99 %s
6+ // RUN: %clang_cc1 -verify -std=c89 %s
7+
8+ /* WG14 N3532: Yes
9+ * Member access of an incomplete object
10+ *
11+ * Verify that the first operand to the . or -> operators is a complete object
12+ * type.
13+ */
14+
15+ struct S {
16+ int i ;
17+ };
18+
19+ union U {
20+ int i ;
21+ };
22+
23+ void good_test (void ) {
24+ struct S s ;
25+ struct S * s_ptr = & s ;
26+ union U u ;
27+ union U * u_ptr = & u ;
28+
29+ // Complete object type, correctly named member.
30+ s .i = 10 ;
31+ s_ptr -> i = 10 ;
32+ u .i = 10 ;
33+ u_ptr -> i = 10 ;
34+ }
35+
36+ void bad_test (void ) {
37+ struct Incomplete * s_ptr ; /* expected-note 2 {{forward declaration of 'struct Incomplete'}} */
38+ union AlsoIncomplete * u_ptr ; /* expected-note 2 {{forward declaration of 'union AlsoIncomplete'}} */
39+ struct S s ;
40+ union U u ;
41+
42+ // Incomplete object type.
43+ s_ptr -> i = 10 ; /* expected-error {{incomplete definition of type 'struct Incomplete'}} */
44+ u_ptr -> i = 10 ; /* expected-error {{incomplete definition of type 'union AlsoIncomplete'}} */
45+
46+ (* s_ptr ).i = 10 ; /* expected-error {{incomplete definition of type 'struct Incomplete'}} */
47+ (* u_ptr ).i = 10 ; /* expected-error {{incomplete definition of type 'union AlsoIncomplete'}} */
48+
49+ // Complete object type, no named member.
50+ s .f = "test" ; /* expected-error {{no member named 'f' in 'struct S'}} */
51+ u .f = "test" ; /* expected-error {{no member named 'f' in 'union U'}} */
52+ }
53+
Original file line number Diff line number Diff line change @@ -359,7 +359,7 @@ <h2 id="c2y">C2y implementation status</h2>
359359 < tr >
360360 < td > Member access of an incomplete object</ td >
361361 < td > < a href ="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3532.pdf "> N3532</ a > </ td >
362- < td class ="unknown " align ="center "> Unknown </ td >
362+ < td class ="full " align ="center "> Yes </ td >
363363 </ tr >
364364 < tr >
365365 < td > Representation of Pointers and nullptr_t</ td >
You can’t perform that action at this time.
0 commit comments