13bb8b56aSRichard Trieu // RUN: %clang_cc1 -fsyntax-only -Wno-tautological-pointer-compare -fblocks -std=c++11 -verify %s 2701fb36bSRichard Trieu foo()3e1db1cf0SChandler Carruthvoid foo() { 4701fb36bSRichard Trieu int a; 5701fb36bSRichard Trieu bool b; 6701fb36bSRichard Trieu 7701fb36bSRichard Trieu a = 0 ? nullptr + a : a + nullptr; // expected-error 2{{invalid operands to binary expression}} 8701fb36bSRichard Trieu a = 0 ? nullptr - a : a - nullptr; // expected-error 2{{invalid operands to binary expression}} 9701fb36bSRichard Trieu a = 0 ? nullptr / a : a / nullptr; // expected-error 2{{invalid operands to binary expression}} 10701fb36bSRichard Trieu a = 0 ? nullptr * a : a * nullptr; // expected-error 2{{invalid operands to binary expression}} 11701fb36bSRichard Trieu a = 0 ? nullptr >> a : a >> nullptr; // expected-error 2{{invalid operands to binary expression}} 12701fb36bSRichard Trieu a = 0 ? nullptr << a : a << nullptr; // expected-error 2{{invalid operands to binary expression}} 13701fb36bSRichard Trieu a = 0 ? nullptr % a : a % nullptr; // expected-error 2{{invalid operands to binary expression}} 14701fb36bSRichard Trieu a = 0 ? nullptr & a : a & nullptr; // expected-error 2{{invalid operands to binary expression}} 15701fb36bSRichard Trieu a = 0 ? nullptr | a : a | nullptr; // expected-error 2{{invalid operands to binary expression}} 16701fb36bSRichard Trieu a = 0 ? nullptr ^ a : a ^ nullptr; // expected-error 2{{invalid operands to binary expression}} 17701fb36bSRichard Trieu 18701fb36bSRichard Trieu // Using two nullptrs should only give one error instead of two. 19701fb36bSRichard Trieu a = nullptr + nullptr; // expected-error{{invalid operands to binary expression}} 20701fb36bSRichard Trieu a = nullptr - nullptr; // expected-error{{invalid operands to binary expression}} 21701fb36bSRichard Trieu a = nullptr / nullptr; // expected-error{{invalid operands to binary expression}} 22701fb36bSRichard Trieu a = nullptr * nullptr; // expected-error{{invalid operands to binary expression}} 23701fb36bSRichard Trieu a = nullptr >> nullptr; // expected-error{{invalid operands to binary expression}} 24701fb36bSRichard Trieu a = nullptr << nullptr; // expected-error{{invalid operands to binary expression}} 25701fb36bSRichard Trieu a = nullptr % nullptr; // expected-error{{invalid operands to binary expression}} 26701fb36bSRichard Trieu a = nullptr & nullptr; // expected-error{{invalid operands to binary expression}} 27701fb36bSRichard Trieu a = nullptr | nullptr; // expected-error{{invalid operands to binary expression}} 28701fb36bSRichard Trieu a = nullptr ^ nullptr; // expected-error{{invalid operands to binary expression}} 29701fb36bSRichard Trieu 30701fb36bSRichard Trieu a += nullptr; // expected-error{{invalid operands to binary expression}} 31701fb36bSRichard Trieu a -= nullptr; // expected-error{{invalid operands to binary expression}} 32701fb36bSRichard Trieu a /= nullptr; // expected-error{{invalid operands to binary expression}} 33701fb36bSRichard Trieu a *= nullptr; // expected-error{{invalid operands to binary expression}} 34701fb36bSRichard Trieu a >>= nullptr; // expected-error{{invalid operands to binary expression}} 35701fb36bSRichard Trieu a <<= nullptr; // expected-error{{invalid operands to binary expression}} 36701fb36bSRichard Trieu a %= nullptr; // expected-error{{invalid operands to binary expression}} 37701fb36bSRichard Trieu a &= nullptr; // expected-error{{invalid operands to binary expression}} 38701fb36bSRichard Trieu a |= nullptr; // expected-error{{invalid operands to binary expression}} 39701fb36bSRichard Trieu a ^= nullptr; // expected-error{{invalid operands to binary expression}} 40701fb36bSRichard Trieu 41701fb36bSRichard Trieu b = a < nullptr || nullptr < a; // expected-error 2{{invalid operands to binary expression}} 42701fb36bSRichard Trieu b = a > nullptr || nullptr > a; // expected-error 2{{invalid operands to binary expression}} 43701fb36bSRichard Trieu b = a <= nullptr || nullptr <= a; // expected-error 2{{invalid operands to binary expression}} 44701fb36bSRichard Trieu b = a >= nullptr || nullptr >= a; // expected-error 2{{invalid operands to binary expression}} 45701fb36bSRichard Trieu b = a == nullptr || nullptr == a; // expected-error 2{{invalid operands to binary expression}} 46701fb36bSRichard Trieu b = a != nullptr || nullptr != a; // expected-error 2{{invalid operands to binary expression}} 47701fb36bSRichard Trieu 48*5e9746f5SRichard Smith b = &a < nullptr || nullptr < &a || &a > nullptr || nullptr > &a; // expected-error 4{{invalid operands}} 49*5e9746f5SRichard Smith b = &a <= nullptr || nullptr <= &a || &a >= nullptr || nullptr >= &a; // expected-error 4{{invalid operands}} 50701fb36bSRichard Trieu b = &a == nullptr || nullptr == &a || &a != nullptr || nullptr != &a; 51701fb36bSRichard Trieu 52*5e9746f5SRichard Smith b = nullptr < nullptr || nullptr > nullptr; // expected-error 2{{invalid operands to binary expression}} 53*5e9746f5SRichard Smith b = nullptr <= nullptr || nullptr >= nullptr; // expected-error 2{{invalid operands to binary expression}} 54e1db1cf0SChandler Carruth b = nullptr == nullptr || nullptr != nullptr; 55701fb36bSRichard Trieu 56701fb36bSRichard Trieu b = ((nullptr)) != a; // expected-error{{invalid operands to binary expression}} 57701fb36bSRichard Trieu 58701fb36bSRichard Trieu void (^c)(); 59701fb36bSRichard Trieu c = nullptr; 60701fb36bSRichard Trieu b = c == nullptr || nullptr == c || c != nullptr || nullptr != c; 61701fb36bSRichard Trieu 62701fb36bSRichard Trieu class X; 63701fb36bSRichard Trieu void (X::*d) (); 64701fb36bSRichard Trieu d = nullptr; 65701fb36bSRichard Trieu b = d == nullptr || nullptr == d || d != nullptr || nullptr != d; 66e1db1cf0SChandler Carruth 67e1db1cf0SChandler Carruth extern void e(); 68e1db1cf0SChandler Carruth b = e == nullptr || nullptr == e || e != nullptr || nullptr != e; 69e1db1cf0SChandler Carruth 70e1db1cf0SChandler Carruth int f[2]; 71e1db1cf0SChandler Carruth b = f == nullptr || nullptr == f || f != nullptr || nullptr != f; 72e1db1cf0SChandler Carruth b = "f" == nullptr || nullptr == "f" || "f" != nullptr || nullptr != "f"; 73701fb36bSRichard Trieu } 74