[clang] 1427742 - [Sema][NFC] Improve test coverage for builtin operators.
Clement Courbet via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 3 05:33:10 PDT 2021
Author: Clement Courbet
Date: 2021-11-03T13:32:48+01:00
New Revision: 1427742750ed1fcd2ead639c4ec5178fc34c9257
URL: https://github.com/llvm/llvm-project/commit/1427742750ed1fcd2ead639c4ec5178fc34c9257
DIFF: https://github.com/llvm/llvm-project/commit/1427742750ed1fcd2ead639c4ec5178fc34c9257.diff
LOG: [Sema][NFC] Improve test coverage for builtin operators.
In preparation for D112453.
Added:
clang/test/CXX/over/over.built/p10.cpp
clang/test/CXX/over/over.built/p11.cpp
clang/test/CXX/over/over.built/p24.cpp
clang/test/CXX/over/over.built/p4.cpp
clang/test/CXX/over/over.built/p5.cpp
clang/test/CXX/over/over.built/p6.cpp
clang/test/CXX/over/over.built/p7-ast.cpp
clang/test/CXX/over/over.built/p7.cpp
clang/test/CXX/over/over.built/p8.cpp
clang/test/CXX/over/over.built/p9.cpp
Modified:
Removed:
################################################################################
diff --git a/clang/test/CXX/over/over.built/p10.cpp b/clang/test/CXX/over/over.built/p10.cpp
new file mode 100644
index 0000000000000..678056da58205
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p10.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+struct A{};
+
+template <typename T>
+void f(int i, float f, bool b, char c, int* pi, A* pa, T* pt) {
+ (void)+i;
+ (void)-i;
+ (void)+f;
+ (void)-f;
+ (void)+b;
+ (void)-b;
+ (void)+c;
+ (void)-c;
+
+ (void)-pi; // expected-error {{invalid argument type}}
+ (void)-pa; // expected-error {{invalid argument type}}
+ (void)-pt; // FIXME: we should be able to give an error here.
+}
+
diff --git a/clang/test/CXX/over/over.built/p11.cpp b/clang/test/CXX/over/over.built/p11.cpp
new file mode 100644
index 0000000000000..7ebf16b95439f
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p11.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+template <typename T>
+void f(int i, float f, bool b, char c, int* pi, T* pt) {
+ (void)~i;
+ (void)~f; // expected-error {{invalid argument type}}
+ (void)~b;
+ (void)~c;
+ (void)~pi; // expected-error {{invalid argument type}}
+ (void)~pt; // FIXME: we should be able to give an error here.
+}
+
diff --git a/clang/test/CXX/over/over.built/p24.cpp b/clang/test/CXX/over/over.built/p24.cpp
new file mode 100644
index 0000000000000..3c48dcd9aa673
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p24.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+template <typename T>
+void f(int i, float f, bool b, char c, int* pi, T* pt) {
+ (void)!i;
+ (void)!f;
+ (void)!b;
+ (void)!c;
+ (void)!pi;
+ (void)!pt;
+}
+// expected-no-diagnostics
diff --git a/clang/test/CXX/over/over.built/p4.cpp b/clang/test/CXX/over/over.built/p4.cpp
new file mode 100644
index 0000000000000..d7cd99c68d6a2
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p4.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s -Wno-tautological-compare
+
+void f(int i, bool b) {
+ (void)++i;
+ (void)i++;
+
+ (void)++b; // expected-error {{ISO C++17 does not allow incrementing expression of type bool}}
+ (void)b++; // expected-error {{ISO C++17 does not allow incrementing expression of type bool}}
+}
+
diff --git a/clang/test/CXX/over/over.built/p5.cpp b/clang/test/CXX/over/over.built/p5.cpp
new file mode 100644
index 0000000000000..4ba32564e9ad8
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p5.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+void f(int i, bool b) {
+ (void)--i;
+ (void)i--;
+
+ (void)--b; // expected-error {{cannot decrement expression of type bool}}
+ (void)b--; // expected-error {{cannot decrement expression of type bool}}
+}
+
diff --git a/clang/test/CXX/over/over.built/p6.cpp b/clang/test/CXX/over/over.built/p6.cpp
new file mode 100644
index 0000000000000..ca81c9aecce86
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p6.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+struct A{};
+
+template <typename T>
+void f(int* pi, A* pa, T* pt) {
+ (void)++pi;
+ (void)pi++;
+ (void)--pi;
+ (void)pi--;
+
+ (void)++pa;
+ (void)pa++;
+ (void)--pa;
+ (void)pa--;
+
+ (void)++pt;
+ (void)pt++;
+ (void)--pt;
+ (void)pt--;
+}
+// expected-no-diagnostics
+
diff --git a/clang/test/CXX/over/over.built/p7-ast.cpp b/clang/test/CXX/over/over.built/p7-ast.cpp
new file mode 100644
index 0000000000000..9f501a496fea8
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p7-ast.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++17 -ast-dump %s -ast-dump-filter Test | FileCheck %s
+
+struct A{};
+
+template <typename T>
+auto Test(T* pt) {
+ // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '*'
+ // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+ return *pt;
+}
+
+
diff --git a/clang/test/CXX/over/over.built/p7.cpp b/clang/test/CXX/over/over.built/p7.cpp
new file mode 100644
index 0000000000000..348c4cdf37830
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p7.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+struct A{};
+
+template <typename T>
+void f(int* pi, A* pa, T* pt) {
+ (void)*pi;
+ (void)*pa;
+ (void)*pt;
+}
+// expected-no-diagnostics
+
diff --git a/clang/test/CXX/over/over.built/p8.cpp b/clang/test/CXX/over/over.built/p8.cpp
new file mode 100644
index 0000000000000..7e34ea3a217f4
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p8.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+template <typename T>
+void f(void(*pf)(), T(*ptf)(T)) {
+ (void)*pf;
+ (void)*ptf;
+}
+// expected-no-diagnostics
+
diff --git a/clang/test/CXX/over/over.built/p9.cpp b/clang/test/CXX/over/over.built/p9.cpp
new file mode 100644
index 0000000000000..7c981e73d4cd3
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p9.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+struct A{};
+
+template <typename T>
+void f(int* pi, A* pa, T* pt) {
+ (void)+pi;
+ (void)+pa;
+ (void)+pt;
+}
+// expected-no-diagnostics
+
More information about the cfe-commits
mailing list