1 // RUN: %clang_cc1 -fsyntax-only -Wno-tautological-pointer-compare -fblocks -std=c++11 -verify %s 2 foo()3void foo() { 4 int a; 5 bool b; 6 7 a = 0 ? nullptr + a : a + nullptr; // expected-error 2{{invalid operands to binary expression}} 8 a = 0 ? nullptr - a : a - nullptr; // expected-error 2{{invalid operands to binary expression}} 9 a = 0 ? nullptr / a : a / nullptr; // expected-error 2{{invalid operands to binary expression}} 10 a = 0 ? nullptr * a : a * nullptr; // expected-error 2{{invalid operands to binary expression}} 11 a = 0 ? nullptr >> a : a >> nullptr; // expected-error 2{{invalid operands to binary expression}} 12 a = 0 ? nullptr << a : a << nullptr; // expected-error 2{{invalid operands to binary expression}} 13 a = 0 ? nullptr % a : a % nullptr; // expected-error 2{{invalid operands to binary expression}} 14 a = 0 ? nullptr & a : a & nullptr; // expected-error 2{{invalid operands to binary expression}} 15 a = 0 ? nullptr | a : a | nullptr; // expected-error 2{{invalid operands to binary expression}} 16 a = 0 ? nullptr ^ a : a ^ nullptr; // expected-error 2{{invalid operands to binary expression}} 17 18 // Using two nullptrs should only give one error instead of two. 19 a = nullptr + nullptr; // expected-error{{invalid operands to binary expression}} 20 a = nullptr - nullptr; // expected-error{{invalid operands to binary expression}} 21 a = nullptr / nullptr; // expected-error{{invalid operands to binary expression}} 22 a = nullptr * nullptr; // expected-error{{invalid operands to binary expression}} 23 a = nullptr >> nullptr; // expected-error{{invalid operands to binary expression}} 24 a = nullptr << nullptr; // expected-error{{invalid operands to binary expression}} 25 a = nullptr % nullptr; // expected-error{{invalid operands to binary expression}} 26 a = nullptr & nullptr; // expected-error{{invalid operands to binary expression}} 27 a = nullptr | nullptr; // expected-error{{invalid operands to binary expression}} 28 a = nullptr ^ nullptr; // expected-error{{invalid operands to binary expression}} 29 30 a += nullptr; // expected-error{{invalid operands to binary expression}} 31 a -= nullptr; // expected-error{{invalid operands to binary expression}} 32 a /= nullptr; // expected-error{{invalid operands to binary expression}} 33 a *= nullptr; // expected-error{{invalid operands to binary expression}} 34 a >>= nullptr; // expected-error{{invalid operands to binary expression}} 35 a <<= nullptr; // expected-error{{invalid operands to binary expression}} 36 a %= nullptr; // expected-error{{invalid operands to binary expression}} 37 a &= nullptr; // expected-error{{invalid operands to binary expression}} 38 a |= nullptr; // expected-error{{invalid operands to binary expression}} 39 a ^= nullptr; // expected-error{{invalid operands to binary expression}} 40 41 b = a < nullptr || nullptr < a; // expected-error 2{{invalid operands to binary expression}} 42 b = a > nullptr || nullptr > a; // expected-error 2{{invalid operands to binary expression}} 43 b = a <= nullptr || nullptr <= a; // expected-error 2{{invalid operands to binary expression}} 44 b = a >= nullptr || nullptr >= a; // expected-error 2{{invalid operands to binary expression}} 45 b = a == nullptr || nullptr == a; // expected-error 2{{invalid operands to binary expression}} 46 b = a != nullptr || nullptr != a; // expected-error 2{{invalid operands to binary expression}} 47 48 b = &a < nullptr || nullptr < &a || &a > nullptr || nullptr > &a; // expected-error 4{{invalid operands}} 49 b = &a <= nullptr || nullptr <= &a || &a >= nullptr || nullptr >= &a; // expected-error 4{{invalid operands}} 50 b = &a == nullptr || nullptr == &a || &a != nullptr || nullptr != &a; 51 52 b = nullptr < nullptr || nullptr > nullptr; // expected-error 2{{invalid operands to binary expression}} 53 b = nullptr <= nullptr || nullptr >= nullptr; // expected-error 2{{invalid operands to binary expression}} 54 b = nullptr == nullptr || nullptr != nullptr; 55 56 b = ((nullptr)) != a; // expected-error{{invalid operands to binary expression}} 57 58 void (^c)(); 59 c = nullptr; 60 b = c == nullptr || nullptr == c || c != nullptr || nullptr != c; 61 62 class X; 63 void (X::*d) (); 64 d = nullptr; 65 b = d == nullptr || nullptr == d || d != nullptr || nullptr != d; 66 67 extern void e(); 68 b = e == nullptr || nullptr == e || e != nullptr || nullptr != e; 69 70 int f[2]; 71 b = f == nullptr || nullptr == f || f != nullptr || nullptr != f; 72 b = "f" == nullptr || nullptr == "f" || "f" != nullptr || nullptr != "f"; 73 } 74