File: c23-tag-1.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (67 lines) | stat: -rw-r--r-- 1,622 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * { dg-do compile }
 * { dg-options "-std=c23" }
 */

// allowed and forbidden redefinitions of the same struct/union in the same scope

typedef struct p { int a; } pd_t;
typedef struct p { int a; } pd_t;

typedef struct bar { int x; } X;
typedef struct bar { float x; } Y; /* { dg-error "redefinition of struct or union" } */

void test(void)
{
	struct foo { int x; };
	struct foo { float x; }; /* { dg-error "redefinition of struct or union" } */
}

struct aa { int a; };

void f(void)
{
	typedef struct aa A;
	struct bb { struct aa a; } x;
	struct aa { int a; };
	typedef struct aa A;		/* { dg-error "redefinition" } */
	struct bb { struct aa a; } y; /* { dg-error "redefinition of struct or union" } */
	(void)x; (void)y;
}



void h(void)
{
	struct a2 { int a; };
	{
		typedef struct a2 A;
		struct b2 { struct a2 a; } x;
		struct a2 { int a; };
		typedef struct a2 A;		/* { dg-error "redefinition" } */
		struct b2 { struct a2 a; } y; /* { dg-error "redefinition of struct or union" } */
		(void)x; (void)y;
	}
}


union cc { int x; float y; } z;
union cc { int x; float y; } z1;
union cc { float y; int x; } z2;	/* { dg-error "redefinition of struct or union" } */

void g(void)
{
	struct s { int a; };
	struct s { int a; } x0;
	struct p { struct s c; } y1 = { x0 };
	struct p { struct s { int a; } c; } y = { x0 };
}

struct q { struct { int a; }; }; 
struct q { struct { int a; }; }; 
struct q { int a; };  /* { dg-error "redefinition of struct or union" } */

struct r { int a; char b[]; };
struct r { int a; char b[]; };
struct r { int a; char b[1]; }; /* { dg-error "redefinition of struct or union" } */