summaryrefslogtreecommitdiffstats
path: root/build/clang-plugin/tests/TestNoArithmeticExprInArgument.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /build/clang-plugin/tests/TestNoArithmeticExprInArgument.cpp
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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 0000000000..d147b17012
--- /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));
+}