xref: /llvm-project/clang/test/Sema/complete-incomplete-pointer-relational-c99.c (revision 8c5edb59cf487373e545ccb87ffcd24cb7d0d0ec)
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -Wc11-extensions %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -Wc11-extensions %s
3 
4 int incomplete[]; // expected-warning {{tentative array definition assumed to have one element}}
5 int complete[6];
6 
test_comparison_between_incomplete_and_complete_pointer(void)7 int test_comparison_between_incomplete_and_complete_pointer(void) {
8   return (&incomplete < &complete) &&  // expected-warning {{pointer comparisons before C11 need to be between two complete or two incomplete types; 'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
9          (&incomplete <= &complete) && // expected-warning {{pointer comparisons before C11 need to be between two complete or two incomplete types; 'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
10          (&incomplete > &complete) &&  // expected-warning {{pointer comparisons before C11 need to be between two complete or two incomplete types; 'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
11          (&incomplete >= &complete) && // expected-warning {{pointer comparisons before C11 need to be between two complete or two incomplete types; 'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
12          (&incomplete == &complete) &&
13          (&incomplete != &complete);
14 }
15