File: Wcxx-compat-3.c

package info (click to toggle)
gcc-riscv64-unknown-elf 8.3.0.2019.08%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 680,956 kB
  • sloc: ansic: 3,237,715; cpp: 896,882; ada: 772,854; f90: 144,254; asm: 68,788; makefile: 67,456; sh: 29,743; exp: 28,045; objc: 15,273; fortran: 11,885; python: 7,369; pascal: 5,375; awk: 3,725; perl: 2,872; yacc: 316; xml: 311; ml: 285; lex: 198; haskell: 122
file content (46 lines) | stat: -rw-r--r-- 1,015 bytes parent folder | download | duplicates (10)
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
/* { dg-do compile } */
/* { dg-options "-Wc++-compat" } */
enum E1 { A, B, C };
enum E2 { D, E, F };
extern void f2 (enum E1);

void
f1 ()
{
  int a = A;
  enum E1 e1;
  enum E2 e2;

  f2 (0);	/* { dg-warning "invalid in C\[+\]\[+\]" } */
  f2 (A);
  f2 (D);	/* { dg-warning "invalid in C\[+\]\[+\]" } */
  f2 (a);	/* { dg-warning "invalid in C\[+\]\[+\]" } */
  f2 (e1);
  f2 (e2);	/* { dg-warning "invalid in C\[+\]\[+\]" } */
  f2 ((A));
  f2 (a ? A : B);
  f2 ((enum E1) 0);
  f2 ((enum E1) D);
  f2 ((enum E1) a);
  f2 ((enum E1) e2);
}

struct s1 { enum E1 e1 : 3; };
struct s2 { enum E2 e2 : 3; };

void
f3 (struct s1 sv1, struct s2 sv2)
{
  f2 (sv1.e1);
  f2 (sv2.e2);	/* { dg-warning "invalid in C\[+\]\[+\]" } */
}

void
f4 (struct s1 *pv1, struct s2 *pv2)
{
  f2 (pv1->e1);
  f2 (pv2->e2);	/* { dg-warning "invalid in C\[+\]\[+\]" } */
}

/* Match all extra informative notes.  */
/* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" { target *-*-* } 0 } */