Home | History | Annotate | Download | only in Sema
      1 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -std=c11
      2 
      3 typedef struct S S; // expected-note 4 {{forward declaration of 'struct S'}}
      4 extern _Atomic(S*) e;
      5 void a(S* b, void* c) {
      6   void (*fp)(int) = 0;
      7   b++;       // expected-error {{arithmetic on a pointer to an incomplete type}}
      8   b += 1;    // expected-error {{arithmetic on a pointer to an incomplete type}}
      9   c++;       // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
     10   c += 1;    // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
     11   c--;       // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
     12   c -= 1;    // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
     13   (void) c[1]; // expected-warning {{subscript of a pointer to void is a GNU extension}}
     14   b = 1+b;   // expected-error {{arithmetic on a pointer to an incomplete type}}
     15   /* The next couple tests are only pedantic warnings in gcc */
     16   void (*d)(S*,void*) = a;
     17   d += 1;    // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
     18   d++;       // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
     19   d--;       // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
     20   d -= 1;    // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
     21   (void)(1 + d); // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
     22   e++;       // expected-error {{arithmetic on a pointer to an incomplete type}}
     23 }
     24