forked from OSchip/llvm-project
[Sema][NFC] Improve test coverage for builtin operators.
In preparation for D112453.
This commit is contained in:
parent
30f922741a
commit
1427742750
|
@ -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.
|
||||
}
|
||||
|
|
@ -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.
|
||||
}
|
||||
|
|
@ -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
|
|
@ -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}}
|
||||
}
|
||||
|
|
@ -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}}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue