aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/diag-aka-1.c
blob: fde4ca7c74312e75931e52e1849b8254bde2cc21 (plain)
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
/* { dg-do compile } */
/* { dg-options "-Wc++-compat" } */

typedef struct A { int i; } B;
typedef struct T { int i; } T;
typedef const float TFA;
typedef TFA TFB;
typedef TFB TFC;
typedef int IA[];
typedef IA *IAP;
extern IAP arr[];

void fn1 (B *); /* { dg-message "expected 'B \\*' {aka 'struct A \\*'} but argument is of type 'struct B \\*'" } */
void fn2 (TFC *);

void 
bar (B *b, int *i)
{
  fn1 ((struct B *) b); /* { dg-warning "passing argument" } */
  fn2 (i); /* { dg-warning "passing argument" } */
  sizeof (arr); /* { dg-error "invalid application of .sizeof. to incomplete type .int \\(\\*\\\[\\\]\\)\\\[\\\]." } */
}

int
foo (void *a)
{
  T *t = a; /* { dg-warning "request for implicit conversion from 'void \\*' to 'T \\*' {aka 'struct T \\*'} not" } */
  return t->i;
}