diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-11-18 14:59:57 +0000 |
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-11-18 14:59:57 +0000 |
| commit | b3d5a323a5ca92ea73443499cee2f15db1ff0fb3 (patch) | |
| tree | 60a1694bec5a44d15456acc880cb2f91619f66aa /test/CXX | |
| parent | 8f57cb0305232cb53fff00ef151ca716766f3437 (diff) | |
Notes
Diffstat (limited to 'test/CXX')
| -rw-r--r-- | test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp | 35 | ||||
| -rw-r--r-- | test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp | 24 | ||||
| -rw-r--r-- | test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp | 67 | ||||
| -rw-r--r-- | test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp | 141 | ||||
| -rw-r--r-- | test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp | 44 | ||||
| -rw-r--r-- | test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp | 2 | ||||
| -rw-r--r-- | test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp | 2 | ||||
| -rw-r--r-- | test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp | 4 | ||||
| -rw-r--r-- | test/CXX/expr/expr.unary/expr.delete/p5.cpp | 34 | ||||
| -rw-r--r-- | test/CXX/special/class.free/p1.cpp | 11 | ||||
| -rw-r--r-- | test/CXX/special/class.free/p6.cpp | 11 | ||||
| -rw-r--r-- | test/CXX/temp/temp.param/p1.cpp | 2 | ||||
| -rw-r--r-- | test/CXX/temp/temp.param/p12.cpp | 4 | ||||
| -rw-r--r-- | test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp | 2 | ||||
| -rw-r--r-- | test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp | 5 |
15 files changed, 378 insertions, 10 deletions
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp b/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp new file mode 100644 index 000000000000..04aef1e39e40 --- /dev/null +++ b/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp @@ -0,0 +1,35 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +// When looking up a namespace-name in a using-directive or +// namespace-alias-definition, only namespace names are considered. + +struct ns1 {}; +void ns2(); +int ns3 = 0; + +namespace ns0 { + namespace ns1 { + struct test0 {}; + } + namespace ns2 { + struct test1 {}; + } + namespace ns3 { + struct test2 {}; + } +} + +using namespace ns0; + +namespace test3 = ns1; +namespace test4 = ns2; +namespace test5 = ns3; + +using namespace ns1; +using namespace ns2; +using namespace ns3; + +test0 a; +test1 b; +test2 c; + diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp new file mode 100644 index 000000000000..dd30d6ad4f98 --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp @@ -0,0 +1,24 @@ +// RUN: clang-cc -emit-llvm-only -verify %s + +// This lame little test was ripped straight from the standard. + +namespace { + int i; // expected-note {{candidate}} +} +void test0() { i++; } + +namespace A { + namespace { + int i; // expected-note {{candidate}} + int j; + } + void test1() { i++; } +} + +using namespace A; + +void test2() { + i++; // expected-error {{reference to 'i' is ambiguous}} + A::i++; + j++; +} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp new file mode 100644 index 000000000000..35e8c08a112f --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp @@ -0,0 +1,67 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +// We have to avoid ADL for this test. + +template <unsigned N> class test {}; + +class foo {}; +test<0> foo(foo); // expected-note {{candidate}} + +namespace Test0 { + class foo { int x; }; + test<1> foo(class foo); + + namespace A { + test<2> foo(class ::foo); // expected-note {{candidate}} + + void test0() { + using ::foo; + + class foo a; + test<0> _ = (foo)(a); + } + + void test1() { + using Test0::foo; + + class foo a; + test<1> _ = (foo)(a); + }; + + void test2() { + class ::foo a; + + // Argument-dependent lookup is ambiguous between B:: and ::. + test<0> _0 = foo(a); // expected-error {{call to 'foo' is ambiguous}} + + // But basic unqualified lookup is not. + test<2> _1 = (foo)(a); + + class Test0::foo b; + test<2> _2 = (foo)(b); // expected-error {{incompatible type passing}} + } + } +} + +namespace Test1 { + namespace A { + class a {}; + } + + namespace B { + typedef class {} b; + } + + namespace C { + int c(); // expected-note {{target of using declaration}} + } + + namespace D { + using typename A::a; + using typename B::b; + using typename C::c; // expected-error {{'typename' keyword used on a non-type}} + + a _1 = A::a(); + b _2 = B::b(); + } +} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp new file mode 100644 index 000000000000..fbd205833cad --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp @@ -0,0 +1,141 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +// (this actually occurs before paragraph 1) +namespace test0 { + namespace A {} + class B { + using namespace A; // expected-error {{'using namespace' is not allowed in classes}} + }; +} + + +struct opaque0 {}; +struct opaque1 {}; + +// Test that names appear as if in deepest common ancestor. +namespace test1 { + namespace A { + namespace B { + opaque0 foo(); // expected-note {{candidate}} + } + } + + namespace C { + opaque1 foo(); // expected-note {{candidate}} + + opaque1 test() { + using namespace A::B; + return foo(); // C::foo + } + } + + opaque1 test() { + using namespace A::B; + using namespace C; + return foo(); // expected-error {{call to 'foo' is ambiguous}} + } +} + +// Same thing, but with the directives in namespaces. +namespace test2 { + namespace A { + namespace B { + opaque0 foo(); // expected-note {{candidate}} + } + } + + namespace C { + opaque1 foo(); // expected-note {{candidate}} + + namespace test { + using namespace A::B; + + opaque1 test() { + return foo(); // C::foo + } + } + } + + namespace test { + using namespace A::B; + using namespace C; + + opaque1 test() { + return foo(); // expected-error {{call to 'foo' is ambiguous}} + } + } +} + +// Transitivity. +namespace test3 { + namespace A { + namespace B { + opaque0 foo(); + } + } + namespace C { + using namespace A; + } + + opaque0 test0() { + using namespace C; + using namespace B; + return foo(); + } + + namespace D { + using namespace C; + } + namespace A { + opaque1 foo(); + } + + opaque1 test1() { + using namespace D; + return foo(); + } +} + +// Transitivity acts like synthetic using directives. +namespace test4 { + namespace A { + namespace B { + opaque0 foo(); // expected-note {{candidate}} + } + } + + namespace C { + using namespace A::B; + } + + opaque1 foo(); // expected-note {{candidate}} + + namespace A { + namespace D { + using namespace C; + } + + opaque0 test() { + using namespace D; + return foo(); + } + } + + opaque0 test() { + using namespace A::D; + return foo(); // expected-error {{call to 'foo' is ambiguous}} + } +} + +// Bug: using directives should be followed when parsing default +// arguments in scoped declarations. +class test5 { + int inc(int x); +}; +namespace Test5 { + int default_x = 0; +} +using namespace Test5; +int test5::inc(int x = default_x) { + return x+1; +} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp new file mode 100644 index 000000000000..a3c147db5ee2 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp @@ -0,0 +1,44 @@ +// RUN: clang-cc -fsyntax-only -pedantic -verify %s + +// Simple form +int ar1[10]; + +// Element type cannot be: +// - (cv) void +volatile void ar2[10]; // expected-error {{incomplete element type 'void volatile'}} +// - a reference +int& ar3[10]; // expected-error {{array of references}} +// - a function type +typedef void Fn(); +Fn ar4[10]; // expected-error {{array of functions}} +// - an abstract class +struct Abstract { virtual void fn() = 0; }; // expected-note {{pure virtual}} +Abstract ar5[10]; // expected-error {{abstract class}} + +// If we have a size, it must be greater than zero. +int ar6[-1]; // expected-error {{array size is negative}} +int ar7[0u]; // expected-warning {{zero size arrays are an extension}} + +// An array with unknown bound is incomplete. +int ar8[]; // expected-error {{needs an explicit size or an initializer}} +// So is an array with an incomplete element type. +struct Incomplete; // expected-note {{forward declaration}} +Incomplete ar9[10]; // expected-error {{incomplete type}} +// Neither of which should be a problem in situations where no complete type +// is required. (PR5048) +void fun(int p1[], Incomplete p2[10]); +extern int ear1[]; +extern Incomplete ear2[10]; + +// cv migrates to element type +typedef const int cint; +extern cint car1[10]; +typedef int intar[10]; +// thus this is a valid redeclaration +extern const intar car1; + +// Check that instantiation works properly when the element type is a template. +template <typename T> struct S { + typename T::type x; // expected-error {{has no members}} +}; +S<int> ar10[10]; // expected-note {{requested here}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp index bbfaf909392a..4b1582840c39 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp @@ -52,4 +52,4 @@ namespace N1 { { f2(6); // okay } -}
\ No newline at end of file +} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp index 6f71978c4e46..01fa6ac35548 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp @@ -1,3 +1,3 @@ // RUN: clang-cc -fsyntax-only -verify %s void f(int) { } // expected-note {{previous definition is here}} -void f(const int) { } // expected-error {{redefinition of 'f'}}
\ No newline at end of file +void f(const int) { } // expected-error {{redefinition of 'f'}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp index 101d75fc0f48..5f9a5345cf1c 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -fsyntax-only -verify %t +// RUN: clang-cc -fsyntax-only -verify %s class A { public: int& i; @@ -20,7 +20,7 @@ void f() { a.*&A::s = 10; // expected-error{{right hand operand to .* has non pointer-to-member type 'int *'}} a.*&A::i = 10; // expected-error{{cannot form a pointer-to-member to member 'i' of reference type 'int &'}} - ft(a); // expected-note{{in instantiation of function template specialization 'ft' requested here}} + ft(a); // expected-note{{in instantiation of function template specialization 'ft<class A>' requested here}} void A::*p = 0; // expected-error{{'p' declared as a member pointer to void}} } diff --git a/test/CXX/expr/expr.unary/expr.delete/p5.cpp b/test/CXX/expr/expr.unary/expr.delete/p5.cpp new file mode 100644 index 000000000000..91e77bcb8bf7 --- /dev/null +++ b/test/CXX/expr/expr.unary/expr.delete/p5.cpp @@ -0,0 +1,34 @@ +// RUN: clang-cc -verify %s + +// If the object being deleted has incomplete class type at the point of +// deletion and the complete class has a non-trivial destructor or a +// deallocation function, the behavior is undefined. + +// The trivial case. +class T0; // expected-note {{forward declaration}} +void f0(T0 *a) { delete a; } // expected-warning {{deleting pointer to incomplete type}} +class T0 { ~T0(); }; + +// The trivial case, inside a template instantiation. +template<typename T> +class T1_A { T *x; ~T1_A() { delete x; } }; // expected-warning {{deleting pointer to incomplete type}} +class T1_B; // expected-note {{forward declaration}} +void f0() { T1_A<T1_B> x; } // expected-note {{in instantiation of member function}} + +// This case depends on when we check T2_C::f0. +class T2_A; +template<typename T> +struct T2_B { void f0(T *a) { delete a; } }; +struct T2_C { T2_B<T2_A> x; void f0(T2_A *a) { x.f0(a); } }; +void f0(T2_A *a) { T2_C x; x.f0(a); } +class T2_A { }; + +// An alternate version of the same. +// +// FIXME: Revisit this case when we have access control. +class T3_A; +template<typename T> +struct T3_B { void f0(T *a) { delete a; } }; +struct T3_C { T3_B<T3_A> x; void f0(T3_A *a) { x.f0(a); } }; +void f0(T3_A *a) { T3_C x; x.f0(a); } +class T3_A { private: ~T3_A(); }; diff --git a/test/CXX/special/class.free/p1.cpp b/test/CXX/special/class.free/p1.cpp new file mode 100644 index 000000000000..bf99a2782bd5 --- /dev/null +++ b/test/CXX/special/class.free/p1.cpp @@ -0,0 +1,11 @@ +// RUN: clang-cc -fsyntax-only -verify %s +#include <stddef.h> + +struct A { + void *operator new(size_t) { + return this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} + } + void *operator new[](size_t) { + return this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} + } +}; diff --git a/test/CXX/special/class.free/p6.cpp b/test/CXX/special/class.free/p6.cpp new file mode 100644 index 000000000000..8334817ca2b5 --- /dev/null +++ b/test/CXX/special/class.free/p6.cpp @@ -0,0 +1,11 @@ +// RUN: clang-cc -fsyntax-only -verify %s +#include <stddef.h> + +struct A { + void operator delete(size_t) { + (void)this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} + } + void operator delete[](void*) { + (void)this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} + } +}; diff --git a/test/CXX/temp/temp.param/p1.cpp b/test/CXX/temp/temp.param/p1.cpp index a6638b4f60f2..676bffe31dc5 100644 --- a/test/CXX/temp/temp.param/p1.cpp +++ b/test/CXX/temp/temp.param/p1.cpp @@ -1,4 +1,4 @@ // Suppress 'no run line' failure. -// RUN: true +// RUN: echo ok // Paragraph 1 is descriptive, and therefore requires no tests. diff --git a/test/CXX/temp/temp.param/p12.cpp b/test/CXX/temp/temp.param/p12.cpp index 5511224ebe94..3864fbeaa11e 100644 --- a/test/CXX/temp/temp.param/p12.cpp +++ b/test/CXX/temp/temp.param/p12.cpp @@ -34,4 +34,6 @@ template<int N, // Check validity of default arguments template<template<class, int> class // expected-note{{previous template template parameter is here}} = Y1> // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} - class C1; + class C1 {}; + +C1<> c1; // expected-note{{while checking a default template argument}} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp index 33fb93bacfaf..de05a926338c 100644 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp +++ b/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp @@ -10,4 +10,4 @@ namespace N { template<> class X<char*> { /* ... */ }; // OK: X is a template -}
\ No newline at end of file +} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp index 8d91068f9b99..ad0d50621367 100644 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp +++ b/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp @@ -12,7 +12,7 @@ struct X { // expected-note{{here}} void g() { } - struct Inner { + struct Inner { // expected-error{{implicit default}} T value; // expected-note {{member is declared here}} }; @@ -26,8 +26,7 @@ IntHolder &test_X_IntHolderInt(X<IntHolder, int> xih) { xih.g(); // okay xih.f(); // expected-note{{instantiation}} - // FIXME: diagnostic here has incorrect reason (PR5154) - X<IntHolder, int>::Inner inner; // expected-error{{implicit default}} + X<IntHolder, int>::Inner inner; // expected-note {{first required here}} return X<IntHolder, int>::value; // expected-note{{instantiation}} } |
