summaryrefslogtreecommitdiff
path: root/test/CXX/basic
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/basic')
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp27
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp73
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp42
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp18
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp65
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp41
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp25
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp35
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp4
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2a.cpp8
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2b.cpp8
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2c.cpp4
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2d.cpp4
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2e.cpp4
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2f.cpp7
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2g.cpp4
-rw-r--r--test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp7
-rw-r--r--test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp25
18 files changed, 398 insertions, 3 deletions
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp
new file mode 100644
index 0000000000000..e2c76f9183362
--- /dev/null
+++ b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp
@@ -0,0 +1,27 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+namespace N1 {
+ struct X { };
+ int& f(void*);
+}
+
+namespace N2 {
+ template<typename T> struct Y { };
+}
+
+namespace N3 {
+ void test() {
+ int &ir = f((N2::Y<N1::X>*)0);
+ }
+}
+
+int g(void *);
+long g(N1::X);
+
+namespace N1 {
+ void h(int (*)(void *));
+}
+
+void test() {
+ h((&g));
+}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
new file mode 100644
index 0000000000000..677df8284a72c
--- /dev/null
+++ b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
@@ -0,0 +1,73 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+namespace N {
+ struct X { };
+
+ X operator+(X, X);
+
+ void f(X);
+ void g(X); // expected-note{{candidate function}}
+
+ void test_multiadd(X x) {
+ (void)(x + x);
+ }
+}
+
+namespace M {
+ struct Y : N::X { };
+}
+
+void f();
+
+void test_operator_adl(N::X x, M::Y y) {
+ (void)(x + x);
+ (void)(y + y);
+}
+
+void test_func_adl(N::X x, M::Y y) {
+ f(x);
+ f(y);
+ (f)(x); // expected-error{{too many arguments to function call}}
+ ::f(x); // expected-error{{too many arguments to function call}}
+}
+
+namespace N {
+ void test_multiadd2(X x) {
+ (void)(x + x);
+ }
+}
+
+
+void test_func_adl_only(N::X x) {
+ g(x);
+}
+
+namespace M {
+ int g(N::X); // expected-note{{candidate function}}
+
+ void test(N::X x) {
+ g(x); // expected-error{{call to 'g' is ambiguous; candidates are:}}
+ int i = (g)(x);
+
+ int g(N::X);
+ g(x); // okay; calls locally-declared function, no ADL
+ }
+}
+
+
+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/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
new file mode 100644
index 0000000000000..8f0bed8789fe6
--- /dev/null
+++ b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
@@ -0,0 +1,42 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+namespace A {
+ class A {
+ friend void func(A);
+ friend A operator+(A,A);
+ };
+}
+
+namespace B {
+ class B {
+ static void func(B);
+ };
+ B operator+(B,B);
+}
+
+namespace D {
+ class D {};
+}
+
+namespace C {
+ class C {};
+ void func(C);
+ C operator+(C,C);
+ D::D operator+(D::D,D::D);
+}
+
+namespace D {
+ using namespace C;
+}
+
+namespace Test {
+ void test() {
+ func(A::A());
+ func(B::B()); // expected-error {{ no matching function for call to 'func' }}
+ func(C::C());
+ A::A() + A::A();
+ B::B() + B::B();
+ C::C() + C::C();
+ D::D() + D::D(); // expected-error {{ invalid operands to binary expression ('D::D' and 'D::D') }}
+ }
+}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp b/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp
new file mode 100644
index 0000000000000..cb9d942ba6f69
--- /dev/null
+++ b/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp
@@ -0,0 +1,18 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// elaborated-type-specifier:
+// class-key '::'? nested-name-specifier? 'template'? simple-template-id
+// Tests that this form is accepted by the compiler but does not follow
+// the elaborated lookup rules of [basic.lookup.elab].
+
+template <typename> class Ident {}; // expected-note {{previous use is here}}
+
+namespace A {
+ template <typename> void Ident();
+
+ class Ident<int> AIdent; // expected-error {{refers to a function template}}
+ class ::Ident<int> AnotherIdent;
+}
+
+class Ident<int> GlobalIdent;
+union Ident<int> GlobalIdent; // expected-error {{ tag type that does not match }}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
new file mode 100644
index 0000000000000..b32948b4a608f
--- /dev/null
+++ b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
@@ -0,0 +1,65 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+namespace Ints {
+ int zero = 0; // expected-note {{candidate found by name lookup is 'Ints::zero'}}
+ void f(int); // expected-note 3 {{candidate function}}
+ void g(int);
+}
+
+namespace Floats {
+ float zero = 0.0f; // expected-note {{candidate found by name lookup is 'Floats::zero'}}
+ void f(float); // expected-note 3 {{candidate function}}
+ void g(float);
+}
+
+namespace Numbers {
+ using namespace Ints;
+ using namespace Floats;
+}
+
+void test() {
+ int i = Ints::zero;
+ Ints::f(i);
+
+ float f = Floats::zero;
+ Floats::f(f);
+
+ double n = Numbers::zero; // expected-error {{reference to 'zero' is ambiguous}}
+ Numbers::f(n); // expected-error{{call to 'f' is ambiguous}}
+ Numbers::f(i);
+ Numbers::f(f);
+}
+
+namespace Numbers {
+ struct Number {
+ explicit Number(double d) : d(d) {}
+ double d;
+ };
+ Number zero(0.0f);
+ void g(Number);
+}
+
+void test2() {
+ Numbers::Number n = Numbers::zero;
+ Numbers::f(n); // expected-error {{no matching function for call to 'f'}}
+ Numbers::g(n);
+}
+
+namespace Numbers2 {
+ using Numbers::f;
+ using Numbers::g;
+}
+
+void test3() {
+ Numbers::Number n = Numbers::zero;
+ Numbers2::f(n); // expected-error {{no matching function for call to 'f'}}
+ Numbers2::g(n);
+
+ int i = Ints::zero;
+ Numbers2::f(i);
+ Numbers2::g(i); // expected-error {{incompatible type passing 'int'}}
+
+ float f = Floats::zero;
+ Numbers2::f(f);
+ Numbers2::g(f); // expected-error {{incompatible type passing 'float'}}
+}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp
new file mode 100644
index 0000000000000..7a51a7bb1df07
--- /dev/null
+++ b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp
@@ -0,0 +1,41 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// This is basically paraphrased from the standard.
+
+namespace Root {
+ int i = 0;
+ void f();
+}
+
+namespace A {
+ using namespace Root;
+}
+
+namespace B {
+ using namespace Root;
+}
+
+namespace AB {
+ using namespace A;
+ using namespace B;
+}
+
+void test() {
+ if (AB::i)
+ AB::f();
+}
+
+namespace C {
+ using Root::i;
+ using Root::f;
+}
+
+namespace AC {
+ using namespace A;
+ using namespace C;
+}
+
+void test2() {
+ if (AC::i)
+ AC::f();
+}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp
new file mode 100644
index 0000000000000..2c0ce80d8ce69
--- /dev/null
+++ b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp
@@ -0,0 +1,25 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+namespace A {
+ int a;
+}
+
+namespace C {
+ int c;
+}
+
+namespace B {
+ using namespace C;
+ int b;
+}
+
+namespace C {
+ using namespace B;
+ using namespace A;
+}
+
+void test() {
+ C::a++;
+ C::b++;
+ C::c++;
+}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp
new file mode 100644
index 0000000000000..78af521c91030
--- /dev/null
+++ b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp
@@ -0,0 +1,35 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+namespace A {
+ struct x {}; // expected-note {{candidate found by name lookup is 'A::x'}}
+ int x; // expected-note {{candidate found by name lookup is 'A::x'}}
+
+ struct y {}; // expected-note {{type declaration hidden}}
+
+ struct z;
+ void z(float);
+}
+
+namespace B {
+ struct x {}; // expected-note {{candidate found by name lookup is 'B::x'}}
+ float x; // expected-note {{candidate found by name lookup is 'B::x'}}
+
+ float y; // expected-note {{declaration hides type}}
+
+ void z(int);
+}
+
+namespace AB {
+ using namespace A;
+ using namespace B;
+}
+
+void test() {
+ struct AB::x foo; // expected-error {{reference to 'x' is ambiguous}}
+ int i = AB::x; // expected-error {{reference to 'x' is ambiguous}}
+
+ struct AB::y bar;
+ float f = AB::y; // expected-error {{a type named 'y' is hidden by a declaration in a different namespace}}
+ AB::z(i);
+ AB::z(f);
+}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
index 1daf0ddec6c05..7fd1b53c2cb0e 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
@@ -1,9 +1,7 @@
// RUN: clang-cc -fsyntax-only -verify %s
-// XFAIL
-// FIXME: This part is here to demonstrate the failure in looking up 'f', it can
-// be removed once the whole test passes.
typedef int f;
+
namespace N0 {
struct A {
friend void f();
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2a.cpp b/test/CXX/basic/basic.start/basic.start.main/p2a.cpp
new file mode 100644
index 0000000000000..a6a758798949f
--- /dev/null
+++ b/test/CXX/basic/basic.start/basic.start.main/p2a.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+typedef int Int;
+typedef char Char;
+typedef Char* Carp;
+
+Int main(Int argc, Carp argv[]) {
+}
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2b.cpp b/test/CXX/basic/basic.start/basic.start.main/p2b.cpp
new file mode 100644
index 0000000000000..caecf60608817
--- /dev/null
+++ b/test/CXX/basic/basic.start/basic.start.main/p2b.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+typedef int Int;
+typedef char Char;
+typedef Char* Carp;
+
+Int main(Int argc, Carp argv[], Char *env[]) {
+}
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2c.cpp b/test/CXX/basic/basic.start/basic.start.main/p2c.cpp
new file mode 100644
index 0000000000000..8587d8cec791b
--- /dev/null
+++ b/test/CXX/basic/basic.start/basic.start.main/p2c.cpp
@@ -0,0 +1,4 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int main() {
+}
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2d.cpp b/test/CXX/basic/basic.start/basic.start.main/p2d.cpp
new file mode 100644
index 0000000000000..777b5ceb743a3
--- /dev/null
+++ b/test/CXX/basic/basic.start/basic.start.main/p2d.cpp
@@ -0,0 +1,4 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+static int main() { // expected-error {{'main' is not allowed to be declared static}}
+}
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2e.cpp b/test/CXX/basic/basic.start/basic.start.main/p2e.cpp
new file mode 100644
index 0000000000000..087cf77476ad4
--- /dev/null
+++ b/test/CXX/basic/basic.start/basic.start.main/p2e.cpp
@@ -0,0 +1,4 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+inline int main() { // expected-error {{'main' is not allowed to be declared inline}}
+}
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2f.cpp b/test/CXX/basic/basic.start/basic.start.main/p2f.cpp
new file mode 100644
index 0000000000000..b7845b13e9a4b
--- /dev/null
+++ b/test/CXX/basic/basic.start/basic.start.main/p2f.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+void // expected-error {{error: 'main' must return 'int'}}
+main( // expected-error {{error: first argument of 'main' should be of type 'int'}}
+ float a
+) {
+}
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2g.cpp b/test/CXX/basic/basic.start/basic.start.main/p2g.cpp
new file mode 100644
index 0000000000000..4cedcdb916573
--- /dev/null
+++ b/test/CXX/basic/basic.start/basic.start.main/p2g.cpp
@@ -0,0 +1,4 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int main(int argc, const char* const* argv) {
+}
diff --git a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp
new file mode 100644
index 0000000000000..ff653d5fef08f
--- /dev/null
+++ b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int *use_new(int N) {
+ return new int [N];
+}
+
+int std = 17;
diff --git a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
new file mode 100644
index 0000000000000..f3499e4286bcc
--- /dev/null
+++ b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
@@ -0,0 +1,25 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+int *use_new(int N) {
+ if (N == 1)
+ return new int;
+
+ return new int [N];
+}
+
+void use_delete(int* ip, int N) {
+ if (N == 1)
+ delete ip;
+ else
+ delete [] ip;
+}
+
+namespace std {
+ class bad_alloc { };
+
+ typedef __SIZE_TYPE__ size_t;
+}
+
+void* operator new(std::size_t) throw(std::bad_alloc);
+void* operator new[](std::size_t) throw(std::bad_alloc);
+void operator delete(void*) throw();
+void operator delete[](void*) throw();