xref: /llvm-project/clang/test/SemaObjCXX/null_objc_pointer.mm (revision 5e9746f520e6bbeafc36b8a23585b2e6117e1a7a)
1fc51bc1cSRichard Trieu// RUN: %clang_cc1 -fsyntax-only -verify -Wnull-arithmetic %s
2701fb36bSRichard Trieu#define NULL __null
3701fb36bSRichard Trieu
4701fb36bSRichard Trieu@interface X
5701fb36bSRichard Trieu@end
6701fb36bSRichard Trieu
7701fb36bSRichard Trieuvoid f() {
8701fb36bSRichard Trieu  bool b;
9701fb36bSRichard Trieu  X *d;
10*5e9746f5SRichard Smith  b = d < NULL || NULL < d || d > NULL || NULL > d; // expected-error 4{{ordered comparison between pointer and zero}}
11*5e9746f5SRichard Smith  b = d <= NULL || NULL <= d || d >= NULL || NULL >= d; // expected-error 4{{ordered comparison between pointer and zero}}
12701fb36bSRichard Trieu  b = d == NULL || NULL == d || d != NULL || NULL != d;
13701fb36bSRichard Trieu}
14