diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-07-15 17:07:12 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-07-15 17:07:12 +0000 |
commit | f1752835b9d5f0da31f34b18c9f1eb8dcb799ba8 (patch) | |
tree | 5e946d69177464379cb1a38ac18206180d763639 /test | |
parent | 1928da94b55683957759d5c5ff4593a118773394 (diff) | |
download | FreeBSD-src-f1752835b9d5f0da31f34b18c9f1eb8dcb799ba8.zip FreeBSD-src-f1752835b9d5f0da31f34b18c9f1eb8dcb799ba8.tar.gz |
Update clang to r108428.
Diffstat (limited to 'test')
40 files changed, 491 insertions, 53 deletions
diff --git a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp b/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp index dc79300..5556f35 100644 --- a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp +++ b/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp @@ -43,3 +43,23 @@ namespace PR5949 { return Foo<T>(b, quuz); } } + +// PR7641 +namespace PR7641 { + namespace N2 + { + template<class> + int f0(int); + } + namespace N + { + using N2::f0; + } + + template<class R,class B1> + int + f1(R(a)(B1)); + + void f2() + { f1(N::f0<int>); } +} diff --git a/test/CodeCompletion/Inputs/reserved.h b/test/CodeCompletion/Inputs/reserved.h new file mode 100644 index 0000000..fafe4ac --- /dev/null +++ b/test/CodeCompletion/Inputs/reserved.h @@ -0,0 +1,2 @@ +typedef int _INTEGER_TYPE; +typedef float FLOATING_TYPE; diff --git a/test/CodeCompletion/ordinary-name.c b/test/CodeCompletion/ordinary-name.c index 1580d01..0807b74 100644 --- a/test/CodeCompletion/ordinary-name.c +++ b/test/CodeCompletion/ordinary-name.c @@ -1,10 +1,14 @@ +#include <reserved.h> struct X { int x; }; - typedef struct t TYPEDEF; - +typedef struct t _TYPEDEF; void foo() { int y; - // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s + // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s + // CHECK-CC1: _Imaginary + // CHECK-CC1-NOT: _INTEGER_TYPE; + // CHECK-CC1: _TYPEDEF + // CHECK-CC1: FLOATING_TYPE // CHECK-CC1: foo - // CHECK-CC1: y // CHECK-CC1: TYPEDEF + // CHECK-CC1: y diff --git a/test/CodeGenCXX/condition.cpp b/test/CodeGenCXX/condition.cpp index bbc6d2f..652e7c8 100644 --- a/test/CodeGenCXX/condition.cpp +++ b/test/CodeGenCXX/condition.cpp @@ -26,6 +26,7 @@ struct Y { X getX(); +// CHECK: define void @_Z11if_destructi( void if_destruct(int z) { // Verify that the condition variable is destroyed at the end of the // "if" statement. diff --git a/test/CodeGenCXX/eh.cpp b/test/CodeGenCXX/eh.cpp index d03dc91..6d79c3e 100644 --- a/test/CodeGenCXX/eh.cpp +++ b/test/CodeGenCXX/eh.cpp @@ -136,9 +136,6 @@ namespace test7 { // CHECK-NEXT: invoke void @__cxa_throw(i8* [[EXNALLOC]], i8* bitcast (i8** @_ZTIi to i8*), i8* null throw 1; } -// This cleanup ends up here for no good reason. It's actually unused. -// CHECK: load i8** [[EXNALLOCVAR]] -// CHECK-NEXT: call void @__cxa_free_exception( // CHECK: [[CAUGHTEXN:%.*]] = call i8* @llvm.eh.exception() // CHECK-NEXT: store i8* [[CAUGHTEXN]], i8** [[CAUGHTEXNVAR]] @@ -184,11 +181,7 @@ namespace test8 { // CHECK-NEXT: invoke void @_ZN5test81AC1ERKS0_( // CHECK: call i8* @__cxa_begin_catch // CHECK-NEXT: invoke void @_ZN5test81AD1Ev( - // CHECK: call void @__cxa_end_catch() - // CHECK-NEXT: load - // CHECK-NEXT: switch - // CHECK: ret void } } @@ -220,3 +213,39 @@ namespace test9 { // CHECK: call i8* @llvm.eh.exception // CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* {{.*}}, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* bitcast (i8** @_ZTIi to i8*), i8* null) } + +// __cxa_end_catch can throw for some kinds of caught exceptions. +namespace test10 { + void opaque(); + + struct A { ~A(); }; + struct B { int x; }; + + // CHECK: define void @_ZN6test103fooEv() + void foo() { + A a; // force a cleanup context + + try { + // CHECK: invoke void @_ZN6test106opaqueEv() + opaque(); + } catch (int i) { + // CHECK: call i8* @__cxa_begin_catch + // CHECK-NEXT: bitcast + // CHECK-NEXT: load i32* + // CHECK-NEXT: store i32 + // CHECK-NEXT: call void @__cxa_end_catch() nounwind + } catch (B a) { + // CHECK: call i8* @__cxa_begin_catch + // CHECK-NEXT: bitcast + // CHECK-NEXT: bitcast + // CHECK-NEXT: bitcast + // CHECK-NEXT: call void @llvm.memcpy + // CHECK-NEXT: invoke void @__cxa_end_catch() + } catch (...) { + // CHECK: call i8* @__cxa_begin_catch + // CHECK-NEXT: invoke void @__cxa_end_catch() + } + + // CHECK: call void @_ZN6test101AD1Ev( + } +} diff --git a/test/CodeGenCXX/instantiate-blocks.cpp b/test/CodeGenCXX/instantiate-blocks.cpp index c8f897d..e206582 100644 --- a/test/CodeGenCXX/instantiate-blocks.cpp +++ b/test/CodeGenCXX/instantiate-blocks.cpp @@ -31,3 +31,29 @@ void test2(void) { foo(100, 'a'); } + +namespace rdar6182276 { +extern "C" { +int printf(const char *, ...); +} + +template <typename T> T foo(T t) +{ + void (^testing)(int) = ^(int bar) { printf("bar is %d\n", bar); }; + printf("bar is\n"); + return 1; +} + +template <typename T> void gorf(T t) +{ + foo(t); +} + + +void test(void) +{ + gorf(2); +} +} + + diff --git a/test/CodeGenCXX/lvalue-bitcasts.cpp b/test/CodeGenCXX/lvalue-bitcasts.cpp new file mode 100644 index 0000000..8c5fa4a --- /dev/null +++ b/test/CodeGenCXX/lvalue-bitcasts.cpp @@ -0,0 +1,163 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s | FileCheck %s + +struct X { int i; float f; }; +struct Y { X x; }; + +// CHECK: define void @_Z21reinterpret_cast_testRiRfR1X +void reinterpret_cast_test(int &ir, float &fr, X &xr) { + // CHECK: load float** + // CHECK: bitcast float* + // CHECK: load i32* + ir = reinterpret_cast<int&>(fr); + // CHECK: load + // CHECK: {{bitcast.*to i32\*}} + // CHECK: load i32* + ir = reinterpret_cast<int&>(xr); + // CHECK: load i32 + // CHECK: {{bitcast.*to float\*}} + // CHECK: load float* + fr = reinterpret_cast<float&>(ir); + // CHECK: load + // CHECK: {{bitcast.*to float\*}} + // CHECK: load float* + fr = reinterpret_cast<float&>(xr); + // CHECK: load i32** + // CHECK: bitcast i32* + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 + xr = reinterpret_cast<X&>(ir); + // CHECK: load float** + // CHECK: bitcast float* + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 + xr = reinterpret_cast<X&>(fr); + _Complex float cf; + _Complex float &cfr = cf; + // CHECK: load i32** + // CHECK: bitcast i32* + // CHECK: load float* + // CHECK: load float* + cfr = reinterpret_cast<_Complex float&>(ir); + // CHECK: load float** + // CHECK: bitcast float* + // CHECK: load float* + // CHECK: load float* + cfr = reinterpret_cast<_Complex float&>(fr); + // CHECK: bitcast + // CHECK: load float* + // CHECK: load float* + cfr = reinterpret_cast<_Complex float&>(xr); + // CHECK: ret void +} + +// CHECK: define void @_Z6c_castRiRfR1X +void c_cast(int &ir, float &fr, X &xr) { + // CHECK: load float** + // CHECK: bitcast float* + // CHECK: load i32* + ir = (int&)fr; + // CHECK: load + // CHECK: {{bitcast.*to i32\*}} + // CHECK: load i32* + ir = (int&)xr; + // CHECK: load i32 + // CHECK: {{bitcast.*to float\*}} + // CHECK: load float* + fr = (float&)ir; + // CHECK: load + // CHECK: {{bitcast.*to float\*}} + // CHECK: load float* + fr = (float&)xr; + // CHECK: load i32** + // CHECK: bitcast i32* + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 + xr = (X&)ir; + // CHECK: load float** + // CHECK: bitcast float* + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 + xr = (X&)fr; + _Complex float cf; + _Complex float &cfr = cf; + // CHECK: load i32** + // CHECK: bitcast i32* + // CHECK: load float* + // CHECK: load float* + cfr = (_Complex float&)ir; + // CHECK: load float** + // CHECK: bitcast float* + // CHECK: load float* + // CHECK: load float* + cfr = (_Complex float&)fr; + // CHECK: bitcast + // CHECK: load float* + // CHECK: load float* + cfr = (_Complex float&)xr; + // CHECK: ret void +} + +// CHECK: define void @_Z15functional_castRiRfR1X +void functional_cast(int &ir, float &fr, X &xr) { + typedef int &intref; + typedef float &floatref; + typedef X &Xref; + // CHECK: load float** + // CHECK: bitcast float* + // CHECK: load i32* + ir = intref(fr); + // CHECK: load + // CHECK: {{bitcast.*to i32\*}} + // CHECK: load i32* + ir = intref(xr); + // CHECK: load i32 + // CHECK: {{bitcast.*to float\*}} + // CHECK: load float* + fr = floatref(ir); + // CHECK: load + // CHECK: {{bitcast.*to float\*}} + // CHECK: load float* + fr = floatref(xr); + // CHECK: load i32** + // CHECK: bitcast i32* + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 + xr = Xref(ir); + // CHECK: load float** + // CHECK: bitcast float* + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 + xr = Xref(fr); + typedef _Complex float &complex_float_ref; + _Complex float cf; + _Complex float &cfr = cf; + // CHECK: load i32** + // CHECK: bitcast i32* + // CHECK: load float* + // CHECK: load float* + cfr = complex_float_ref(ir); + // CHECK: load float** + // CHECK: bitcast float* + // CHECK: load float* + // CHECK: load float* + cfr = complex_float_ref(fr); + // CHECK: bitcast + // CHECK: load float* + // CHECK: load float* + cfr = complex_float_ref(xr); + // CHECK: ret void +} + +namespace PR6437 { + struct in_addr {}; + void copy( const struct in_addr &new_addr ) { + int addr = (int&)new_addr; + } +} + +namespace PR7593 { + void foo(double &X, char *A) { + X = reinterpret_cast<double&>(A[4]); + } +} + +namespace PR7344 { + void serialize_annotatable_id( void*& id ) + { + unsigned long l_id = (unsigned long&)id; + } +} diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp index 54a4060..814a759 100644 --- a/test/CodeGenCXX/mangle.cpp +++ b/test/CodeGenCXX/mangle.cpp @@ -495,4 +495,15 @@ namespace test12 { // CHECK: _ZN6test121fENS_1AILt33000EEE template <unsigned short> struct A { }; void f(A<33000>) { } -}
\ No newline at end of file +} + +// PR7446 +namespace test13 { + template <template <class> class T> class A {}; + template <class U> class B {}; + + template <template<class> class T> void foo(const A<T> &a) {} + + // CHECK: define weak_odr void @_ZN6test133fooINS_1BEEEvRKNS_1AIT_EE( + template void foo(const A<B> &a); +} diff --git a/test/CodeGenCXX/member-qual-debug-info.cpp b/test/CodeGenCXX/member-qual-debug-info.cpp new file mode 100644 index 0000000..c6e0991 --- /dev/null +++ b/test/CodeGenCXX/member-qual-debug-info.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -g -S -masm-verbose -x c++ -o %t %s +// RUN: grep DW_TAG_volatile_type %t | count 3 +// RUN: grep DW_TAG_const_type %t | count 3 +// one for decl, one for def, one for abbrev + +namespace A { + class B { + public: + void dump() const volatile; + }; +} + +int main () { + using namespace A; + B b; + return 0; +} + +void A::B::dump() const volatile{ +} diff --git a/test/CodeGenCXX/nrvo.cpp b/test/CodeGenCXX/nrvo.cpp index 6181f0e..8d19b1e 100644 --- a/test/CodeGenCXX/nrvo.cpp +++ b/test/CodeGenCXX/nrvo.cpp @@ -57,20 +57,15 @@ X test2(bool B) { // CHECK-EH: call void @_ZN1XC1Ev // CHECK-EH-NEXT: invoke void @_ZN1XC1Ev - // -> %invoke.cont1, %lpad + // -> %invoke.cont, %lpad - // %invoke.cont1: + // %invoke.cont: // CHECK-EH: br i1 // -> %if.then, %if.end // %if.then: returning 'x' // CHECK-EH: invoke void @_ZN1XC1ERKS_ - // -> %cleanup, %lpad5 - - // %invoke.cont: rethrow block for %eh.cleanup. - // This really should be elsewhere in the function. - // CHECK-EH: call void @_Unwind_Resume_or_Rethrow - // CHECK-EH-NEXT: unreachable + // -> %cleanup, %lpad1 // %lpad: landing pad for ctor of 'y', dtor of 'y' // CHECK-EH: call i8* @llvm.eh.exception() @@ -78,25 +73,30 @@ X test2(bool B) { // CHECK-EH-NEXT: br label // -> %eh.cleanup - // %invoke.cont2: normal cleanup for 'x' - // CHECK-EH: call void @_ZN1XD1Ev - // CHECK-EH-NEXT: ret void - - // %lpad5: landing pad for return copy ctors, EH cleanup for 'y' + // %lpad1: landing pad for return copy ctors, EH cleanup for 'y' // CHECK-EH: invoke void @_ZN1XD1Ev // -> %eh.cleanup, %terminate.lpad // %if.end: returning 'y' // CHECK-EH: invoke void @_ZN1XC1ERKS_ - // -> %cleanup, %lpad5 + // -> %cleanup, %lpad1 // %cleanup: normal cleanup for 'y' // CHECK-EH: invoke void @_ZN1XD1Ev - // -> %invoke.cont2, %lpad + // -> %invoke.cont11, %lpad + + // %invoke.cont11: normal cleanup for 'x' + // CHECK-EH: call void @_ZN1XD1Ev + // CHECK-EH-NEXT: ret void // %eh.cleanup: EH cleanup for 'x' // CHECK-EH: invoke void @_ZN1XD1Ev - // -> %invoke.cont, %terminate.lpad + // -> %invoke.cont17, %terminate.lpad + + // %invoke.cont17: rethrow block for %eh.cleanup. + // This really should be elsewhere in the function. + // CHECK-EH: call void @_Unwind_Resume_or_Rethrow + // CHECK-EH-NEXT: unreachable // %terminate.lpad: terminate landing pad. // CHECK-EH: call i8* @llvm.eh.exception() diff --git a/test/CodeGenCXX/static-init-2.cpp b/test/CodeGenCXX/static-init-2.cpp index 65ab3bb..7eb4a7d 100644 --- a/test/CodeGenCXX/static-init-2.cpp +++ b/test/CodeGenCXX/static-init-2.cpp @@ -3,4 +3,4 @@ // Make sure we don't crash generating y; its value is constant, but the // initializer has side effects, so EmitConstantExpr should fail. int x(); -int y = x() && 0; +int y = x() && 0; // expected-warning {{use of logical && with constant operand}} diff --git a/test/CodeGenObjC/metadata_symbols.m b/test/CodeGenObjC/metadata_symbols.m index 59441e5..3163946 100644 --- a/test/CodeGenObjC/metadata_symbols.m +++ b/test/CodeGenObjC/metadata_symbols.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -fexceptions -o %t %s // RUN: FileCheck -check-prefix=CHECK-X86_64 < %t %s // RUN: grep '@"OBJC_EHTYPE_$_EH3"' %t | count 3 diff --git a/test/CodeGenObjC/unwind-fn.m b/test/CodeGenObjC/unwind-fn.m index 0aa8cde..48217f0 100644 --- a/test/CodeGenObjC/unwind-fn.m +++ b/test/CodeGenObjC/unwind-fn.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fobjc-nonfragile-abi -emit-llvm -o - %s | FileCheck --check-prefix=DEFAULT_EH %s -// RUN: %clang_cc1 -fsjlj-exceptions -fobjc-nonfragile-abi -emit-llvm -o - %s | FileCheck --check-prefix=SJLJ_EH %s +// RUN: %clang_cc1 -fobjc-nonfragile-abi -emit-llvm -fexceptions -o - %s | FileCheck --check-prefix=DEFAULT_EH %s +// RUN: %clang_cc1 -fsjlj-exceptions -fobjc-nonfragile-abi -fexceptions -emit-llvm -o - %s | FileCheck --check-prefix=SJLJ_EH %s // DEFAULT_EH: declare void @_Unwind_Resume_or_Rethrow(i8*) // SJLJ_EH: declare void @_Unwind_SjLj_Resume(i8*) diff --git a/test/Driver/darwin-iphone-defaults.m b/test/Driver/darwin-iphone-defaults.m index 97ac4a4..62a9403 100644 --- a/test/Driver/darwin-iphone-defaults.m +++ b/test/Driver/darwin-iphone-defaults.m @@ -1,4 +1,4 @@ -// RUN: %clang -ccc-host-triple i386-apple-darwin9 -arch armv7 -flto -S -o - %s | FileCheck %s +// RUN: %clang -ccc-host-triple i386-apple-darwin9 -miphoneos-version-min=3.0 -arch armv7 -flto -S -o - %s | FileCheck %s // CHECK: @f0 // CHECK-NOT: ssp diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c index 0a89895..4484468 100644 --- a/test/Driver/darwin-ld.c +++ b/test/Driver/darwin-ld.c @@ -70,3 +70,15 @@ // LINK_IPHONE_3_1: ld" // LINK_IPHONE_3_1-NOT: -lbundle1.o // LINK_IPHONE_3_1: -lSystem + +// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -fpie %t.o 2> %t.log +// RUN: FileCheck -check-prefix=LINK_EXPLICIT_PIE %s < %t.log +// +// LINK_EXPLICIT_PIE: ld" +// LINK_EXPLICIT_PIE: "-pie" + +// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -fno-pie %t.o 2> %t.log +// RUN: FileCheck -check-prefix=LINK_EXPLICIT_NO_PIE %s < %t.log +// +// LINK_EXPLICIT_NO_PIE: ld" +// LINK_EXPLICIT_NO_PIE: "-no_pie" diff --git a/test/Frontend/darwin-version.c b/test/Frontend/darwin-version.c index 1c866ee..151d3a9f 100644 --- a/test/Frontend/darwin-version.c +++ b/test/Frontend/darwin-version.c @@ -1,4 +1,7 @@ // RUN: %clang -ccc-host-triple armv6-apple-darwin9 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0 +// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1 +// RUN: %clang -ccc-host-triple armv6-apple-darwin9 -miphoneos-version-min=3.0 -dM -E -o %t %s // RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '30000' | count 1 // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | count 0 // RUN: %clang -ccc-host-triple armv6-apple-darwin9 -miphoneos-version-min=2.0 -dM -E -o %t %s diff --git a/test/Index/c-index-api-loadTU-test.m b/test/Index/c-index-api-loadTU-test.m index 22875db..4e5eed4 100644 --- a/test/Index/c-index-api-loadTU-test.m +++ b/test/Index/c-index-api-loadTU-test.m @@ -66,6 +66,10 @@ int main (int argc, const char * argv[]) { - (IBAction) actionMethod:(id)arg; @end +typedef struct X0 X1; +struct X0; +struct X0 {}; + // CHECK: c-index-api-loadTU-test.m:4:12: ObjCInterfaceDecl=Foo:4:12 Extent=[4:1 - 12:5] // CHECK: c-index-api-loadTU-test.m:6:32: ObjCIvarDecl=myoutlet:6:32 (Definition) Extent=[6:32 - 6:40] // CHECK: <invalid loc>:0:0: attribute(iboutlet)= diff --git a/test/Makefile b/test/Makefile index 5bb50c6..ba3a640 100644 --- a/test/Makefile +++ b/test/Makefile @@ -50,4 +50,8 @@ lit.site.cfg: FORCE clean:: @ find . -name Output | xargs rm -fr +# Daniel hates Chris. +chris-lit: + make LIT_ARGS='-j16 -s' + .PHONY: all report clean diff --git a/test/PCH/pchpch.c b/test/PCH/pchpch.c new file mode 100644 index 0000000..d68a6ad --- /dev/null +++ b/test/PCH/pchpch.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pch -o %t1 %S/pchpch1.h +// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pch -o %t2 %S/pchpch2.h -include-pch %t1 +// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only %s -include-pch %t2 + +// The purpose of this test is to make sure that a PCH created while including +// an existing PCH can be loaded. diff --git a/test/PCH/pchpch1.h b/test/PCH/pchpch1.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/PCH/pchpch1.h diff --git a/test/PCH/pchpch2.h b/test/PCH/pchpch2.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/PCH/pchpch2.h diff --git a/test/Sema/block-call.c b/test/Sema/block-call.c index 28e6c68..27e4cfc 100644 --- a/test/Sema/block-call.c +++ b/test/Sema/block-call.c @@ -13,10 +13,9 @@ int main() { int (^IFP) () = PFR; // OK - const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int const (^)()' with an expression of type 'int (^)()'}} \ - // expected-warning{{type qualifier on return type has no effect}} + const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int const (^)()' with an expression of type 'int (^)()'}} - const int (^CICC) () = CIC; // expected-warning{{type qualifier on return type has no effect}} + const int (^CICC) () = CIC; int * const (^IPCC) () = 0; diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c index 33fd183..5a4ec01 100644 --- a/test/Sema/block-return.c +++ b/test/Sema/block-return.c @@ -109,10 +109,9 @@ void foo6() { void foo7() { - const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int const (^)(void)' with an expression of type 'int (^)(void)'}} \ - // expected-warning{{type qualifier on return type has no effect}} + const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int const (^)(void)' with an expression of type 'int (^)(void)'}} - const int (^CC) (void) = ^const int{ const int i = 1; return i; }; // expected-warning{{type qualifier on return type has no effect}} + const int (^CC) (void) = ^const int{ const int i = 1; return i; }; int i; diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c index b22b522..9d3da90 100644 --- a/test/Sema/exprs.c +++ b/test/Sema/exprs.c @@ -142,3 +142,8 @@ void test19() { *(volatile int*)0 = 0; // Ok. } +int test20(int x) { + return x && 4; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}} + + return x && sizeof(int) == 4; // no warning. +} diff --git a/test/Sema/i-c-e.c b/test/Sema/i-c-e.c index c86a93f..eb77bbe 100644 --- a/test/Sema/i-c-e.c +++ b/test/Sema/i-c-e.c @@ -51,7 +51,8 @@ char z[__builtin_constant_p(4) ? 1 : -1]; // Comma tests int comma1[0?1,2:3]; // expected-warning {{expression result unused}} -int comma2[1||(1,2)]; // expected-warning {{expression result unused}} +int comma2[1||(1,2)]; // expected-warning {{expression result unused}} \ + // expected-warning {{use of logical || with constant operand}} int comma3[(1,2)]; // expected-warning {{size of static array must be an integer constant expression}} \ // expected-warning {{expression result unused}} diff --git a/test/Sema/return.c b/test/Sema/return.c index 2d23e08..54c3406 100644 --- a/test/Sema/return.c +++ b/test/Sema/return.c @@ -1,4 +1,4 @@ -// RUN: %clang %s -fsyntax-only -Wreturn-type -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value +// RUN: %clang %s -fsyntax-only -Wignored-qualifiers -Wreturn-type -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value // clang emits the following warning by default. // With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the @@ -239,3 +239,6 @@ int test_static_inline(int x) { } static inline int si_forward() {} // expected-warning{{control reaches end of non-void function}} +// Test warnings on ignored qualifiers on return types. +const int ignored_c_quals(); // expected-warning{{'const' type qualifier on return type has no effect}} +const volatile int ignored_cv_quals(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}} diff --git a/test/Sema/struct-cast.c b/test/Sema/struct-cast.c index 3456665..30ef892 100644 --- a/test/Sema/struct-cast.c +++ b/test/Sema/struct-cast.c @@ -5,7 +5,7 @@ struct S { int two; }; -struct S const foo(void); // expected-warning{{type qualifier on return type has no effect}} +struct S const foo(void); struct S tmp; diff --git a/test/Sema/switch.c b/test/Sema/switch.c index bb48229..4e39e0f 100644 --- a/test/Sema/switch.c +++ b/test/Sema/switch.c @@ -50,12 +50,14 @@ void test4() } switch (cond) { - case g() && 0: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}} + case g() && 0: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}} \ + expected-warning {{use of logical && with constant operand}} break; } switch (cond) { - case 0 ... g() || 1: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}} + case 0 ... g() || 1: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}} \\ + expected-warning {{use of logical || with constant operand}} break; } } diff --git a/test/SemaCXX/ambig-user-defined-conversions.cpp b/test/SemaCXX/ambig-user-defined-conversions.cpp index 9811859..fdb399b 100644 --- a/test/SemaCXX/ambig-user-defined-conversions.cpp +++ b/test/SemaCXX/ambig-user-defined-conversions.cpp @@ -17,7 +17,7 @@ namespace test0 { void func(const char ci, const B b); // expected-note {{candidate function}} void func(const B b, const int ci); // expected-note {{candidate function}} - const int Test1() { // expected-warning{{type qualifier on return type has no effect}} + const int Test1() { func(b1, f()); // expected-error {{call to 'func' is ambiguous}} return f(); // expected-error {{conversion from 'test0::B' to 'int const' is ambiguous}} diff --git a/test/SemaCXX/bool.cpp b/test/SemaCXX/bool.cpp index 44e17ce..726fa6c 100644 --- a/test/SemaCXX/bool.cpp +++ b/test/SemaCXX/bool.cpp @@ -25,6 +25,6 @@ void static_assert_arg_is_bool(T x) { void test2() { int n = 2; - static_assert_arg_is_bool(n && 4); - static_assert_arg_is_bool(n || 5); + static_assert_arg_is_bool(n && 4); // expected-warning {{use of logical && with constant operand}} + static_assert_arg_is_bool(n || 5); // expected-warning {{use of logical || with constant operand}} } diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp index f37ccc8..065179b 100644 --- a/test/SemaCXX/conditional-expr.cpp +++ b/test/SemaCXX/conditional-expr.cpp @@ -288,11 +288,11 @@ namespace PR7598 { v = 1, }; - const Enum g() { // expected-warning{{type qualifier on return type has no effect}} + const Enum g() { return v; } - const volatile Enum g2() { // expected-warning{{'const volatile' type qualifiers on return type have no effect}} + const volatile Enum g2() { return v; } diff --git a/test/SemaCXX/cv-unqual-rvalues.cpp b/test/SemaCXX/cv-unqual-rvalues.cpp new file mode 100644 index 0000000..ed76ced --- /dev/null +++ b/test/SemaCXX/cv-unqual-rvalues.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// PR7463: Make sure that when we have an rvalue, it does not have +// cv-qualified non-class type. +template <typename T_> void g (T_&); // expected-note 7{{not viable}} + +template<const int X> void h() { + g(X); // expected-error{{no matching function for call to 'g'}} +} + +template<typename T, T X> void h2() { + g(X); // expected-error{{no matching function for call to 'g'}} +} + +void a(__builtin_va_list x) { + g(__builtin_va_arg(x, const int)); // expected-error{{no matching function for call to 'g'}} + g((const int)0); // expected-error{{no matching function for call to 'g'}} + typedef const int cint; + g(cint(0)); // expected-error{{no matching function for call to 'g'}} + g(static_cast<const int>(1)); // expected-error{{no matching function for call to 'g'}} + g(reinterpret_cast<int *const>(0)); // expected-error{{no matching function for call to 'g'}} + h<0>(); + h2<const int, 0>(); // expected-note{{instantiation of}} +} diff --git a/test/SemaCXX/friend.cpp b/test/SemaCXX/friend.cpp index 65e0da7..30abcbb 100644 --- a/test/SemaCXX/friend.cpp +++ b/test/SemaCXX/friend.cpp @@ -44,7 +44,7 @@ namespace test2 { // PR5134 namespace test3 { class Foo { - friend const int getInt(int inInt = 0); // expected-warning{{'const' type qualifier on return type has no effect}} + friend const int getInt(int inInt = 0); }; } diff --git a/test/SemaCXX/return.cpp b/test/SemaCXX/return.cpp index e682fdf..6bdbe52 100644 --- a/test/SemaCXX/return.cpp +++ b/test/SemaCXX/return.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify +// RUN: %clang_cc1 %s -fsyntax-only -Wignored-qualifiers -verify int test1() { throw; @@ -16,3 +16,13 @@ template<typename T> T h() { return 17; } + +// Don't warn on cv-qualified class return types, only scalar return types. +namespace ignored_quals { +struct S {}; +const S class_c(); +const volatile S class_cv(); + +const int scalar_c(); // expected-warning{{'const' type qualifier on return type has no effect}} +const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}} +} diff --git a/test/SemaCXX/switch.cpp b/test/SemaCXX/switch.cpp index fc13630..54240dc 100644 --- a/test/SemaCXX/switch.cpp +++ b/test/SemaCXX/switch.cpp @@ -8,7 +8,8 @@ void test() { } int n = 3; - switch (n && 1) { // expected-warning {{bool}} + switch (n && 1) { // expected-warning {{bool}} \ + // expected-warning {{use of logical && with constant operand}} case 1: break; } diff --git a/test/SemaObjC/default-synthesize.m b/test/SemaObjC/default-synthesize.m index 283ad26..0586dae 100644 --- a/test/SemaObjC/default-synthesize.m +++ b/test/SemaObjC/default-synthesize.m @@ -103,3 +103,15 @@ @implementation C (Category) // expected-note 2 {{implementation is here}} @end +// Don't complain if a property is already @synthesized by usr. +@interface D +{ +} +@property int PROP; +@end + +@implementation D +- (int) Meth { return self.PROP; } +@synthesize PROP=IVAR; +@end + diff --git a/test/SemaObjC/method-sentinel-attr.m b/test/SemaObjC/method-sentinel-attr.m index 08358cc..6ec362f 100644 --- a/test/SemaObjC/method-sentinel-attr.m +++ b/test/SemaObjC/method-sentinel-attr.m @@ -15,6 +15,12 @@ - (void) foo10 : (int)x, ... __attribute__ ((__sentinel__(1,1))); - (void) foo11 : (int)x, ... __attribute__ ((__sentinel__(1,1,3))); // expected-error {{attribute requires 0, 1 or 2 argument(s)}} - (void) foo12 : (int)x, ... ATTR; // expected-note {{method has been explicitly marked sentinel here}} + +// rdar:// 7975788 +- (id) foo13 : (id)firstObj, ... __attribute__((sentinel(0,1))); +- (id) foo14 : (id)firstObj : (Class)secondObj, ... __attribute__((sentinel(0,1))); +- (id) foo15 : (id*)firstObj, ... __attribute__((sentinel(0,1))); +- (id) foo16 : (id**)firstObj, ... __attribute__((sentinel(0,1))); @end int main () @@ -33,5 +39,11 @@ int main () [p foo7:1, NULL]; // ok [p foo12:1]; // expected-warning {{not enough variable arguments in 'foo12:' declaration to fit a sentinel}} + + // rdar:// 7975788 + [ p foo13 : NULL]; + [ p foo14 : 0 : NULL]; + [ p foo16 : NULL]; + [ p foo15 : NULL]; } diff --git a/test/SemaObjC/property-10.m b/test/SemaObjC/property-10.m index bd07df6..0119273 100644 --- a/test/SemaObjC/property-10.m +++ b/test/SemaObjC/property-10.m @@ -20,3 +20,9 @@ @property(nonatomic,copy) int (*includeMailboxCondition2)(); // expected-error {{property with 'copy' attribute must be of object type}} @end + +@interface I0() +@property (retain) int PROP; // expected-error {{property with 'retain' attribute must be of object type}} +@property(nonatomic,copy) int (*PROP1)(); // expected-error {{property with 'copy' attribute must be of object type}} +@end + diff --git a/test/SemaTemplate/deduction-crash.cpp b/test/SemaTemplate/deduction-crash.cpp new file mode 100644 index 0000000..1860c75 --- /dev/null +++ b/test/SemaTemplate/deduction-crash.cpp @@ -0,0 +1,59 @@ +// RUN: %clang_cc1 -fsyntax-only %s 2>&1| FileCheck %s + +// PR7511 + +// Note that the error count below doesn't matter. We just want to +// make sure that the parser doesn't crash. +// CHECK: 16 errors +template<a> +struct int_; + +template<a> +template<int,typename T1,typename> +struct ac +{ + typedef T1 ae +}; + +template<class>struct aaa +{ + typedef ac<1,int,int>::ae ae +}; + +template<class> +struct state_machine +{ + typedef aaa<int>::ae aaa; + int start() + { + ant(0); + } + + template<class> + struct region_processing_helper + { + template<class,int=0> + struct In; + + template<int my> + struct In<a::int_<aaa::a>,my>; + + template<class Event> + int process(Event) + { + In<a::int_<0> > a; + } + } + template<class Event> + int ant(Event) + { + region_processing_helper<int>* helper; + helper->process(0) + } +}; + +int a() +{ + state_machine<int> p; + p.ant(0); +} diff --git a/test/SemaTemplate/deduction.cpp b/test/SemaTemplate/deduction.cpp index 25ffb67..e8ff8d3 100644 --- a/test/SemaTemplate/deduction.cpp +++ b/test/SemaTemplate/deduction.cpp @@ -101,7 +101,7 @@ namespace PR6257 { // PR7463 namespace PR7463 { - const int f (); // expected-warning{{type qualifier on return type has no effect}} + const int f (); template <typename T_> void g (T_&); // expected-note{{T_ = int}} void h (void) { g(f()); } // expected-error{{no matching function for call}} } |