Bug 1814798 - pt 1. Add bool to enable/disable PHC at runtime r=glandium
[gecko.git] / build / clang-plugin / tests / TestNoArithmeticExprInArgument.cpp
blobd147b170125f92629809aa1125b37aa28708c692
1 #define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT __attribute__((annotate("moz_no_arith_expr_in_arg")))
3 struct X {
4 explicit X(int) MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT;
5 void baz(int) MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT;
6 };
8 int operator+(int, X);
9 int operator+(X, int);
10 int operator++(X);
12 void badArithmeticsInArgs() {
13 int a = 1;
14 typedef int myint;
15 myint b = 2;
16 X goodObj1(a);
17 goodObj1.baz(b);
18 X badObj1(a + b); // expected-error{{cannot pass an arithmetic expression of built-in types to 'X'}}
19 X badObj2 = X(a ? 0 : ++a); // expected-error{{cannot pass an arithmetic expression of built-in types to 'X'}}
20 X badObj3(~a); // expected-error{{cannot pass an arithmetic expression of built-in types to 'X'}}
21 badObj1.baz(a - 1 - b); // expected-error{{cannot pass an arithmetic expression of built-in types to 'baz'}}
22 badObj1.baz(++a); // expected-error{{cannot pass an arithmetic expression of built-in types to 'baz'}}
23 badObj1.baz(a++); // expected-error{{cannot pass an arithmetic expression of built-in types to 'baz'}}
24 badObj1.baz(a || b);
25 badObj1.baz(a + goodObj1);
26 badObj1.baz(goodObj1 + a);
27 badObj1.baz(++goodObj1);
28 badObj1.baz(-1);
29 badObj1.baz(-1.0);
30 badObj1.baz(1 + 2);
31 badObj1.baz(1 << (sizeof(int)/2));