[clang] 45b84a5 - [Sema][NFC] Improve test coverage for builtin binary operators.
Clement Courbet via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 3 07:51:47 PDT 2021
Author: Clement Courbet
Date: 2021-11-03T15:51:35+01:00
New Revision: 45b84a547efe8991b28883c73efa2de798dc2c30
URL: https://github.com/llvm/llvm-project/commit/45b84a547efe8991b28883c73efa2de798dc2c30
DIFF: https://github.com/llvm/llvm-project/commit/45b84a547efe8991b28883c73efa2de798dc2c30.diff
LOG: [Sema][NFC] Improve test coverage for builtin binary operators.
In preparation for D112453.
Added:
clang/test/CXX/over/over.built/p13.cpp
clang/test/CXX/over/over.built/p14.cpp
Modified:
clang/test/CXX/over/over.built/p7-ast.cpp
Removed:
################################################################################
diff --git a/clang/test/CXX/over/over.built/p13.cpp b/clang/test/CXX/over/over.built/p13.cpp
new file mode 100644
index 000000000000..de57130386e8
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p13.cpp
@@ -0,0 +1,40 @@
+// 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*i);
+ (void)(i*f);
+ (void)(i*b);
+ (void)(i*c);
+ (void)(i*pi); // expected-error {{invalid operands to binary expression}}
+ (void)(i*pt); // FIXME
+
+ (void)(i/i);
+ (void)(i/f);
+ (void)(i/b);
+ (void)(i/c);
+ (void)(i/pi); // expected-error {{invalid operands to binary expression}}
+ (void)(i/pt); // FIXME
+
+ (void)(i-i);
+ (void)(i-f);
+ (void)(i-b);
+ (void)(i-c);
+ (void)(i-pi); // expected-error {{invalid operands to binary expression}}
+ (void)(i-pt); // FIXME
+
+ (void)(i<i);
+ (void)(i<f);
+ (void)(i<b);
+ (void)(i<c);
+ (void)(i<pi); // expected-error {{comparison between pointer and integer}}
+ (void)(i<pt); // FIXME
+
+ (void)(i==i);
+ (void)(i==f);
+ (void)(i==b);
+ (void)(i==c);
+ (void)(i==pi); // expected-error {{comparison between pointer and integer}}
+ (void)(i==pt); // FIXME
+}
+
diff --git a/clang/test/CXX/over/over.built/p14.cpp b/clang/test/CXX/over/over.built/p14.cpp
new file mode 100644
index 000000000000..ac9ba97e5357
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p14.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+template <typename T>
+void f(int* pi, T* pt) {
+ (void)(pi+3);
+ (void)(3+pi);
+ (void)(pi-3);
+ (void)(pi[3]);
+ (void)(3[pi]);
+
+ (void)(pt+3);
+ (void)(3+pt);
+ (void)(pt-3);
+ (void)(pt[3]);
+ (void)(3[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
index 9f501a496fea..f3c44cff3951 100644
--- a/clang/test/CXX/over/over.built/p7-ast.cpp
+++ b/clang/test/CXX/over/over.built/p7-ast.cpp
@@ -6,7 +6,25 @@ template <typename T>
auto Test(T* pt) {
// CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '*'
// CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
- return *pt;
+ (void)*pt;
+
+ // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '++'
+ // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+ (void)(++pt);
+
+ // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '+'
+ // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+ (void)(+pt);
+
+ // CHECK: BinaryOperator {{.*}} '<dependent type>' '+'
+ // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+ // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 3
+ (void)(pt + 3);
+
+ // CHECK: BinaryOperator {{.*}} '<dependent type>' '-'
+ // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+ // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+ (void)(pt -pt);
}
More information about the cfe-commits
mailing list