summaryrefslogtreecommitdiffstats
path: root/build/clang-plugin/tests/TestNoArithmeticExprInArgument.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /build/clang-plugin/tests/TestNoArithmeticExprInArgument.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'build/clang-plugin/tests/TestNoArithmeticExprInArgument.cpp')
-rw-r--r--build/clang-plugin/tests/TestNoArithmeticExprInArgument.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/build/clang-plugin/tests/TestNoArithmeticExprInArgument.cpp b/build/clang-plugin/tests/TestNoArithmeticExprInArgument.cpp
new file mode 100644
index 000000000..d147b1701
--- /dev/null
+++ b/build/clang-plugin/tests/TestNoArithmeticExprInArgument.cpp
@@ -0,0 +1,32 @@
+#define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT __attribute__((annotate("moz_no_arith_expr_in_arg")))
+
+struct X {
+ explicit X(int) MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT;
+ void baz(int) MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT;
+};
+
+int operator+(int, X);
+int operator+(X, int);
+int operator++(X);
+
+void badArithmeticsInArgs() {
+ int a = 1;
+ typedef int myint;
+ myint b = 2;
+ X goodObj1(a);
+ goodObj1.baz(b);
+ X badObj1(a + b); // expected-error{{cannot pass an arithmetic expression of built-in types to 'X'}}
+ X badObj2 = X(a ? 0 : ++a); // expected-error{{cannot pass an arithmetic expression of built-in types to 'X'}}
+ X badObj3(~a); // expected-error{{cannot pass an arithmetic expression of built-in types to 'X'}}
+ badObj1.baz(a - 1 - b); // expected-error{{cannot pass an arithmetic expression of built-in types to 'baz'}}
+ badObj1.baz(++a); // expected-error{{cannot pass an arithmetic expression of built-in types to 'baz'}}
+ badObj1.baz(a++); // expected-error{{cannot pass an arithmetic expression of built-in types to 'baz'}}
+ badObj1.baz(a || b);
+ badObj1.baz(a + goodObj1);
+ badObj1.baz(goodObj1 + a);
+ badObj1.baz(++goodObj1);
+ badObj1.baz(-1);
+ badObj1.baz(-1.0);
+ badObj1.baz(1 + 2);
+ badObj1.baz(1 << (sizeof(int)/2));
+}