summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2009-11-05 17:18:09 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2009-11-05 17:18:09 +0000
commit8f57cb0305232cb53fff00ef151ca716766f3437 (patch)
tree8b316eca843681b024034db1125707173b9adb4a /test
parent51fb8b013e7734b795139f49d3b1f77c539be20a (diff)
Notes
Diffstat (limited to 'test')
-rw-r--r--test/Analysis/misc-ps.m4
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp6
-rw-r--r--test/CodeGenCXX/array-construction.cpp3
-rw-r--r--test/CodeGenCXX/ptr-to-datamember.cpp13
-rw-r--r--test/CodeGenCXX/ptr-to-member-function.cpp18
-rw-r--r--test/CodeGenCXX/virt.cpp112
-rw-r--r--test/Coverage/html-diagnostics.c6
-rw-r--r--test/Frontend/dependency-gen.c4
-rw-r--r--test/Makefile12
-rw-r--r--test/Parser/if-scope-c90.c2
-rw-r--r--test/Parser/if-scope-c99.c2
-rw-r--r--test/Preprocessor/stdint.c376
-rw-r--r--test/Sema/compare.c20
-rw-r--r--test/Sema/conditional-expr.c19
-rw-r--r--test/SemaCXX/compare.cpp15
-rw-r--r--test/SemaCXX/conditional-expr.cpp22
-rw-r--r--test/SemaCXX/constructor-initializer.cpp33
-rw-r--r--test/SemaCXX/overload-member-call.cpp12
-rw-r--r--test/SemaCXX/overloaded-operator.cpp11
-rw-r--r--test/SemaCXX/primary-base.cpp4
-rw-r--r--test/SemaTemplate/example-dynarray.cpp2
-rw-r--r--test/SemaTemplate/instantiate-complete.cpp21
-rw-r--r--test/SemaTemplate/instantiate-deeply.cpp16
-rw-r--r--test/SemaTemplate/instantiate-expr-1.cpp27
-rw-r--r--test/SemaTemplate/member-access-expr.cpp17
-rw-r--r--test/SemaTemplate/member-template-access-expr.cpp10
-rw-r--r--test/SemaTemplate/temp_arg_nontype.cpp30
-rw-r--r--test/SemaTemplate/template-id-expr.cpp17
-rw-r--r--test/lit.cfg6
30 files changed, 580 insertions, 263 deletions
diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m
index 947b41ae794cc..80e20c1ebb00c 100644
--- a/test/Analysis/misc-ps.m
+++ b/test/Analysis/misc-ps.m
@@ -121,12 +121,12 @@ void check_zero_sized_VLA(int x) {
if (x)
return;
- int vla[x]; // expected-warning{{Declare variable-length array (VLA) of zero size}}
+ int vla[x]; // expected-warning{{Declared variable-length array (VLA) has zero size}}
}
void check_uninit_sized_VLA() {
int x;
- int vla[x]; // expected-warning{{Declare variable-length array (VLA) of undefined size}}
+ int vla[x]; // expected-warning{{Declared variable-length array (VLA) uses a garbage value as its size}}
}
// sizeof(void)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index a83a1993c8f04..8b3c738ed78b9 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -45,6 +45,7 @@ if(PYTHONINTERP_FOUND)
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
COMMAND ${PYTHON_EXECUTABLE}
${LLVM_SOURCE_DIR}/utils/lit/lit.py
+ --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-sv ${CLANG_TEST_EXTRA_ARGS}
${CMAKE_CURRENT_BINARY_DIR}/${testdir}
DEPENDS clang clang-cc index-test c-index-test
@@ -63,6 +64,7 @@ if(PYTHONINTERP_FOUND)
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
COMMAND ${PYTHON_EXECUTABLE}
${LLVM_SOURCE_DIR}/utils/lit/lit.py
+ --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-sv ${CLANG_TEST_EXTRA_ARGS}
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS clang clang-cc index-test c-index-test
@@ -80,6 +82,7 @@ if(PYTHONINTERP_FOUND)
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
COMMAND ${PYTHON_EXECUTABLE}
${LLVM_SOURCE_DIR}/utils/lit/lit.py
+ --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-sv ${CLANG_TEST_EXTRA_ARGS}
${CMAKE_CURRENT_SOURCE_DIR}/../utils/C++Tests
DEPENDS clang clang-cc index-test c-index-test
diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp
index 63e5c3cd27b0a..31218c41300f5 100644
--- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp
+++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp
@@ -7,6 +7,6 @@ struct A {
};
struct B : A {
- using A::f<double>; // expected-error{{using declaration can not refer to template specialization}}
- using A::X<int>; // expected-error{{using declaration can not refer to template specialization}}
-}; \ No newline at end of file
+ using A::f<double>; // expected-error{{using declaration can not refer to a template specialization}}
+ using A::X<int>; // expected-error{{using declaration can not refer to a template specialization}}
+};
diff --git a/test/CodeGenCXX/array-construction.cpp b/test/CodeGenCXX/array-construction.cpp
index b444221533d31..5b6bc2e5b5114 100644
--- a/test/CodeGenCXX/array-construction.cpp
+++ b/test/CodeGenCXX/array-construction.cpp
@@ -17,12 +17,9 @@ public:
int i;
float f;
-/**
- NYI
~xpto() {
printf("xpto::~xpto()\n");
}
-*/
};
int main() {
diff --git a/test/CodeGenCXX/ptr-to-datamember.cpp b/test/CodeGenCXX/ptr-to-datamember.cpp
index a7b4cc2f7afb9..ffaef32a13c9c 100644
--- a/test/CodeGenCXX/ptr-to-datamember.cpp
+++ b/test/CodeGenCXX/ptr-to-datamember.cpp
@@ -32,6 +32,15 @@ public:
F Af;
};
+template <typename T> struct TT {
+ int T::t::*pti;
+};
+
+struct I {
+ typedef I t;
+ int x;
+};
+
void pr(const F& b) {
printf(" %d %f\n", b.iF, b.fF);
}
@@ -69,9 +78,12 @@ void test_aggr_pdata_1(A* pa) {
int main()
{
A a1;
+ TT<I> tt;
+ I i;
int A::* pa = &A::Ai;
float A::* pf = &A::f;
double A::* pd = &A::d;
+ tt.pti = &I::x;
printf("%d %d %d\n", &A::Ai, &A::f, &A::d);
printf("%d\n", &A::B::iB);
printf("%d\n", &A::B1::iB1);
@@ -81,6 +93,7 @@ int main()
printf("%d\n", &A::B::V::iV);
printf("%d\n", &A::B1::V::iV);
printf("%d, %f, %f \n", a1.*pa, a1.*pf, a1.*pd);
+ printf("%d\n", i.*tt.pti);
test_aggr_pdata(a1);
test_aggr_pdata_1(&a1);
}
diff --git a/test/CodeGenCXX/ptr-to-member-function.cpp b/test/CodeGenCXX/ptr-to-member-function.cpp
index 1e396e976575d..15019081c0620 100644
--- a/test/CodeGenCXX/ptr-to-member-function.cpp
+++ b/test/CodeGenCXX/ptr-to-member-function.cpp
@@ -9,8 +9,14 @@ extern "C" int printf(...);
struct A {
int Ai;
+bool foo(int* arg) const;
};
+bool A::foo(int* arg) const {
+ printf("A::foo(%d)\n", *arg);
+ return true;
+}
+
struct B : public A {
void bf() { printf("B::bf called\n"); }
};
@@ -40,10 +46,22 @@ void test2(X x)
g(x);
}
+struct B1 {
+ bool (A::*pmf)(int*) const;
+
+ B1(int i) : pmf(&A::foo), im(i) {
+ ((A*)this->*pmf)(&im);
+ }
+
+ int im;
+};
+
int main()
{
X x;
test2(x);
+ B1 b = B1(1);
+ B1 c = B1(2);
}
// CHECK-LP64: call __ZN1XcvM1BFvvEEv
diff --git a/test/CodeGenCXX/virt.cpp b/test/CodeGenCXX/virt.cpp
index 7911940c6dabd..193a96ddd5897 100644
--- a/test/CodeGenCXX/virt.cpp
+++ b/test/CodeGenCXX/virt.cpp
@@ -48,9 +48,11 @@ public:
void F::foo() { }
int j;
+void *vp;
void test2() {
F f;
static int sz = (char *)(&f.f) - (char *)(&f);
+ vp = &sz;
j = sz;
// FIXME: These should result in a frontend constant a la fold, no run time
// initializer
@@ -91,50 +93,6 @@ int main() {
// CHECK-LP64: movl $1, 12(%rax)
// CHECK-LP64: movl $2, 8(%rax)
-// FIXME: This is the wrong thunk, but until these issues are fixed, better
-// than nothing.
-// CHECK-LP64: __ZTcvn16_n72_v16_n32_N8test16_D4foo1Ev:
-// CHECK-LP64-NEXT:Leh_func_begin43:
-// CHECK-LP64-NEXT: subq $24, %rsp
-// CHECK-LP64-NEXT:Llabel43:
-// CHECK-LP64-NEXT: movq %rdi, %rax
-// CHECK-LP64-NEXT: movq %rax, 8(%rsp)
-// CHECK-LP64-NEXT: movq 8(%rsp), %rax
-// CHECK-LP64-NEXT: movq %rax, %rcx
-// CHECK-LP64-NEXT: movabsq $-16, %rdx
-// CHECK-LP64-NEXT: addq %rdx, %rcx
-// CHECK-LP64-NEXT: movq -16(%rax), %rax
-// CHECK-LP64-NEXT: movq -72(%rax), %rax
-// CHECK-LP64-NEXT: addq %rax, %rcx
-// CHECK-LP64-NEXT: movq %rcx, %rax
-// CHECK-LP64-NEXT: movq %rax, %rdi
-// CHECK-LP64-NEXT: call __ZTch0_v16_n32_N8test16_D4foo1Ev
-// CHECK-LP64-NEXT: movq %rax, 16(%rsp)
-// CHECK-LP64-NEXT: movq 16(%rsp), %rax
-// CHECK-LP64-NEXT: addq $24, %rsp
-// CHECK-LP64-NEXT: ret
-
-// CHECK-LP64: __ZTch0_v16_n32_N8test16_D4foo1Ev:
-// CHECK-LP64-NEXT:Leh_func_begin44:
-// CHECK-LP64-NEXT: subq $24, %rsp
-// CHECK-LP64-NEXT:Llabel44:
-// CHECK-LP64-NEXT: movq %rdi, %rax
-// CHECK-LP64-NEXT: movq %rax, 8(%rsp)
-// CHECK-LP64-NEXT: movq 8(%rsp), %rax
-// CHECK-LP64-NEXT: movq %rax, %rdi
-// CHECK-LP64-NEXT: call __ZN8test16_D4foo1Ev
-// CHECK-LP64-NEXT: movq %rax, %rcx
-// CHECK-LP64-NEXT: movabsq $16, %rdx
-// CHECK-LP64-NEXT: addq %rdx, %rcx
-// CHECK-LP64-NEXT: movq 16(%rax), %rax
-// CHECK-LP64-NEXT: movq -32(%rax), %rax
-// CHECK-LP64-NEXT: addq %rax, %rcx
-// CHECK-LP64-NEXT: movq %rcx, %rax
-// CHECK-LP64-NEXT: movq %rax, 16(%rsp)
-// CHECK-LP64-NEXT: movq 16(%rsp), %rax
-// CHECK-LP64-NEXT: addq $24, %rsp
-// CHECK-LP64-NEXT: ret
-
struct test12_A {
virtual void foo0() { }
virtual void foo();
@@ -207,6 +165,7 @@ void test12_foo() {
// CHECK-LPOPT64-NEXT: movq _test12_pa(%rip), %rdi
// CHECK-LPOPT64-NEXT: call __ZN8test12_A3fooEv
+
struct test6_B2 { virtual void funcB2(); char b[1000]; };
struct test6_B1 : virtual test6_B2 { virtual void funcB1(); };
@@ -1003,9 +962,12 @@ virtual void foo_B2() { }
};
struct test16_D : test16_NV1, virtual test16_B2 {
- virtual test16_D *foo1() { return 0; }
+ virtual void bar();
+ virtual test16_D *foo1();
};
+void test16_D::bar() { }
+
// CHECK-LP64: __ZTV8test16_D:
// CHECK-LP64-NEXT: .quad 32
// CHECK-LP64-NEXT: .quad 16
@@ -1013,6 +975,7 @@ struct test16_D : test16_NV1, virtual test16_B2 {
// CHECK-LP64-NEXT: .quad __ZTI8test16_D
// CHECK-LP64-NEXT: .quad __ZN10test16_NV16fooNV1Ev
// CHECK-LP64-NEXT: .quad __ZN10test16_NV17foo_NV1Ev
+// CHECK-LP64-NEXT: .quad __ZN8test16_D3barEv
// CHECK-LP64-NEXT: .quad __ZN8test16_D4foo1Ev
// CHECK-LP64-NEXT: .space 8
// CHECK-LP64-NEXT: .space 8
@@ -1056,6 +1019,7 @@ struct test16_D : test16_NV1, virtual test16_B2 {
// CHECK-LP32-NEXT: .long __ZTI8test16_D
// CHECK-LP32-NEXT: .long __ZN10test16_NV16fooNV1Ev
// CHECK-LP32-NEXT: .long __ZN10test16_NV17foo_NV1Ev
+// CHECK-LP32-NEXT: .long __ZN8test16_D3barEv
// CHECK-LP32-NEXT: .long __ZN8test16_D4foo1Ev
// CHECK-LP32-NEXT: .space 4
// CHECK-LP32-NEXT: .space 4
@@ -1093,6 +1057,37 @@ struct test16_D : test16_NV1, virtual test16_B2 {
// CHECK-LP32-NEXT: .long __ZN10test16_NV28foo_NV2bEv
+// FIXME: This is the wrong thunk, but until these issues are fixed, better
+// than nothing.
+// CHECK-LPOPT64: __ZTcvn16_n72_v16_n32_N8test16_D4foo1Ev:
+// CHECK-LPOPT64-NEXT:Leh_func_begin
+// CHECK-LPOPT64-NEXT: subq $8, %rsp
+// CHECK-LPOPT64-NEXT:Llabel
+// CHECK-LPOPT64-NEXT: movq -16(%rdi), %rax
+// CHECK-LPOPT64-NEXT: movq -72(%rax), %rax
+// CHECK-LPOPT64-NEXT: leaq -16(%rax,%rdi), %rdi
+// FIXME: We want a tail call here
+// CHECK-LPOPT64-NEXT: call __ZTch0_v16_n32_N8test16_D4foo1Ev
+// CHECK-LPOPT64-NEXT: addq $8, %rsp
+// CHECK-LPOPT64-NEXT: ret
+
+// CHECK-LPOPT64: __ZTch0_v16_n32_N8test16_D4foo1Ev:
+// CHECK-LPOPT64-NEXT:Leh_func_begin
+// CHECK-LPOPT64-NEXT: subq $8, %rsp
+// CHECK-LPOPT64-NEXT:Llabel
+// CHECK-LPOPT64-NEXT: call __ZN8test16_D4foo1Ev
+// CHECK-LPOPT64-NEXT: testq %rax, %rax
+// CHECK-LPOPT64-NEXT: je LBB102_2
+// CHECK-LPOPT64-NEXT: movq 16(%rax), %rcx
+// CHECK-LPOPT64-NEXT: movq -32(%rcx), %rcx
+// CHECK-LPOPT64-NEXT: leaq 16(%rcx,%rax), %rax
+// CHECK-LPOPT64-NEXT: addq $8, %rsp
+// CHECK-LPOPT64-NEXT: ret
+// CHECK-LPOPT64-NEXT:LBB102_2:
+// CHECK-LPOPT64-NEXT: addq $8, %rsp
+// CHECK-LPOPT64-NEXT: ret
+
+
class test17_B1 {
virtual void foo() = 0;
virtual void bar() { }
@@ -1237,6 +1232,33 @@ struct test19_D : virtual test19_B4 {
// CHECK-LP64-NEXT .quad __ZN9test19_B43fB4Ev
+class test20_V {
+ virtual void foo1();
+};
+class test20_V1 {
+ virtual void foo2();
+};
+class test20_B : virtual test20_V {
+} b;
+class test20_B1 : virtual test20_V1 {
+};
+class test20_D : public test20_B, public test20_B1 {
+} d;
+
+// CHECK-LP64: __ZTV8test20_D:
+// CHECK-LP64-NEXT: .quad 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad __ZTI8test20_D
+// CHECK-LP64-NEXT: .quad __ZN8test20_V4foo1Ev
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad 18446744073709551608
+// CHECK-LP64-NEXT: .quad __ZTI8test20_D
+// CHECK-LP64-NEXT: .quad __ZN9test20_V14foo2Ev
+
+
// CHECK-LP64: __ZTV1B:
// CHECK-LP64-NEXT: .space 8
diff --git a/test/Coverage/html-diagnostics.c b/test/Coverage/html-diagnostics.c
index e3db1668d8363..55376d0e440e0 100644
--- a/test/Coverage/html-diagnostics.c
+++ b/test/Coverage/html-diagnostics.c
@@ -1,5 +1,9 @@
// RUN: rm -rf %t &&
-// RUN: clang-cc --html-diags=%t -checker-cfref %s
+// RUN: clang-cc -analyze -analyzer-output=html -checker-cfref -o %t %s &&
+// RUN: cat %t/*.html | FileCheck %s
+
+// CHECK: <h3>Annotated Source Code</h3>
+// CHECK: Dereference of null pointer
void f0(int x) {
int *p = &x;
diff --git a/test/Frontend/dependency-gen.c b/test/Frontend/dependency-gen.c
index 953869912bbbf..458d8d58b2ee1 100644
--- a/test/Frontend/dependency-gen.c
+++ b/test/Frontend/dependency-gen.c
@@ -1,8 +1,8 @@
// rdar://6533411
-// RUN: clang -MD -MF %t.d -c -x c -o %t.o %s &&
+// RUN: clang -MD -MF %t.d -S -x c -o %t.o %s &&
// RUN: grep '.*dependency-gen.*:' %t.d &&
// RUN: grep 'dependency-gen.c' %t.d &&
-// RUN: clang -M -x c %s -o %t.d &&
+// RUN: clang -S -M -x c %s -o %t.d &&
// RUN: grep '.*dependency-gen.*:' %t.d &&
// RUN: grep 'dependency-gen.c' %t.d
diff --git a/test/Makefile b/test/Makefile
index fdb9d8f713d94..b7cb38af8af05 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -11,6 +11,9 @@ endif
# 'lit' wants objdir paths, so it will pick up the lit.site.cfg.
TESTDIRS := $(TESTDIRS:$(PROJ_SRC_DIR)%=$(PROJ_OBJ_DIR)%)
+# Allow EXTRA_TESTDIRS to provide additional test directories.
+TESTDIRS += $(EXTRA_TESTDIRS)
+
ifndef TESTARGS
ifdef VERBOSE
TESTARGS = -v
@@ -19,16 +22,17 @@ TESTARGS = -s
endif
endif
+# Make sure any extra test suites can find the main site config.
+LIT_ARGS := --param clang_site_config=$(PROJ_OBJ_DIR)/lit.site.cfg
+
ifdef VG
- VGARG="--vg"
-else
- VGARG=
+ LIT_ARGS += "--vg"
endif
all:: lit.site.cfg
@ echo '--- Running clang tests for $(TARGET_TRIPLE) ---'
@ $(PYTHON) $(LLVM_SRC_ROOT)/utils/lit/lit.py \
- $(TESTARGS) $(TESTDIRS) $(VGARG)
+ $(LIT_ARGS) $(TESTARGS) $(TESTDIRS)
FORCE:
diff --git a/test/Parser/if-scope-c90.c b/test/Parser/if-scope-c90.c
index fdc75e9f10b0f..53987dccbc37f 100644
--- a/test/Parser/if-scope-c90.c
+++ b/test/Parser/if-scope-c90.c
@@ -2,7 +2,7 @@
int f (int z)
{
- if (z > sizeof (enum {a, b}))
+ if (z > (int) sizeof (enum {a, b}))
return a;
return b;
}
diff --git a/test/Parser/if-scope-c99.c b/test/Parser/if-scope-c99.c
index 37cd0e15ab8e4..b4cb51ca8c4f1 100644
--- a/test/Parser/if-scope-c99.c
+++ b/test/Parser/if-scope-c99.c
@@ -2,7 +2,7 @@
int f (int z)
{
- if (z > sizeof (enum {a, b}))
+ if (z > (int) sizeof (enum {a, b}))
return a;
return b; // expected-error{{use of undeclared identifier}}
}
diff --git a/test/Preprocessor/stdint.c b/test/Preprocessor/stdint.c
index e292bd3ec7e5a..d47b51dbc7b72 100644
--- a/test/Preprocessor/stdint.c
+++ b/test/Preprocessor/stdint.c
@@ -1,34 +1,33 @@
// RUN: clang-cc -E -ffreestanding -triple=arm-none-none %s | FileCheck -check-prefix ARM %s &&
//
-// ARM:typedef signed char int8_t;
-// ARM:typedef short int16_t;
-// ARM:typedef int int32_t;
// ARM:typedef long long int int64_t;
+// ARM:typedef unsigned long long int uint64_t;
+// ARM:typedef int64_t int_least64_t;
+// ARM:typedef uint64_t uint_least64_t;
+// ARM:typedef int64_t int_fast64_t;
+// ARM:typedef uint64_t uint_fast64_t;
//
-// ARM:typedef unsigned char uint8_t;
-// ARM:typedef int8_t int_least8_t;
-// ARM:typedef uint8_t uint_least8_t;
-// ARM:typedef int8_t int_fast8_t;
-// ARM:typedef uint8_t uint_fast8_t;
-//
+// ARM:typedef int int32_t;
+// ARM:typedef unsigned int uint32_t;
+// ARM:typedef int32_t int_least32_t;
+// ARM:typedef uint32_t uint_least32_t;
+// ARM:typedef int32_t int_fast32_t;
+// ARM:typedef uint32_t uint_fast32_t;
+//
+// ARM:typedef short int16_t;
// ARM:typedef unsigned short uint16_t;
// ARM:typedef int16_t int_least16_t;
// ARM:typedef uint16_t uint_least16_t;
// ARM:typedef int16_t int_fast16_t;
// ARM:typedef uint16_t uint_fast16_t;
//
-// ARM:typedef unsigned int uint32_t;
-// ARM:typedef int32_t int_least32_t;
-// ARM:typedef uint32_t uint_least32_t;
-// ARM:typedef int32_t int_fast32_t;
-// ARM:typedef uint32_t uint_fast32_t;
+// ARM:typedef signed char int8_t;
+// ARM:typedef unsigned char uint8_t;
+// ARM:typedef int8_t int_least8_t;
+// ARM:typedef uint8_t uint_least8_t;
+// ARM:typedef int8_t int_fast8_t;
+// ARM:typedef uint8_t uint_fast8_t;
//
-// ARM:typedef unsigned long long int uint64_t;
-// ARM:typedef int64_t int_least64_t;
-// ARM:typedef uint64_t uint_least64_t;
-// ARM:typedef int64_t int_fast64_t;
-// ARM:typedef uint64_t uint_fast64_t;
-//
// ARM:typedef long int intptr_t;
// ARM:typedef unsigned long int uintptr_t;
//
@@ -109,35 +108,33 @@
//
// RUN: clang-cc -E -ffreestanding -triple=bfin-none-none %s | FileCheck -check-prefix BFIN %s &&
//
-// BFIN:typedef signed char int8_t;
-// BFIN:typedef short int16_t;
-// BFIN:typedef int int32_t;
-//
// BFIN:typedef long long int int64_t;
+// BFIN:typedef unsigned long long int uint64_t;
+// BFIN:typedef int64_t int_least64_t;
+// BFIN:typedef uint64_t uint_least64_t;
+// BFIN:typedef int64_t int_fast64_t;
+// BFIN:typedef uint64_t uint_fast64_t;
//
-// BFIN:typedef unsigned char uint8_t;
-// BFIN:typedef int8_t int_least8_t;
-// BFIN:typedef uint8_t uint_least8_t;
-// BFIN:typedef int8_t int_fast8_t;
-// BFIN:typedef uint8_t uint_fast8_t;
+// BFIN:typedef int int32_t;
+// BFIN:typedef unsigned int uint32_t;
+// BFIN:typedef int32_t int_least32_t;
+// BFIN:typedef uint32_t uint_least32_t;
+// BFIN:typedef int32_t int_fast32_t;
+// BFIN:typedef uint32_t uint_fast32_t;
//
+// BFIN:typedef short int16_t;
// BFIN:typedef unsigned short uint16_t;
// BFIN:typedef int16_t int_least16_t;
// BFIN:typedef uint16_t uint_least16_t;
// BFIN:typedef int16_t int_fast16_t;
// BFIN:typedef uint16_t uint_fast16_t;
//
-// BFIN:typedef unsigned int uint32_t;
-// BFIN:typedef int32_t int_least32_t;
-// BFIN:typedef uint32_t uint_least32_t;
-// BFIN:typedef int32_t int_fast32_t;
-// BFIN:typedef uint32_t uint_fast32_t;
-//
-// BFIN:typedef unsigned long long int uint64_t;
-// BFIN:typedef int64_t int_least64_t;
-// BFIN:typedef uint64_t uint_least64_t;
-// BFIN:typedef int64_t int_fast64_t;
-// BFIN:typedef uint64_t uint_fast64_t;
+// BFIN:typedef signed char int8_t;
+// BFIN:typedef unsigned char uint8_t;
+// BFIN:typedef int8_t int_least8_t;
+// BFIN:typedef uint8_t uint_least8_t;
+// BFIN:typedef int8_t int_fast8_t;
+// BFIN:typedef uint8_t uint_fast8_t;
//
// BFIN:typedef long int intptr_t;
// BFIN:typedef unsigned long int uintptr_t;
@@ -219,34 +216,33 @@
//
// RUN: clang-cc -E -ffreestanding -triple=i386-none-none %s | FileCheck -check-prefix I386 %s &&
//
-// I386:typedef signed char int8_t;
-// I386:typedef short int16_t;
-// I386:typedef int int32_t;
// I386:typedef long long int int64_t;
+// I386:typedef unsigned long long int uint64_t;
+// I386:typedef int64_t int_least64_t;
+// I386:typedef uint64_t uint_least64_t;
+// I386:typedef int64_t int_fast64_t;
+// I386:typedef uint64_t uint_fast64_t;
//
-// I386:typedef unsigned char uint8_t;
-// I386:typedef int8_t int_least8_t;
-// I386:typedef uint8_t uint_least8_t;
-// I386:typedef int8_t int_fast8_t;
-// I386:typedef uint8_t uint_fast8_t;
+// I386:typedef int int32_t;
+// I386:typedef unsigned int uint32_t;
+// I386:typedef int32_t int_least32_t;
+// I386:typedef uint32_t uint_least32_t;
+// I386:typedef int32_t int_fast32_t;
+// I386:typedef uint32_t uint_fast32_t;
//
+// I386:typedef short int16_t;
// I386:typedef unsigned short uint16_t;
// I386:typedef int16_t int_least16_t;
// I386:typedef uint16_t uint_least16_t;
// I386:typedef int16_t int_fast16_t;
// I386:typedef uint16_t uint_fast16_t;
//
-// I386:typedef unsigned int uint32_t;
-// I386:typedef int32_t int_least32_t;
-// I386:typedef uint32_t uint_least32_t;
-// I386:typedef int32_t int_fast32_t;
-// I386:typedef uint32_t uint_fast32_t;
-//
-// I386:typedef unsigned long long int uint64_t;
-// I386:typedef int64_t int_least64_t;
-// I386:typedef uint64_t uint_least64_t;
-// I386:typedef int64_t int_fast64_t;
-// I386:typedef uint64_t uint_fast64_t;
+// I386:typedef signed char int8_t;
+// I386:typedef unsigned char uint8_t;
+// I386:typedef int8_t int_least8_t;
+// I386:typedef uint8_t uint_least8_t;
+// I386:typedef int8_t int_fast8_t;
+// I386:typedef uint8_t uint_fast8_t;
//
// I386:typedef int intptr_t;
// I386:typedef unsigned int uintptr_t;
@@ -327,27 +323,26 @@
//
// RUN: clang-cc -E -ffreestanding -triple=msp430-none-none %s | FileCheck -check-prefix MSP430 %s &&
//
-// MSP430:typedef signed char int8_t;
-// MSP430:typedef short int16_t;
// MSP430:typedef long long int32_t;
+// MSP430:typedef unsigned long long uint32_t;
+// MSP430:typedef int32_t int_least32_t;
+// MSP430:typedef uint32_t uint_least32_t;
+// MSP430:typedef int32_t int_fast32_t;
+// MSP430:typedef uint32_t uint_fast32_t;
//
-// MSP430:typedef unsigned char uint8_t;
-// MSP430:typedef int8_t int_least8_t;
-// MSP430:typedef uint8_t uint_least8_t;
-// MSP430:typedef int8_t int_fast8_t;
-// MSP430:typedef uint8_t uint_fast8_t;
-//
+// MSP430:typedef short int16_t;
// MSP430:typedef unsigned short uint16_t;
// MSP430:typedef int16_t int_least16_t;
// MSP430:typedef uint16_t uint_least16_t;
// MSP430:typedef int16_t int_fast16_t;
// MSP430:typedef uint16_t uint_fast16_t;
//
-// MSP430:typedef unsigned long long uint32_t;
-// MSP430:typedef int32_t int_least32_t;
-// MSP430:typedef uint32_t uint_least32_t;
-// MSP430:typedef int32_t int_fast32_t;
-// MSP430:typedef uint32_t uint_fast32_t;
+// MSP430:typedef signed char int8_t;
+// MSP430:typedef unsigned char uint8_t;
+// MSP430:typedef int8_t int_least8_t;
+// MSP430:typedef uint8_t uint_least8_t;
+// MSP430:typedef int8_t int_fast8_t;
+// MSP430:typedef uint8_t uint_fast8_t;
//
// MSP430:typedef short intptr_t;
// MSP430:typedef unsigned short uintptr_t;
@@ -428,27 +423,26 @@
//
// RUN: clang-cc -E -ffreestanding -triple=pic16-none-none %s | FileCheck -check-prefix PIC16 %s &&
//
-// PIC16:typedef signed char int8_t;
-// PIC16:typedef short int16_t;
// PIC16:typedef long long int32_t;
+// PIC16:typedef unsigned long long uint32_t;
+// PIC16:typedef int32_t int_least32_t;
+// PIC16:typedef uint32_t uint_least32_t;
+// PIC16:typedef int32_t int_fast32_t;
+// PIC16:typedef uint32_t uint_fast32_t;
//
-// PIC16:typedef unsigned char uint8_t;
-// PIC16:typedef int8_t int_least8_t;
-// PIC16:typedef uint8_t uint_least8_t;
-// PIC16:typedef int8_t int_fast8_t;
-// PIC16:typedef uint8_t uint_fast8_t;
-//
+// PIC16:typedef short int16_t;
// PIC16:typedef unsigned short uint16_t;
// PIC16:typedef int16_t int_least16_t;
// PIC16:typedef uint16_t uint_least16_t;
// PIC16:typedef int16_t int_fast16_t;
// PIC16:typedef uint16_t uint_fast16_t;
//
-// PIC16:typedef unsigned long long uint32_t;
-// PIC16:typedef int32_t int_least32_t;
-// PIC16:typedef uint32_t uint_least32_t;
-// PIC16:typedef int32_t int_fast32_t;
-// PIC16:typedef uint32_t uint_fast32_t;
+// PIC16:typedef signed char int8_t;
+// PIC16:typedef unsigned char uint8_t;
+// PIC16:typedef int8_t int_least8_t;
+// PIC16:typedef uint8_t uint_least8_t;
+// PIC16:typedef int8_t int_fast8_t;
+// PIC16:typedef uint8_t uint_fast8_t;
//
// PIC16:typedef short intptr_t;
// PIC16:typedef unsigned short uintptr_t;
@@ -529,34 +523,33 @@
//
// RUN: clang-cc -E -ffreestanding -triple=powerpc64-none-none %s | FileCheck -check-prefix PPC64 %s &&
//
-// PPC64:typedef signed char int8_t;
-// PPC64:typedef short int16_t;
-// PPC64:typedef int int32_t;
// PPC64:typedef long int int64_t;
+// PPC64:typedef unsigned long int uint64_t;
+// PPC64:typedef int64_t int_least64_t;
+// PPC64:typedef uint64_t uint_least64_t;
+// PPC64:typedef int64_t int_fast64_t;
+// PPC64:typedef uint64_t uint_fast64_t;
//
-// PPC64:typedef unsigned char uint8_t;
-// PPC64:typedef int8_t int_least8_t;
-// PPC64:typedef uint8_t uint_least8_t;
-// PPC64:typedef int8_t int_fast8_t;
-// PPC64:typedef uint8_t uint_fast8_t;
+// PPC64:typedef int int32_t;
+// PPC64:typedef unsigned int uint32_t;
+// PPC64:typedef int32_t int_least32_t;
+// PPC64:typedef uint32_t uint_least32_t;
+// PPC64:typedef int32_t int_fast32_t;
+// PPC64:typedef uint32_t uint_fast32_t;
//
+// PPC64:typedef short int16_t;
// PPC64:typedef unsigned short uint16_t;
// PPC64:typedef int16_t int_least16_t;
// PPC64:typedef uint16_t uint_least16_t;
// PPC64:typedef int16_t int_fast16_t;
// PPC64:typedef uint16_t uint_fast16_t;
//
-// PPC64:typedef unsigned int uint32_t;
-// PPC64:typedef int32_t int_least32_t;
-// PPC64:typedef uint32_t uint_least32_t;
-// PPC64:typedef int32_t int_fast32_t;
-// PPC64:typedef uint32_t uint_fast32_t;
-//
-// PPC64:typedef unsigned long int uint64_t;
-// PPC64:typedef int64_t int_least64_t;
-// PPC64:typedef uint64_t uint_least64_t;
-// PPC64:typedef int64_t int_fast64_t;
-// PPC64:typedef uint64_t uint_fast64_t;
+// PPC64:typedef signed char int8_t;
+// PPC64:typedef unsigned char uint8_t;
+// PPC64:typedef int8_t int_least8_t;
+// PPC64:typedef uint8_t uint_least8_t;
+// PPC64:typedef int8_t int_fast8_t;
+// PPC64:typedef uint8_t uint_fast8_t;
//
// PPC64:typedef long int intptr_t;
// PPC64:typedef unsigned long int uintptr_t;
@@ -637,34 +630,34 @@
//
// RUN: clang-cc -E -ffreestanding -triple=powerpc-none-none %s | FileCheck -check-prefix PPC %s &&
//
-// PPC:typedef signed char int8_t;
-// PPC:typedef short int16_t;
-// PPC:typedef int int32_t;
+//
// PPC:typedef long long int int64_t;
+// PPC:typedef unsigned long long int uint64_t;
+// PPC:typedef int64_t int_least64_t;
+// PPC:typedef uint64_t uint_least64_t;
+// PPC:typedef int64_t int_fast64_t;
+// PPC:typedef uint64_t uint_fast64_t;
//
-// PPC:typedef unsigned char uint8_t;
-// PPC:typedef int8_t int_least8_t;
-// PPC:typedef uint8_t uint_least8_t;
-// PPC:typedef int8_t int_fast8_t;
-// PPC:typedef uint8_t uint_fast8_t;
+// PPC:typedef int int32_t;
+// PPC:typedef unsigned int uint32_t;
+// PPC:typedef int32_t int_least32_t;
+// PPC:typedef uint32_t uint_least32_t;
+// PPC:typedef int32_t int_fast32_t;
+// PPC:typedef uint32_t uint_fast32_t;
//
+// PPC:typedef short int16_t;
// PPC:typedef unsigned short uint16_t;
// PPC:typedef int16_t int_least16_t;
// PPC:typedef uint16_t uint_least16_t;
// PPC:typedef int16_t int_fast16_t;
// PPC:typedef uint16_t uint_fast16_t;
//
-// PPC:typedef unsigned int uint32_t;
-// PPC:typedef int32_t int_least32_t;
-// PPC:typedef uint32_t uint_least32_t;
-// PPC:typedef int32_t int_fast32_t;
-// PPC:typedef uint32_t uint_fast32_t;
-//
-// PPC:typedef unsigned long long int uint64_t;
-// PPC:typedef int64_t int_least64_t;
-// PPC:typedef uint64_t uint_least64_t;
-// PPC:typedef int64_t int_fast64_t;
-// PPC:typedef uint64_t uint_fast64_t;
+// PPC:typedef signed char int8_t;
+// PPC:typedef unsigned char uint8_t;
+// PPC:typedef int8_t int_least8_t;
+// PPC:typedef uint8_t uint_least8_t;
+// PPC:typedef int8_t int_fast8_t;
+// PPC:typedef uint8_t uint_fast8_t;
//
// PPC:typedef long int intptr_t;
// PPC:typedef unsigned long int uintptr_t;
@@ -745,34 +738,33 @@
//
// RUN: clang-cc -E -ffreestanding -triple=s390x-none-none %s | FileCheck -check-prefix S390X %s &&
//
-// S390X:typedef signed char int8_t;
-// S390X:typedef short int16_t;
-// S390X:typedef int int32_t;
// S390X:typedef long long int int64_t;
+// S390X:typedef unsigned long long int uint64_t;
+// S390X:typedef int64_t int_least64_t;
+// S390X:typedef uint64_t uint_least64_t;
+// S390X:typedef int64_t int_fast64_t;
+// S390X:typedef uint64_t uint_fast64_t;
//
-// S390X:typedef unsigned char uint8_t;
-// S390X:typedef int8_t int_least8_t;
-// S390X:typedef uint8_t uint_least8_t;
-// S390X:typedef int8_t int_fast8_t;
-// S390X:typedef uint8_t uint_fast8_t;
+// S390X:typedef int int32_t;
+// S390X:typedef unsigned int uint32_t;
+// S390X:typedef int32_t int_least32_t;
+// S390X:typedef uint32_t uint_least32_t;
+// S390X:typedef int32_t int_fast32_t;
+// S390X:typedef uint32_t uint_fast32_t;
//
+// S390X:typedef short int16_t;
// S390X:typedef unsigned short uint16_t;
// S390X:typedef int16_t int_least16_t;
// S390X:typedef uint16_t uint_least16_t;
// S390X:typedef int16_t int_fast16_t;
// S390X:typedef uint16_t uint_fast16_t;
//
-// S390X:typedef unsigned int uint32_t;
-// S390X:typedef int32_t int_least32_t;
-// S390X:typedef uint32_t uint_least32_t;
-// S390X:typedef int32_t int_fast32_t;
-// S390X:typedef uint32_t uint_fast32_t;
-//
-// S390X:typedef unsigned long long int uint64_t;
-// S390X:typedef int64_t int_least64_t;
-// S390X:typedef uint64_t uint_least64_t;
-// S390X:typedef int64_t int_fast64_t;
-// S390X:typedef uint64_t uint_fast64_t;
+// S390X:typedef signed char int8_t;
+// S390X:typedef unsigned char uint8_t;
+// S390X:typedef int8_t int_least8_t;
+// S390X:typedef uint8_t uint_least8_t;
+// S390X:typedef int8_t int_fast8_t;
+// S390X:typedef uint8_t uint_fast8_t;
//
// S390X:typedef long int intptr_t;
// S390X:typedef unsigned long int uintptr_t;
@@ -853,34 +845,33 @@
//
// RUN: clang-cc -E -ffreestanding -triple=sparc-none-none %s | FileCheck -check-prefix SPARC %s &&
//
-// SPARC:typedef signed char int8_t;
-// SPARC:typedef short int16_t;
-// SPARC:typedef int int32_t;
// SPARC:typedef long long int int64_t;
+// SPARC:typedef unsigned long long int uint64_t;
+// SPARC:typedef int64_t int_least64_t;
+// SPARC:typedef uint64_t uint_least64_t;
+// SPARC:typedef int64_t int_fast64_t;
+// SPARC:typedef uint64_t uint_fast64_t;
//
-// SPARC:typedef unsigned char uint8_t;
-// SPARC:typedef int8_t int_least8_t;
-// SPARC:typedef uint8_t uint_least8_t;
-// SPARC:typedef int8_t int_fast8_t;
-// SPARC:typedef uint8_t uint_fast8_t;
+// SPARC:typedef int int32_t;
+// SPARC:typedef unsigned int uint32_t;
+// SPARC:typedef int32_t int_least32_t;
+// SPARC:typedef uint32_t uint_least32_t;
+// SPARC:typedef int32_t int_fast32_t;
+// SPARC:typedef uint32_t uint_fast32_t;
//
+// SPARC:typedef short int16_t;
// SPARC:typedef unsigned short uint16_t;
// SPARC:typedef int16_t int_least16_t;
// SPARC:typedef uint16_t uint_least16_t;
// SPARC:typedef int16_t int_fast16_t;
// SPARC:typedef uint16_t uint_fast16_t;
//
-// SPARC:typedef unsigned int uint32_t;
-// SPARC:typedef int32_t int_least32_t;
-// SPARC:typedef uint32_t uint_least32_t;
-// SPARC:typedef int32_t int_fast32_t;
-// SPARC:typedef uint32_t uint_fast32_t;
-//
-// SPARC:typedef unsigned long long int uint64_t;
-// SPARC:typedef int64_t int_least64_t;
-// SPARC:typedef uint64_t uint_least64_t;
-// SPARC:typedef int64_t int_fast64_t;
-// SPARC:typedef uint64_t uint_fast64_t;
+// SPARC:typedef signed char int8_t;
+// SPARC:typedef unsigned char uint8_t;
+// SPARC:typedef int8_t int_least8_t;
+// SPARC:typedef uint8_t uint_least8_t;
+// SPARC:typedef int8_t int_fast8_t;
+// SPARC:typedef uint8_t uint_fast8_t;
//
// SPARC:typedef long int intptr_t;
// SPARC:typedef unsigned long int uintptr_t;
@@ -961,27 +952,26 @@
//
// RUN: clang-cc -E -ffreestanding -triple=tce-none-none %s | FileCheck -check-prefix TCE %s &&
//
-// TCE:typedef signed char int8_t;
-// TCE:typedef short int16_t;
// TCE:typedef int int32_t;
+// TCE:typedef unsigned int uint32_t;
+// TCE:typedef int32_t int_least32_t;
+// TCE:typedef uint32_t uint_least32_t;
+// TCE:typedef int32_t int_fast32_t;
+// TCE:typedef uint32_t uint_fast32_t;
//
-// TCE:typedef unsigned char uint8_t;
-// TCE:typedef int8_t int_least8_t;
-// TCE:typedef uint8_t uint_least8_t;
-// TCE:typedef int8_t int_fast8_t;
-// TCE:typedef uint8_t uint_fast8_t;
-//
+// TCE:typedef short int16_t;
// TCE:typedef unsigned short uint16_t;
// TCE:typedef int16_t int_least16_t;
// TCE:typedef uint16_t uint_least16_t;
// TCE:typedef int16_t int_fast16_t;
// TCE:typedef uint16_t uint_fast16_t;
//
-// TCE:typedef unsigned int uint32_t;
-// TCE:typedef int32_t int_least32_t;
-// TCE:typedef uint32_t uint_least32_t;
-// TCE:typedef int32_t int_fast32_t;
-// TCE:typedef uint32_t uint_fast32_t;
+// TCE:typedef signed char int8_t;
+// TCE:typedef unsigned char uint8_t;
+// TCE:typedef int8_t int_least8_t;
+// TCE:typedef uint8_t uint_least8_t;
+// TCE:typedef int8_t int_fast8_t;
+// TCE:typedef uint8_t uint_fast8_t;
//
// TCE:typedef int intptr_t;
// TCE:typedef unsigned int uintptr_t;
@@ -1062,34 +1052,34 @@
//
// RUN: clang-cc -E -ffreestanding -triple=x86_64-none-none %s | FileCheck -check-prefix X86_64 %s &&
//
-// X86_64:typedef signed char int8_t;
-// X86_64:typedef short int16_t;
-// X86_64:typedef int int32_t;
+//
// X86_64:typedef long int int64_t;
+// X86_64:typedef unsigned long int uint64_t;
+// X86_64:typedef int64_t int_least64_t;
+// X86_64:typedef uint64_t uint_least64_t;
+// X86_64:typedef int64_t int_fast64_t;
+// X86_64:typedef uint64_t uint_fast64_t;
//
-// X86_64:typedef unsigned char uint8_t;
-// X86_64:typedef int8_t int_least8_t;
-// X86_64:typedef uint8_t uint_least8_t;
-// X86_64:typedef int8_t int_fast8_t;
-// X86_64:typedef uint8_t uint_fast8_t;
+// X86_64:typedef int int32_t;
+// X86_64:typedef unsigned int uint32_t;
+// X86_64:typedef int32_t int_least32_t;
+// X86_64:typedef uint32_t uint_least32_t;
+// X86_64:typedef int32_t int_fast32_t;
+// X86_64:typedef uint32_t uint_fast32_t;
//
+// X86_64:typedef short int16_t;
// X86_64:typedef unsigned short uint16_t;
// X86_64:typedef int16_t int_least16_t;
// X86_64:typedef uint16_t uint_least16_t;
// X86_64:typedef int16_t int_fast16_t;
// X86_64:typedef uint16_t uint_fast16_t;
//
-// X86_64:typedef unsigned int uint32_t;
-// X86_64:typedef int32_t int_least32_t;
-// X86_64:typedef uint32_t uint_least32_t;
-// X86_64:typedef int32_t int_fast32_t;
-// X86_64:typedef uint32_t uint_fast32_t;
-//
-// X86_64:typedef unsigned long int uint64_t;
-// X86_64:typedef int64_t int_least64_t;
-// X86_64:typedef uint64_t uint_least64_t;
-// X86_64:typedef int64_t int_fast64_t;
-// X86_64:typedef uint64_t uint_fast64_t;
+// X86_64:typedef signed char int8_t;
+// X86_64:typedef unsigned char uint8_t;
+// X86_64:typedef int8_t int_least8_t;
+// X86_64:typedef uint8_t uint_least8_t;
+// X86_64:typedef int8_t int_fast8_t;
+// X86_64:typedef uint8_t uint_fast8_t;
//
// X86_64:typedef long int intptr_t;
// X86_64:typedef unsigned long int uintptr_t;
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index 87131bb62183a..9cbbfba935bd0 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -7,6 +7,26 @@ int test(char *C) { // nothing here should warn.
return C != 1; // expected-warning {{comparison between pointer and integer ('char *' and 'int')}}
}
+int ints(long a, unsigned long b) {
+ return (a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((int)a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((short)a == b) + // expected-warning {{comparison of integers of different signs}}
+ (a == (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
+ (a == (unsigned short) b); // expected-warning {{comparison of integers of different signs}}
+
+ enum Enum {B};
+ return (a == B) +
+ ((int)a == B) +
+ ((short)a == B) +
+ (a == (unsigned int) B) + // expected-warning {{comparison of integers of different signs}}
+ (a == (unsigned short) B); // expected-warning {{comparison of integers of different signs}}
+
+ // Should be able to prove all of these are non-negative.
+ return (b == (long) B) +
+ (b == (int) B) +
+ (b == (short) B);
+}
+
int equal(char *a, const char *b) {
return a == b;
}
diff --git a/test/Sema/conditional-expr.c b/test/Sema/conditional-expr.c
index 1f0a9deb5e47d..3bfeae5d4c5eb 100644
--- a/test/Sema/conditional-expr.c
+++ b/test/Sema/conditional-expr.c
@@ -34,6 +34,25 @@ void foo() {
typedef void *asdf;
*(0 ? (asdf) 0 : &x) = 10;
+
+ unsigned long test0 = 5;
+ test0 = test0 ? (long) test0 : test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? (int) test0 : test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? (short) test0 : test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? test0 : (long) test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? test0 : (int) test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? test0 : (short) test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? test0 : (long) 10;
+ test0 = test0 ? test0 : (int) 10;
+ test0 = test0 ? test0 : (short) 10;
+ test0 = test0 ? (long) 10 : test0;
+ test0 = test0 ? (int) 10 : test0;
+ test0 = test0 ? (short) 10 : test0;
+
+ enum Enum { EVal };
+ test0 = test0 ? EVal : test0;
+ test0 = test0 ? EVal : (int) test0; // okay: EVal is an int
+ test0 = test0 ? (unsigned) EVal : (int) test0; // expected-warning {{operands of ? are integers of different signs}}
}
int Postgresql() {
diff --git a/test/SemaCXX/compare.cpp b/test/SemaCXX/compare.cpp
new file mode 100644
index 0000000000000..806b078e8df6c
--- /dev/null
+++ b/test/SemaCXX/compare.cpp
@@ -0,0 +1,15 @@
+// RUN: clang-cc -fsyntax-only -pedantic -verify %s
+
+int test0(long a, unsigned long b) {
+ enum Enum {B};
+ return (a == B) + // expected-warning {{comparison of integers of different signs}}
+ ((int)a == B) + // expected-warning {{comparison of integers of different signs}}
+ ((short)a == B) + // expected-warning {{comparison of integers of different signs}}
+ (a == (unsigned int) B) + // expected-warning {{comparison of integers of different signs}}
+ (a == (unsigned short) B); // expected-warning {{comparison of integers of different signs}}
+
+ // Should be able to prove all of these are non-negative.
+ return (b == (long) B) +
+ (b == (int) B) +
+ (b == (short) B);
+}
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp
index fea3324b5fd52..da2dd67d061d8 100644
--- a/test/SemaCXX/conditional-expr.cpp
+++ b/test/SemaCXX/conditional-expr.cpp
@@ -156,8 +156,8 @@ void test()
i1 = i1 ? i1 : ir1;
int *pi1 = i1 ? &i1 : 0;
pi1 = i1 ? 0 : &i1;
- i1 = i1 ? i1 : EVal;
- i1 = i1 ? EVal : i1;
+ i1 = i1 ? i1 : EVal; // expected-warning {{operands of ? are integers of different signs}} ??
+ i1 = i1 ? EVal : i1; // expected-warning {{operands of ? are integers of different signs}} ??
d1 = i1 ? 'c' : 4.0;
d1 = i1 ? 4.0 : 'c';
Base *pb = i1 ? (Base*)0 : (Derived*)0;
@@ -177,6 +177,24 @@ void test()
(void)&(i1 ? flds.b1 : flds.i1); // expected-error {{address of bit-field requested}}
(void)&(i1 ? flds.i1 : flds.b1); // expected-error {{address of bit-field requested}}
+
+ unsigned long test0 = 5;
+ test0 = test0 ? (long) test0 : test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? (int) test0 : test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? (short) test0 : test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? test0 : (long) test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? test0 : (int) test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? test0 : (short) test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? test0 : (long) 10;
+ test0 = test0 ? test0 : (int) 10;
+ test0 = test0 ? test0 : (short) 10;
+ test0 = test0 ? (long) 10 : test0;
+ test0 = test0 ? (int) 10 : test0;
+ test0 = test0 ? (short) 10 : test0;
+
+ test0 = test0 ? EVal : test0;
+ test0 = test0 ? EVal : (int) test0; // expected-warning {{operands of ? are integers of different signs}}
+
// Note the thing that this does not test: since DR446, various situations
// *must* create a separate temporary copy of class objects. This can only
// be properly tested at runtime, though.
diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp
index b86a27d66d982..20cf35b293b6e 100644
--- a/test/SemaCXX/constructor-initializer.cpp
+++ b/test/SemaCXX/constructor-initializer.cpp
@@ -122,3 +122,36 @@ struct Q {
float *pf;
};
+
+// A silly class used to demonstrate field-is-uninitialized in constructors with
+// multiple params.
+class TwoInOne { TwoInOne(TwoInOne a, TwoInOne b) {} };
+class InitializeUsingSelfTest {
+ bool A;
+ char* B;
+ int C;
+ TwoInOne D;
+ InitializeUsingSelfTest(int E)
+ : A(A), // expected-warning {{field is uninitialized when used here}}
+ B((((B)))), // expected-warning {{field is uninitialized when used here}}
+ C(A && InitializeUsingSelfTest::C), // expected-warning {{field is uninitialized when used here}}
+ D(D, // expected-warning {{field is uninitialized when used here}}
+ D) {} // expected-warning {{field is uninitialized when used here}}
+};
+
+int IntWrapper(int i) { return 0; };
+class InitializeUsingSelfExceptions {
+ int A;
+ int B;
+ InitializeUsingSelfExceptions(int B)
+ : A(IntWrapper(A)), // Due to a conservative implementation, we do not report warnings inside function/ctor calls even though it is possible to do so.
+ B(B) {} // Not a warning; B is a local variable.
+};
+
+class CopyConstructorTest {
+ bool A, B, C;
+ CopyConstructorTest(const CopyConstructorTest& rhs)
+ : A(rhs.A),
+ B(B), // expected-warning {{field is uninitialized when used here}}
+ C(rhs.C || C) { } // expected-warning {{field is uninitialized when used here}}
+};
diff --git a/test/SemaCXX/overload-member-call.cpp b/test/SemaCXX/overload-member-call.cpp
index 96e570da654b7..937b65d633f9d 100644
--- a/test/SemaCXX/overload-member-call.cpp
+++ b/test/SemaCXX/overload-member-call.cpp
@@ -54,3 +54,15 @@ void test(X x, const X xc, X* xp, const X* xcp, volatile X xv, volatile X* xvp)
X::h(0); // expected-error{{call to non-static member function without an object argument}}
}
+
+struct X1 {
+ int& member();
+ float& member() const;
+};
+
+struct X2 : X1 { };
+
+void test_X2(X2 *x2p, const X2 *cx2p) {
+ int &ir = x2p->member();
+ float &fr = cx2p->member();
+}
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index 0f723ad206b9b..750038d4ab519 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -268,3 +268,14 @@ void circ() {
CircA a;
a->val = 0; // expected-error {{circular pointer delegation detected}}
}
+
+// PR5360: Arrays should lead to built-in candidates for subscript.
+typedef enum {
+ LastReg = 23,
+} Register;
+class RegAlloc {
+ int getPriority(Register r) {
+ return usepri[r];
+ }
+ int usepri[LastReg + 1];
+};
diff --git a/test/SemaCXX/primary-base.cpp b/test/SemaCXX/primary-base.cpp
index 62f9087bd91d8..a7e18bd528a16 100644
--- a/test/SemaCXX/primary-base.cpp
+++ b/test/SemaCXX/primary-base.cpp
@@ -4,8 +4,8 @@ class B : virtual A { };
class C : B { };
-// Since A is already a primary base class, C should be the primary base class of F.
+// Since A is already a primary base class, C should be the primary base class
+// of F.
class F : virtual A, virtual C { };
int sa[sizeof(F) == sizeof(A) ? 1 : -1];
-
diff --git a/test/SemaTemplate/example-dynarray.cpp b/test/SemaTemplate/example-dynarray.cpp
index 0b8d605b623d2..2b752b4f1f490 100644
--- a/test/SemaTemplate/example-dynarray.cpp
+++ b/test/SemaTemplate/example-dynarray.cpp
@@ -1,4 +1,4 @@
-// RUN: clang %s -o %t
+// RUN: clang-cc -emit-llvm-only %s
#include <stddef.h>
#include <stdlib.h>
#include <assert.h>
diff --git a/test/SemaTemplate/instantiate-complete.cpp b/test/SemaTemplate/instantiate-complete.cpp
index babc55217a95b..507894a2ff691 100644
--- a/test/SemaTemplate/instantiate-complete.cpp
+++ b/test/SemaTemplate/instantiate-complete.cpp
@@ -45,3 +45,24 @@ void test_memptr(X<long> *p1, long X<long>::*pm1,
(void)(p1->*pm1);
(void)((p2->*pm2)(0));
}
+
+// Reference binding to a base
+template<typename T>
+struct X1 { };
+
+template<typename T>
+struct X2 : public T { };
+
+void refbind_base(X2<X1<int> > &x2) {
+ X1<int> &x1 = x2;
+}
+
+// Enumerate constructors for user-defined conversion.
+template<typename T>
+struct X3 {
+ X3(T);
+};
+
+void enum_constructors(X1<float> &x1) {
+ X3<X1<float> > x3 = x1;
+}
diff --git a/test/SemaTemplate/instantiate-deeply.cpp b/test/SemaTemplate/instantiate-deeply.cpp
index 27e430be5cbee..7f15bf1200f12 100644
--- a/test/SemaTemplate/instantiate-deeply.cpp
+++ b/test/SemaTemplate/instantiate-deeply.cpp
@@ -1,5 +1,4 @@
// RUN: clang-cc -fsyntax-only -Wall -verify %s
-
template<typename a> struct A {
template <typename b> struct B {
template <typename c> struct C {
@@ -20,3 +19,18 @@ template<typename a> struct A {
};
A<int>::B<int>::C<int>::D<int>::E<int> global;
+
+// PR5352
+template <typename T>
+class Foo {
+public:
+ Foo() {}
+
+ struct Bar {
+ T value;
+ };
+
+ Bar u;
+};
+
+template class Foo<int>;
diff --git a/test/SemaTemplate/instantiate-expr-1.cpp b/test/SemaTemplate/instantiate-expr-1.cpp
index 13ee3ab525ba6..fb88213c401be 100644
--- a/test/SemaTemplate/instantiate-expr-1.cpp
+++ b/test/SemaTemplate/instantiate-expr-1.cpp
@@ -1,5 +1,4 @@
// RUN: clang-cc -fsyntax-only -verify %s
-
template<int I, int J>
struct Bitfields {
int simple : I; // expected-error{{bit-field 'simple' has zero width}}
@@ -69,3 +68,29 @@ void test_BitfieldNeg() {
(void)sizeof(BitfieldNeg2<int, -5>); // okay
(void)sizeof(BitfieldNeg2<int, 5>); // expected-note{{in instantiation of template class 'struct BitfieldNeg2<int, 5>' requested here}}
}
+
+template<typename T>
+void increment(T &x) {
+ (void)++x;
+}
+
+struct Incrementable {
+ Incrementable &operator++();
+};
+
+void test_increment(Incrementable inc) {
+ increment(inc);
+}
+
+template<typename T>
+void add(const T &x) {
+ (void)(x + x);
+}
+
+struct Addable {
+ Addable operator+(const Addable&) const;
+};
+
+void test_add(Addable &a) {
+ add(a);
+}
diff --git a/test/SemaTemplate/member-access-expr.cpp b/test/SemaTemplate/member-access-expr.cpp
index 0a6a6bc0990e5..ad0075f564b60 100644
--- a/test/SemaTemplate/member-access-expr.cpp
+++ b/test/SemaTemplate/member-access-expr.cpp
@@ -88,3 +88,20 @@ protected:
(void)f0<0>();
}
};
+
+// Fun with template instantiation and conversions
+struct X4 {
+ int& member();
+ float& member() const;
+};
+
+template<typename T>
+struct X5 {
+ void f(T* ptr) { int& ir = ptr->member(); }
+ void g(T* ptr) { float& fr = ptr->member(); }
+};
+
+void test_X5(X5<X4> x5, X5<const X4> x5c, X4 *xp, const X4 *cxp) {
+ x5.f(xp);
+ x5c.g(cxp);
+}
diff --git a/test/SemaTemplate/member-template-access-expr.cpp b/test/SemaTemplate/member-template-access-expr.cpp
index 0238cd53c553d..567c0d63b046a 100644
--- a/test/SemaTemplate/member-template-access-expr.cpp
+++ b/test/SemaTemplate/member-template-access-expr.cpp
@@ -93,3 +93,13 @@ void f(X4<X3<int> > x4i) {
X2<sizeof(int)> x2;
x4i.f<X2<sizeof(int)> >(x2);
}
+
+template<typename T>
+struct X5 {
+ template<typename U>
+ void f();
+
+ void g() {
+ this->f<T*>();
+ }
+};
diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp
index 534030dba0ea2..a6611582f1707 100644
--- a/test/SemaTemplate/temp_arg_nontype.cpp
+++ b/test/SemaTemplate/temp_arg_nontype.cpp
@@ -122,3 +122,33 @@ extern FuncPtr0<&func0> *fp0;
int func0(int, int);
extern FuncPtr0<&func0> *fp0;
+// PR5350
+namespace ns {
+ template <typename T>
+ struct Foo {
+ static const bool value = true;
+ };
+
+ template <bool b>
+ struct Bar {};
+
+ const bool value = false;
+
+ Bar<bool(ns::Foo<int>::value)> x;
+}
+
+// PR5349
+namespace ns {
+ enum E { k };
+
+ template <E e>
+ struct Baz {};
+
+ Baz<k> f1; // This works.
+ Baz<E(0)> f2; // This too.
+ Baz<static_cast<E>(0)> f3; // And this.
+
+ Baz<ns::E(0)> b1; // This doesn't work.
+ Baz<static_cast<ns::E>(0)> b2; // This neither.
+}
+
diff --git a/test/SemaTemplate/template-id-expr.cpp b/test/SemaTemplate/template-id-expr.cpp
index a0cbe4408494b..dd8694afa7ea6 100644
--- a/test/SemaTemplate/template-id-expr.cpp
+++ b/test/SemaTemplate/template-id-expr.cpp
@@ -1,5 +1,4 @@
// RUN: clang-cc -fsyntax-only -verify %s
-
// PR5336
template<typename FromCl>
struct isa_impl_cl {
@@ -12,3 +11,19 @@ void isa(const Y &Val) { return isa_impl_cl<Y>::template isa<X>(Val); }
class Value;
void f0(const Value &Val) { isa<Value>(Val); }
+
+// Implicit template-ids.
+template<typename T>
+struct X0 {
+ template<typename U>
+ void f1();
+
+ template<typename U>
+ void f2(U) {
+ f1<U>();
+ }
+};
+
+void test_X0_int(X0<int> xi, float f) {
+ xi.f2(f);
+}
diff --git a/test/lit.cfg b/test/lit.cfg
index 60d8df057730f..9b274fed30b50 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -55,6 +55,12 @@ if config.test_exec_root is None:
# configuration hasn't been created by the build system, or we are in an
# out-of-tree build situation).
+ # Check for 'clang_site_config' user parameter, and use that if available.
+ site_cfg = lit.params.get('clang_site_config', None)
+ if site_cfg and os.path.exists(site_cfg):
+ lit.load_config(config, site_cfg)
+ raise SystemExit
+
# Try to detect the situation where we are using an out-of-tree build by
# looking for 'llvm-config'.
#