blob: 667fe9a68c1537953f6ba6e7bdb04af5118ce515 [file] [log] [blame]
Stephen Hines0e2c34f2015-03-23 12:09:02 -07001// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -std=c11
Eli Friedmand72d16e2008-05-18 18:08:51 +00002
Stephen Hines0e2c34f2015-03-23 12:09:02 -07003typedef struct S S; // expected-note 4 {{forward declaration of 'struct S'}}
4extern _Atomic(S*) e;
Eli Friedmand72d16e2008-05-18 18:08:51 +00005void a(S* b, void* c) {
Douglas Gregorc983b862009-01-23 00:36:41 +00006 void (*fp)(int) = 0;
Chandler Carruth13b21be2011-06-27 08:02:19 +00007 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}}
Chandler Carruth66289692011-06-27 16:32:27 +000013 (void) c[1]; // expected-warning {{subscript of a pointer to void is a GNU extension}}
Chandler Carruth13b21be2011-06-27 08:02:19 +000014 b = 1+b; // expected-error {{arithmetic on a pointer to an incomplete type}}
Eli Friedmand72d16e2008-05-18 18:08:51 +000015 /* The next couple tests are only pedantic warnings in gcc */
16 void (*d)(S*,void*) = a;
Chandler Carruth13b21be2011-06-27 08:02:19 +000017 d += 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
18 d++; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
19 d--; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
20 d -= 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
21 (void)(1 + d); // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
Stephen Hines0e2c34f2015-03-23 12:09:02 -070022 e++; // expected-error {{arithmetic on a pointer to an incomplete type}}
Eli Friedmand72d16e2008-05-18 18:08:51 +000023}