diff options
Diffstat (limited to 'test')
54 files changed, 570 insertions, 49 deletions
diff --git a/test/Analysis/NoReturn.m b/test/Analysis/NoReturn.m index a43f99b..5f5ce28 100644 --- a/test/Analysis/NoReturn.m +++ b/test/Analysis/NoReturn.m @@ -1,5 +1,3 @@ -// RUN: clang-cc -analyze -checker-simple -analyzer-store=basic -analyzer-constraints=basic -verify %s && -// RUN: clang-cc -analyze -checker-simple -analyzer-store=basic -analyzer-constraints=range -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s && diff --git a/test/Analysis/ObjCProperties.m b/test/Analysis/ObjCProperties.m index 7787a1d..3ad2569 100644 --- a/test/Analysis/ObjCProperties.m +++ b/test/Analysis/ObjCProperties.m @@ -1,5 +1,3 @@ -// RUN: clang-cc -analyze -checker-simple -analyzer-store=basic -analyzer-constraints=basic %s -verify && -// RUN: clang-cc -analyze -checker-simple -analyzer-store=basic -analyzer-constraints=range %s -verify && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic %s -verify && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range %s -verify && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic %s -verify && diff --git a/test/Analysis/array-struct.c b/test/Analysis/array-struct.c index 0ad7ae7..438e1cc 100644 --- a/test/Analysis/array-struct.c +++ b/test/Analysis/array-struct.c @@ -1,4 +1,3 @@ -// RUN: clang-cc -analyze -checker-simple -analyzer-store=basic -analyzer-constraints=basic -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s diff --git a/test/Analysis/complex.c b/test/Analysis/complex.c index f29fc70..cef6245 100644 --- a/test/Analysis/complex.c +++ b/test/Analysis/complex.c @@ -1,4 +1,3 @@ -// RUN: clang-cc -analyze -checker-simple -analyzer-store=basic -analyzer-constraints=basic -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s && diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c index c100344..6d3b7e6 100644 --- a/test/Analysis/dead-stores.c +++ b/test/Analysis/dead-stores.c @@ -1,6 +1,4 @@ // RUN: clang-cc -analyze -warn-dead-stores -verify %s && -// RUN: clang-cc -analyze -checker-simple -analyzer-store=basic -analyzer-constraints=basic -warn-dead-stores -verify %s && -// RUN: clang-cc -analyze -checker-simple -analyzer-store=basic -analyzer-constraints=range -warn-dead-stores -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -warn-dead-stores -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -warn-dead-stores -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -warn-dead-stores -verify %s && diff --git a/test/Analysis/elementtype.c b/test/Analysis/elementtype.c index 10328e6..2bdaad4 100644 --- a/test/Analysis/elementtype.c +++ b/test/Analysis/elementtype.c @@ -1,4 +1,4 @@ -// RUN: clang-cc -analyze -checker-simple -analyzer-store=region %s +// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region %s typedef struct added_obj_st { int type; diff --git a/test/Analysis/exercise-ps.c b/test/Analysis/exercise-ps.c index 08842b1..c309349 100644 --- a/test/Analysis/exercise-ps.c +++ b/test/Analysis/exercise-ps.c @@ -1,4 +1,3 @@ -// RUN: clang-cc -analyze -checker-simple -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s // diff --git a/test/Analysis/func.c b/test/Analysis/func.c index a018d0a..2b4e7b0 100644 --- a/test/Analysis/func.c +++ b/test/Analysis/func.c @@ -1,5 +1,3 @@ -// RUN: clang-cc -analyze -checker-simple -verify %s && -// RUN: clang-cc -analyze -checker-simple -analyzer-store=region -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index 09b9c2f..6e20741 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -1,7 +1,7 @@ -// RUN: clang-cc -analyze -std=gnu99 -checker-simple -verify %s && -// RUN: clang-cc -analyze -std=gnu99 -checker-simple -verify %s -analyzer-constraints=range && -// RUN: clang-cc -analyze -std=gnu99 -checker-simple -analyzer-store=region -analyzer-purge-dead=false -verify %s && -// RUN: clang-cc -analyze -std=gnu99 -checker-cfref -analyzer-store=region -verify %s +// RUN: clang-cc -analyze -std=gnu99 -checker-cfref -verify %s -analyzer-constraints=basic -analyzer-store=basic && +// RUN: clang-cc -analyze -std=gnu99 -checker-cfref -verify %s -analyzer-constraints=range -analyzer-store=basic && +// RUN: clang-cc -analyze -std=gnu99 -checker-cfref -analyzer-store=region -analyzer-constraints=range -analyzer-purge-dead=false -verify %s && +// RUN: clang-cc -analyze -std=gnu99 -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s #include<stdint.h> #include <assert.h> diff --git a/test/Analysis/outofbound.c b/test/Analysis/outofbound.c index 953075f..527a311 100644 --- a/test/Analysis/outofbound.c +++ b/test/Analysis/outofbound.c @@ -1,4 +1,4 @@ -// RUN: clang-cc -analyze -checker-simple -analyzer-store=region -verify %s +// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s char f1() { char* s = "abcd"; diff --git a/test/Analysis/ptr-arith.c b/test/Analysis/ptr-arith.c index 34840c7..4f2c7d9 100644 --- a/test/Analysis/ptr-arith.c +++ b/test/Analysis/ptr-arith.c @@ -1,4 +1,3 @@ -// RUN: clang-cc -analyze -checker-simple -analyzer-store=region -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify -triple i686-apple-darwin9 %s diff --git a/test/Analysis/region-only-test.c b/test/Analysis/region-only-test.c index fdc7404..64d3fcd 100644 --- a/test/Analysis/region-only-test.c +++ b/test/Analysis/region-only-test.c @@ -1,4 +1,4 @@ -// RUN: clang-cc -analyze -checker-simple -analyzer-store=region -verify %s +// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s // Region store must be enabled for tests in this file. diff --git a/test/Analysis/stack-addr-ps.c b/test/Analysis/stack-addr-ps.c index 4bc9a7d..2f7a4bd 100644 --- a/test/Analysis/stack-addr-ps.c +++ b/test/Analysis/stack-addr-ps.c @@ -1,4 +1,3 @@ -// RUN: clang-cc -analyze -checker-simple -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s diff --git a/test/Analysis/uninit-msg-expr.m b/test/Analysis/uninit-msg-expr.m index 161ab80..5ec878e 100644 --- a/test/Analysis/uninit-msg-expr.m +++ b/test/Analysis/uninit-msg-expr.m @@ -1,4 +1,3 @@ -// RUN: clang-cc -analyze -checker-simple -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -verify %s && // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s diff --git a/test/Analysis/uninit-vals-ps-region.c b/test/Analysis/uninit-vals-ps-region.c index 6f3762e..32f787d 100644 --- a/test/Analysis/uninit-vals-ps-region.c +++ b/test/Analysis/uninit-vals-ps-region.c @@ -1,4 +1,4 @@ -// RUN: clang-cc -analyze -checker-simple -analyzer-store=region -verify %s +// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s struct s { int data; diff --git a/test/CXX/class/class.local/p1.cpp b/test/CXX/class/class.local/p1.cpp new file mode 100644 index 0000000..8a84f5d --- /dev/null +++ b/test/CXX/class/class.local/p1.cpp @@ -0,0 +1,18 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +int x; +void f() +{ + static int s; + int x; // expected-note{{'x' declared here}} + extern int g(); + + struct local { + int g() { return x; } // expected-error{{reference to local variable 'x' declared in enclosed function 'f'}} + int h() { return s; } + int k() { return :: x; } + int l() { return g(); } + }; +} + +local* p = 0; // expected-error{{unknown type name 'local'}} diff --git a/test/CXX/class/class.local/p2.cpp b/test/CXX/class/class.local/p2.cpp new file mode 100644 index 0000000..854415f --- /dev/null +++ b/test/CXX/class/class.local/p2.cpp @@ -0,0 +1,12 @@ +// RUN: clang-cc -fsyntax-only -verify %s -faccess-control + +struct A { }; + +void f() { + struct B : private A {}; // expected-note{{'private' inheritance specifier here}} + + B b; + + A *a = &b; // expected-error{{conversion from 'struct B' to inaccessible base class 'struct A'}} \ + expected-error{{incompatible type initializing 'struct B *', expected 'struct A *'}} +} diff --git a/test/CXX/class/class.local/p3.cpp b/test/CXX/class/class.local/p3.cpp new file mode 100644 index 0000000..d888a6d --- /dev/null +++ b/test/CXX/class/class.local/p3.cpp @@ -0,0 +1,30 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +void f1() { + struct X { + struct Y; + }; + + struct X::Y { + void f() {} + }; +} + +void f2() { + struct X { + struct Y; + + struct Y { + void f() {} + }; + }; +} + +// A class nested within a local class is a local class. +void f3(int a) { // expected-note{{'a' declared here}} + struct X { + struct Y { + int f() { return a; } // expected-error{{reference to local variable 'a' declared in enclosed function 'f3'}} + }; + }; +}
\ No newline at end of file diff --git a/test/CXX/class/class.local/p4.cpp b/test/CXX/class/class.local/p4.cpp new file mode 100644 index 0000000..40702ad --- /dev/null +++ b/test/CXX/class/class.local/p4.cpp @@ -0,0 +1,10 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +void f() { + struct X { + static int a; // expected-error {{static data member 'a' not allowed in local class 'X'}} + int b; + + static void f() { } + }; +}
\ No newline at end of file diff --git a/test/CXX/class/class.nested.type/p1.cpp b/test/CXX/class/class.nested.type/p1.cpp new file mode 100644 index 0000000..33bf4b4 --- /dev/null +++ b/test/CXX/class/class.nested.type/p1.cpp @@ -0,0 +1,11 @@ +class X { +public: + typedef int I; + class Y { }; + I a; +}; + +I b; // expected-error{{unknown type name 'I'}} +Y c; // expected-error{{unknown type name 'Y'}} +X::Y d; +X::I e;
\ No newline at end of file diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp new file mode 100644 index 0000000..fa3101c --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp @@ -0,0 +1,13 @@ +// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x +void f() { + auto a = a; // expected-error{{variable 'a' declared with 'auto' type cannot appear in its own initializer}} +} + +struct S { auto a; }; // expected-error{{'auto' not allowed in struct member}} + +void f(auto a) // expected-error{{'auto' not allowed in function prototype}} +{ + try { } catch (auto a) { } // expected-error{{'auto' not allowed in exception declaration}} +} + +template <auto a = 10> class C { }; // expected-error{{'auto' not allowed in template parameter}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp new file mode 100644 index 0000000..d97f2b8 --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp @@ -0,0 +1,21 @@ +// RUN: clang-cc -fsyntax-only -std=c++0x -verify %s + +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +const int&& foo(); +int i; +struct A { double x; }; +const A* a = new A(); + +static_assert(is_same<decltype(foo()), const int&&>::value, ""); +static_assert(is_same<decltype(i), int>::value, ""); +static_assert(is_same<decltype(a->x), double>::value, ""); +static_assert(is_same<decltype((a->x)), const double&>::value, ""); diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp new file mode 100644 index 0000000..9d85534 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp @@ -0,0 +1,6 @@ +// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x + +void f() { + int b[5]; + auto a[5] = b; // expected-error{{'a' declared as array of 'auto'}} +} diff --git a/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp b/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp new file mode 100644 index 0000000..b482955 --- /dev/null +++ b/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp @@ -0,0 +1,27 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +template<typename T> void f0(T) { } // expected-note{{previous}} +template<class U> void f0(U) { } // expected-error{{redefinition}} + +template<int I> void f0() { } // expected-note{{previous}} +template<int> void f0() { } // expected-error{{redefinition}} + +typedef int INT; + +template<template<class T, T Value1, INT> class X> + void f0() { } // expected-note{{previous}} +template<template<typename T, T Value1, int> class> + void f0() { } // expected-error{{redefinition}} + +template<typename T> +struct MetaFun; + +template<typename T> + typename MetaFun<T*>::type f0(const T&) { } // expected-note{{previous}} +template<class U> + typename MetaFun<U*>::type f0(const U&) { } // expected-error{{redefinition}} + +// FIXME: We need canonicalization of expressions for this to work +// template<int> struct A { }; +// template<int I> void f0(A<I>) { } // Xpected-note{{previous}} +// template<int J> void f0(A<J>) { } // Xpected-error{{redefinition}}
\ No newline at end of file diff --git a/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp b/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp new file mode 100644 index 0000000..de1a883 --- /dev/null +++ b/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp @@ -0,0 +1,13 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +// All of these function templates are distinct. +template<typename T> void f0(T) { } +template<typename T, typename U> void f0(T) { } +template<typename T, typename U> void f0(U) { } +void f0(); +template<typename T> void f0(T*); +void f0(int); +template<int I> void f0(); +template<typename T> void f0(); + + diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp new file mode 100644 index 0000000..beb6aad --- /dev/null +++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp @@ -0,0 +1,28 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +template<typename T> struct A { }; + +template<typename T> A<T> f0(T*); + +void test_f0(int *ip, float const *cfp) { + A<int> a0 = f0(ip); + A<const float> a1 = f0(cfp); +} + +template<typename T> void f1(T*, int); + +void test_f1(int *ip, float fv) { + f1(ip, fv); +} + +template<typename T> void f2(T*, T*); + +struct ConvToIntPtr { + operator int*() const; +}; + +void test_f2(int *ip, float *fp) { + f2(ip, ConvToIntPtr()); // expected-error{{no matching function}} + f2(ip, ip); // okay + f2(ip, fp); // expected-error{{no matching function}} +} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p2.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p2.cpp new file mode 100644 index 0000000..6f27d36 --- /dev/null +++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p2.cpp @@ -0,0 +1,31 @@ +// RUN: clang-cc -fsyntax-only -verify %s +template<typename T> struct A { }; + +// bullet 1 +template<typename T> A<T> f0(T* ptr); + +void test_f0_bullet1() { + int arr0[6]; + A<int> a0 = f0(arr0); + const int arr1[] = { 1, 2, 3, 4, 5 }; + A<const int> a1 = f0(arr1); +} + +// bullet 2 +int g0(int, int); +float g1(float); + +void test_f0_bullet2() { + A<int(int, int)> a0 = f0(g0); + A<float(float)> a1 = f0(g1); +} + +// bullet 3 +struct X { }; +const X get_X(); + +template<typename T> A<T> f1(T); + +void test_f1_bullet3() { + A<X> a0 = f1(get_X()); +} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp new file mode 100644 index 0000000..c014c66 --- /dev/null +++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp @@ -0,0 +1,60 @@ +// RUN: clang-cc -fsyntax-only %s + +template<typename T> struct A { }; + +// Top-level cv-qualifiers of P's type are ignored for type deduction. +template<typename T> A<T> f0(const T); + +void test_f0(int i, const int ci) { + A<int> a0 = f0(i); + A<int> a1 = f0(ci); +} + +// If P is a reference type, the type referred to by P is used for type +// deduction. +template<typename T> A<T> f1(T&); + +void test_f1(int i, const int ci, volatile int vi) { + A<int> a0 = f1(i); + A<const int> a1 = f1(ci); + A<volatile int> a2 = f1(vi); +} + +template<typename T, unsigned N> struct B { }; +template<typename T, unsigned N> B<T, N> g0(T (&array)[N]); + +void test_g0() { + int array0[5]; + B<int, 5> b0 = g0(array0); + const int array1[] = { 1, 2, 3}; + B<const int, 3> b1 = g0(array1); +} + +template<typename T> B<T, 0> g1(const A<T>&); + +void test_g1(A<float> af) { + B<float, 0> b0 = g1(af); + B<int, 0> b1 = g1(A<int>()); +} + +// - If the original P is a reference type, the deduced A (i.e., the type +// referred to by the reference) can be more cv-qualified than the +// transformed A. +template<typename T> A<T> f2(const T&); + +void test_f2(int i, const int ci, volatile int vi) { + A<int> a0 = f2(i); + A<int> a1 = f2(ci); + A<volatile int> a2 = f2(vi); +} + +// - The transformed A can be another pointer or pointer to member type that +// can be converted to the deduced A via a qualification conversion (4.4). +template<typename T> A<T> f3(T * * const * const); + +void test_f3(int ***ip, volatile int ***vip) { + A<int> a0 = f3(ip); + A<volatile int> a1 = f3(vip); +} + +// FIXME: the next bullet requires a lot of effort. diff --git a/test/CodeGen/2009-06-16-inc_test.c b/test/CodeGen/2009-06-16-inc_test.c index b28f63a..e69de29 100644 --- a/test/CodeGen/2009-06-16-inc_test.c +++ b/test/CodeGen/2009-06-16-inc_test.c @@ -1,3 +0,0 @@ -// RUN: clang -c -g %s -o /dev/null -// PR 4228 -#include "2009-06-16-test.c" diff --git a/test/CodeGen/2009-06-16-test.c b/test/CodeGen/2009-06-16-test.c index 4189d06..e69de29 100644 --- a/test/CodeGen/2009-06-16-test.c +++ b/test/CodeGen/2009-06-16-test.c @@ -1,15 +0,0 @@ - -#ifndef TEST -#define TEST -#define INSIDE_RECURSION -#include "2009-06-16-test.c" -#undef INSIDE_RECURSION -#endif - -#ifndef INSIDE_RECURSION -int i; -#endif - -#ifdef INSIDE_RECURSION -int j; -#endif diff --git a/test/CodeGenObjC/deadcode_strip_used_var.m b/test/CodeGenObjC/deadcode_strip_used_var.m new file mode 100644 index 0000000..444cf76 --- /dev/null +++ b/test/CodeGenObjC/deadcode_strip_used_var.m @@ -0,0 +1,9 @@ +// RUN: clang-cc %s -emit-llvm -o %t -triple i386-apple-darwin10 && +// RUN: grep "llvm.used" %t | count 1 && +// RUN: clang-cc %s -emit-llvm -o %t -triple x86_64-apple-darwin10 && +// RUN: grep "llvm.used" %t | count 1 + + +__attribute__((used)) static int XXXXXX __attribute__ ((section ("__DATA,__Xinterpose"))) ; +__attribute__((used)) static int YYYY __attribute__ ((section ("__DATA,__Xinterpose"))) ; + diff --git a/test/Coverage/html-diagnostics.c b/test/Coverage/html-diagnostics.c index 6144f2f..e3db166 100644 --- a/test/Coverage/html-diagnostics.c +++ b/test/Coverage/html-diagnostics.c @@ -1,5 +1,5 @@ // RUN: rm -rf %t && -// RUN: clang-cc --html-diags=%t -checker-simple %s +// RUN: clang-cc --html-diags=%t -checker-cfref %s void f0(int x) { int *p = &x; diff --git a/test/Index/resolve-loc.c b/test/Index/resolve-loc.c new file mode 100644 index 0000000..d04b79b --- /dev/null +++ b/test/Index/resolve-loc.c @@ -0,0 +1,24 @@ +// RUN: clang-cc -emit-pch %s -o %t.ast && +// RUN: index-test %t.ast -point-at %s:15:8 | grep top_var && +// RUN: index-test %t.ast -point-at %s:17:15 | grep top_func_decl && +// RUN: index-test %t.ast -point-at %s:17:25 | grep param1 && +// RUN: index-test %t.ast -point-at %s:19:17 | grep top_func_def && +// RUN: index-test %t.ast -point-at %s:19:23 | grep param2 && +// RUN: index-test %t.ast -point-at %s:20:10 | grep local_var1 && +// RUN: index-test %t.ast -point-at %s:21:15 | grep for_var && +// RUN: index-test %t.ast -point-at %s:21:43 | grep top_func_def && +// RUN: index-test %t.ast -point-at %s:21:43 | grep '++for_var' && +// RUN: index-test %t.ast -point-at %s:22:9 | grep local_var2 && +// RUN: index-test %t.ast -point-at %s:22:30 | grep local_var2 && +// RUN: index-test %t.ast -point-at %s:22:30 | grep 'for_var + 1' + +int top_var; + +void top_func_decl(int param1); + +void top_func_def(int param2) { + int local_var1; + for (int for_var = 100; for_var < 500; ++for_var) { + int local_var2 = for_var + 1; + } +} diff --git a/test/Parser/check-syntax-1.m b/test/Parser/check-syntax-1.m index f4aa430..af1b7a8 100644 --- a/test/Parser/check-syntax-1.m +++ b/test/Parser/check-syntax-1.m @@ -2,3 +2,10 @@ int @interface bla ; // expected-error {{cannot combine with previous 'int' declaration specifier}} @end + +typedef float CGFloat; +@interface XNSNumber ++ (XNSNumber *) numberWithCGFloat : (CGFloat) float; // expected-error {{expected identifier}} \ + // expected-error {{ expected ';' after method prototype}} +@end + diff --git a/test/Parser/cxx-template-decl.cpp b/test/Parser/cxx-template-decl.cpp index 75b26a9..6955018 100644 --- a/test/Parser/cxx-template-decl.cpp +++ b/test/Parser/cxx-template-decl.cpp @@ -33,11 +33,11 @@ template <typename = int> class X2; // Forward declarations w/template template parameters template <template <typename> class T> class TTP1; template <template <typename> class> class TTP2; -template <template <typename> class T = foo> class TTP3; // FIXME:expected-error{{template argument for template template parameter must be a template}} -template <template <typename> class = foo> class TTP3; // FIXME:expected-error{{template argument for template template parameter must be a template}} +template <template <typename> class T = foo> class TTP3; // expected-error{{must be a class template}} +template <template <typename> class = foo> class TTP3; // expected-error{{must be a class template}} template <template <typename X, typename Y> class T> class TTP5; -// Forward declararations with non-type params +// Forward declarations with non-type params template <int> class NTP0; template <int N> class NTP1; template <int N = 5> class NTP2; diff --git a/test/Sema/attr-format_arg.c b/test/Sema/attr-format_arg.c new file mode 100644 index 0000000..6f95315 --- /dev/null +++ b/test/Sema/attr-format_arg.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +const char* f(const char *s) __attribute__((format_arg(1))); + +void g(const char *s) { + printf("%d", 123); + printf("%d %d", 123); // expected-warning{{more '%' conversions than data arguments}} + + printf(f("%d"), 123); + printf(f("%d %d"), 123); // expected-warning{{more '%' conversions than data arguments}} +} diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c new file mode 100644 index 0000000..8aa762e --- /dev/null +++ b/test/Sema/ext_vector_casts.c @@ -0,0 +1,23 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +typedef __attribute__(( ext_vector_type(2) )) float float2; +typedef __attribute__(( ext_vector_type(4) )) int int4; +typedef __attribute__(( ext_vector_type(4) )) float float4; +typedef float t3 __attribute__ ((vector_size (16))); + +static void test() { + float2 vec2; + float4 vec4, vec4_2; + int4 ivec4; + t3 vec4_3; + + vec4 = (float4)5.0f; + vec4 = (float4)5; + vec4 = (float4)vec4_3; + + ivec4 = (int4)5.0f; + ivec4 = (int4)5; + ivec4 = (int4)vec4_3; + + vec4 = (float4)vec2; // expected-error {{invalid conversion between ext-vector type 'float4' and 'float2'}} +} diff --git a/test/Sema/ext_vector_components.c b/test/Sema/ext_vector_components.c index 422a9e6..4890302 100644 --- a/test/Sema/ext_vector_components.c +++ b/test/Sema/ext_vector_components.c @@ -3,11 +3,15 @@ typedef __attribute__(( ext_vector_type(2) )) float float2; typedef __attribute__(( ext_vector_type(3) )) float float3; typedef __attribute__(( ext_vector_type(4) )) float float4; +typedef __attribute__(( ext_vector_type(16) )) float float16; + +static float4 vec4_0 = (float4)0.5f; static void test() { float2 vec2, vec2_2; float3 vec3; float4 vec4, vec4_2, *vec4p; + float16 vec16; float f; vec2.z; // expected-error {{vector component access exceeds type 'float2'}} @@ -16,6 +20,7 @@ static void test() { vec4.xyzc; // expected-error {{illegal vector component name 'c'}} vec4.s01z; // expected-error {{illegal vector component name 'z'}} vec2 = vec4.s01; // legal, shorten + vec2 = vec4.S01; // legal, shorten vec3 = vec4.xyz; // legal, shorten f = vec2.x; // legal, shorten @@ -32,6 +37,8 @@ static void test() { vec4 = (float4){ 1,2,3,4 }; vec4.xy.w; // expected-error {{vector component access exceeds type 'float2'}} vec4.s06; // expected-error {{vector component access exceeds type 'float4'}} + vec4.x = vec16.sf; + vec4.x = vec16.sF; vec4p->yz = vec4p->xy; } diff --git a/test/Sema/vector-cast.c b/test/Sema/vector-cast.c index bd09e69..9460cac 100644 --- a/test/Sema/vector-cast.c +++ b/test/Sema/vector-cast.c @@ -11,9 +11,9 @@ void f() t3 v3; v2 = (t2)v1; // -expected-error {{invalid conversion between vector type \ -'t1' and 't2' of different size}} - v1 = (t1)v2; // -expected-error {{invalid conversion between vector type \ 't2' and 't1' of different size}} + v1 = (t1)v2; // -expected-error {{invalid conversion between vector type \ +'t1' and 't2' of different size}} v3 = (t3)v2; v1 = (t1)(char *)10; // -expected-error {{invalid conversion between vector \ diff --git a/test/SemaCXX/auto-cxx0x.cpp b/test/SemaCXX/auto-cxx0x.cpp new file mode 100644 index 0000000..33156ef --- /dev/null +++ b/test/SemaCXX/auto-cxx0x.cpp @@ -0,0 +1,5 @@ +// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x +void f() { + auto int a; // expected-error{{cannot combine with previous 'auto' declaration specifier}} + int auto b; // expected-error{{cannot combine with previous 'int' declaration specifier}} +} diff --git a/test/SemaCXX/auto-cxx98.cpp b/test/SemaCXX/auto-cxx98.cpp new file mode 100644 index 0000000..14670cd --- /dev/null +++ b/test/SemaCXX/auto-cxx98.cpp @@ -0,0 +1,5 @@ +// RUN: clang-cc -fsyntax-only -verify %s -std=c++98 +void f() { + auto int a; + int auto b; +} diff --git a/test/SemaCXX/basic_lookup_argdep.cpp b/test/SemaCXX/basic_lookup_argdep.cpp index 486a688..677df828 100644 --- a/test/SemaCXX/basic_lookup_argdep.cpp +++ b/test/SemaCXX/basic_lookup_argdep.cpp @@ -58,3 +58,16 @@ namespace M { void test_operator_name_adl(N::X x) { (void)operator+(x, x); } + +struct Z { }; +int& f(Z); + +namespace O { + char &f(); + void test_global_scope_adl(Z z) { + { + int& ir = f(z); + } + } +} + diff --git a/test/SemaCXX/decltype-pr4444.cpp b/test/SemaCXX/decltype-pr4444.cpp new file mode 100644 index 0000000..8b2f584 --- /dev/null +++ b/test/SemaCXX/decltype-pr4444.cpp @@ -0,0 +1,6 @@ +// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x + +template<typename T, T t> +struct TestStruct { + typedef decltype(t+2) sum_type; +}; diff --git a/test/SemaCXX/decltype-pr4448.cpp b/test/SemaCXX/decltype-pr4448.cpp new file mode 100644 index 0000000..fbf5da1 --- /dev/null +++ b/test/SemaCXX/decltype-pr4448.cpp @@ -0,0 +1,8 @@ +// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x + +template< typename T, T t, decltype(t+2) v > +struct Convoluted {}; + +int test_array[5]; + +Convoluted< int *, test_array, nullptr > tarray; diff --git a/test/SemaCXX/default-assignment-operator.cpp b/test/SemaCXX/default-assignment-operator.cpp new file mode 100644 index 0000000..090ba3c --- /dev/null +++ b/test/SemaCXX/default-assignment-operator.cpp @@ -0,0 +1,74 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +class Base { // expected-error {{cannot define the implicit default assignment operator for 'class Base'}} \ + // expected-note {{synthesized method is first required here}} + int &ref; // expected-note {{declared at}} +}; + +class X : Base { // // expected-error {{cannot define the implicit default assignment operator for 'class X'}} +public: + X(); + const int cint; // expected-note {{declared at}} +}; + +struct Y : X { + Y(); + Y& operator=(const Y&); + Y& operator=(volatile Y&); + Y& operator=(const volatile Y&); + Y& operator=(Y&); +}; + +class Z : Y {}; + +Z z1; +Z z2; + +// Test1 +void f(X x, const X cx) { + x = cx; // expected-note {{synthesized method is first required here}} + x = cx; + z1 = z2; +} + +// Test2 +class T {}; +T t1; +T t2; + +void g() +{ + t1 = t2; +} + +// Test3 +class V { +public: + V(); + V &operator = (V &b); +}; + +class W : V {}; +W w1, w2; + +void h() +{ + w1 = w2; +} + +// Test4 + +class B1 { +public: + B1(); + B1 &operator = (B1 b); +}; + +class D1 : B1 {}; +D1 d1, d2; + +void i() +{ + d1 = d2; +} + diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp index 4c3ecee..8fff8a2 100644 --- a/test/SemaCXX/nested-name-spec.cpp +++ b/test/SemaCXX/nested-name-spec.cpp @@ -171,3 +171,26 @@ Y::foo y; // expected-error{{incomplete type 'struct Y' named in nested name spe X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}} \ // expected-error{{C++ requires a type specifier for all declarations}} \ // expected-error{{only constructors take base initializers}} + + + + +namespace somens { + struct a { }; +} + +template <typename T> +class foo { +}; + + +// PR4452 +// FIXME: This error recovery sucks. +foo<somens:a> a2; // expected-error {{unexpected namespace name 'somens': expected expression}} \ +expected-error {{C++ requires a type specifier for all declarations}} + +somens::a a3 = a2; + + + + diff --git a/test/SemaCXX/template-specialization.cpp b/test/SemaCXX/template-specialization.cpp index b3bb08d..e23a192 100644 --- a/test/SemaCXX/template-specialization.cpp +++ b/test/SemaCXX/template-specialization.cpp @@ -1,4 +1,5 @@ // RUN: clang-cc -fsyntax-only -verify %s +// XFAIL template<int N> void f(int (&array)[N]); template<> void f<1>(int (&array)[1]) { } diff --git a/test/SemaCXX/using-decl-1.cpp b/test/SemaCXX/using-decl-1.cpp new file mode 100644 index 0000000..2459f25 --- /dev/null +++ b/test/SemaCXX/using-decl-1.cpp @@ -0,0 +1,8 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +extern "C" { void f(bool); } + +namespace std { + using ::f; + inline void f() { return f(true); } +} diff --git a/test/SemaCXX/using-decl-pr4441.cpp b/test/SemaCXX/using-decl-pr4441.cpp new file mode 100644 index 0000000..6aa2b26 --- /dev/null +++ b/test/SemaCXX/using-decl-pr4441.cpp @@ -0,0 +1,8 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +namespace A { + struct B { }; + void operator+(B,B); +} + +using A::operator+; diff --git a/test/SemaCXX/using-decl-pr4450.cpp b/test/SemaCXX/using-decl-pr4450.cpp new file mode 100644 index 0000000..c3d5b83 --- /dev/null +++ b/test/SemaCXX/using-decl-pr4450.cpp @@ -0,0 +1,15 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +namespace A { + void g(); +} + +namespace X { + using A::g; +} + +void h() +{ + A::g(); + X::g(); +} diff --git a/test/SemaTemplate/implicit-instantiation-1.cpp b/test/SemaTemplate/implicit-instantiation-1.cpp index eecaf2f..b8f9622 100644 --- a/test/SemaTemplate/implicit-instantiation-1.cpp +++ b/test/SemaTemplate/implicit-instantiation-1.cpp @@ -1,5 +1,4 @@ // RUN: clang-cc -fsyntax-only -verify %s - template<typename T, typename U> struct X { T f(T x, U y) { return x + y; } @@ -14,3 +13,13 @@ void test(X<int, int> *xii, X<int*, int> *xpi, X<int, int*> *xip) { (void)xip->g(2, 0); // okay: does not instantiate } +template<typename T, typename U> +T add(T t, U u) { + return t + u; // expected-error{{invalid operands}} +} + +void test_add(char *cp, int i, int *ip) { + char* cp2 = add(cp, i); + add(cp, cp); // expected-note{{instantiation of}} + (void)sizeof(add(ip, ip)); +}
\ No newline at end of file diff --git a/test/SemaTemplate/operator-template.cpp b/test/SemaTemplate/operator-template.cpp new file mode 100644 index 0000000..3d041ec --- /dev/null +++ b/test/SemaTemplate/operator-template.cpp @@ -0,0 +1,14 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +// Make sure we accept this +template<class X>struct A{typedef X Y;}; +template<class X>bool operator==(A<X>,typename A<X>::Y); +int a(A<int> x) { return operator==(x,1); } + +// FIXME: The diagnostic here is a bit messed up +template<class X>struct B{typedef X Y;}; +template<class X>bool operator==(B<X>*,typename B<X>::Y); // \ +expected-error{{overloaded 'operator==' must have at least one parameter of class or enumeration type}} \ +expected-note{{in instantiation of default argument for 'operator==<int>' required here}} +int a(B<int> x) { return operator==(&x,1); } + diff --git a/test/SemaTemplate/temp_arg_template.cpp b/test/SemaTemplate/temp_arg_template.cpp index a5e9f75..f2ee66b 100644 --- a/test/SemaTemplate/temp_arg_template.cpp +++ b/test/SemaTemplate/temp_arg_template.cpp @@ -26,12 +26,12 @@ B<X> *a6; // expected-error{{template template argument has different template p C<Y> *a7; C<Ylong> *a8; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} -template<typename T> void f(int); +template<typename T> void f(int); // expected-note{{function template}} // FIXME: we're right to provide an error message, but it should say // that we need a class template. We won't get this right until name // lookup of 'f' returns a TemplateDecl. -A<f> *a9; // expected-error{{template argument for template template parameter must be a template}} +A<f> *a9; // expected-error{{template argument does not refer to}} // FIXME: The code below is ill-formed, because of the evil digraph '<:'. // We should provide a much better error message than we currently do. diff --git a/test/SemaTemplate/template-decl-fail.cpp b/test/SemaTemplate/template-decl-fail.cpp new file mode 100644 index 0000000..b136f62 --- /dev/null +++ b/test/SemaTemplate/template-decl-fail.cpp @@ -0,0 +1,3 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +template<typename T> typedef T X; // expected-error{{typedef cannot be a template}} |