Skip to content

Commit 00dd5fd

Browse files
committed
Add more tests to ensure nothing is broken by subsequent changes.
1 parent 190886d commit 00dd5fd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

clang/test/C/C23/n3037.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,24 @@ void func2(PRODUCT(int, SUM(float, double)) y) { // c17-warning {{declaration of
3030

3131
struct foop { struct { int x; }; }; // c17-note {{previous definition is here}}
3232
struct foop { struct { int x; }; }; // c17-error {{redefinition of 'foop'}}
33+
// Test the field lookup compatibility isn't sufficient, the structure of types should be compatible.
34+
struct AnonymousStructNotMatchingFields { // c17-note {{previous definition is here}}
35+
struct { // c23-note {{field has name '' here}}
36+
int x;
37+
};
38+
};
39+
struct AnonymousStructNotMatchingFields { // c23-error {{type 'struct AnonymousStructNotMatchingFields' has incompatible definitions}} \
40+
c17-error {{redefinition of 'AnonymousStructNotMatchingFields'}}
41+
int x; // c23-note {{field has name 'x' here}}
42+
};
43+
3344
union barp { int x; float y; }; // c17-note {{previous definition is here}}
3445
union barp { int x; float y; }; // c17-error {{redefinition of 'barp'}}
3546
typedef struct q { int x; } q_t; // c17-note 2 {{previous definition is here}}
3647
typedef struct q { int x; } q_t; // c17-error {{redefinition of 'q'}} \
3748
c17-error-re {{typedef redefinition with different types ('struct (unnamed struct at {{.*}})' vs 'struct q')}}
49+
typedef struct { int x; } untagged_q_t; // both-note {{previous definition is here}}
50+
typedef struct { int x; } untagged_q_t; // both-error {{typedef redefinition with different types}}
3851
void func3(void) {
3952
struct S { int x; }; // c17-note {{previous definition is here}}
4053
struct T { struct S s; }; // c17-note {{previous definition is here}}

0 commit comments

Comments
 (0)