summaryrefslogtreecommitdiffstats
path: root/test/CXX/basic
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
committerdim <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
commitc72c57c9e9b69944e3e009cd5e209634839581d3 (patch)
tree4fc2f184c499d106f29a386c452b49e5197bf63d /test/CXX/basic
parent5b20025c30d23d521e12c1f33ec8fa6b821952cd (diff)
downloadFreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.zip
FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.tar.gz
Vendor import of clang trunk r178860:
http://llvm.org/svn/llvm-project/cfe/trunk@178860
Diffstat (limited to 'test/CXX/basic')
-rw-r--r--test/CXX/basic/basic.link/p6.cpp43
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp92
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp30
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp2
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2.cpp101
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2a.cpp9
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2b.cpp9
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2c.cpp5
-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.cpp5
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2h.cpp5
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2i.cpp6
-rw-r--r--test/CXX/basic/basic.types/p10.cpp2
15 files changed, 267 insertions, 57 deletions
diff --git a/test/CXX/basic/basic.link/p6.cpp b/test/CXX/basic/basic.link/p6.cpp
new file mode 100644
index 0000000..8faec76
--- /dev/null
+++ b/test/CXX/basic/basic.link/p6.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++11 [basic.link]p6:
+// The name of a function declared in block scope and the name
+// of a variable declared by a block scope extern declaration
+// have linkage. If there is a visible declaration of an entity
+// with linkage having the same name and type, ignoring entities
+// declared outside the innermost enclosing namespace scope, the
+// block scope declaration declares that same entity and
+// receives the linkage of the previous declaration.
+
+// rdar://13535367
+namespace test0 {
+ extern "C" int test0_array[];
+ void declare() { extern int test0_array[100]; }
+ extern "C" int test0_array[];
+ int value = sizeof(test0_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
+}
+
+namespace test1 {
+ extern "C" int test1_array[];
+ void test() {
+ { extern int test1_array[100]; }
+ extern int test1_array[];
+ int x = sizeof(test1_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
+ }
+}
+
+namespace test2 {
+ void declare() { extern int test2_array[100]; }
+ extern int test2_array[];
+ int value = sizeof(test2_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
+}
+
+namespace test3 {
+ void test() {
+ { extern int test3_array[100]; }
+ extern int test3_array[];
+ int x = sizeof(test3_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
+ }
+}
+
+
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
index 7ecedd5..1f78a73 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
struct X0 {
X0 f1();
X0 f2();
@@ -25,3 +26,92 @@ struct X0::X0 X0::f2() { return X0(); }
template<typename T> X1<T>::X1<T> X1<T>::f2() { } // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name wherever a constructor can be declared}}
template<typename T> X1<T>::X1<T> (X1<T>::f2)(int) { } // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name wherever a constructor can be declared}}
template<typename T> struct X1<T>::X1<T> (X1<T>::f2)(float) { }
+
+// We have a special case for lookup within using-declarations that are
+// member-declarations: foo::bar::baz::baz always names baz's constructor
+// in such a context, even if looking up 'baz' within foo::bar::baz would
+// not find the injected-class-name. Likewise foo::bar::baz<T>::baz also
+// names the constructor.
+namespace InhCtor {
+ struct A {
+ A(int);
+ protected:
+ int T();
+ };
+ typedef A T;
+ struct B : A {
+ // This is a using-declaration for 'int A::T()' in C++98, but is an
+ // inheriting constructor declaration in C++11.
+ using InhCtor::T::T;
+ };
+#if __cplusplus < 201103L
+ B b(123); // expected-error {{no matching constructor}}
+ // expected-note@-7 2{{candidate constructor}}
+ int n = b.T(); // ok, accessible
+#else
+ B b(123); // ok, inheriting constructor
+ int n = b.T(); // expected-error {{'T' is a protected member of 'InhCtor::A'}}
+ // expected-note@-15 {{declared protected here}}
+
+ template<typename T>
+ struct S : T {
+ struct U : S {
+ using S::S;
+ };
+ using T::T;
+ };
+
+ S<A>::U ua(0);
+ S<B>::U ub(0);
+
+ template<typename T>
+ struct X : T {
+ using T::Z::U::U;
+ };
+ template<typename T>
+ struct X2 : T {
+ using T::Z::template V<int>::V;
+ };
+ struct Y {
+ struct Z {
+ typedef Y U;
+ template<typename T> using V = Y;
+ };
+ Y(int);
+ };
+ X<Y> xy(0);
+
+ namespace Repeat {
+ struct A {
+ struct T {
+ T(int);
+ };
+ };
+ struct Z : A {
+ using A::A::A;
+ };
+ template<typename T>
+ struct ZT : T::T {
+ using T::T::T;
+ };
+ }
+
+ namespace NS {
+ struct NS {};
+ }
+ struct DerivedFromNS : NS::NS {
+ // No special case unless the NNS names a class.
+ using InhCtor::NS::NS; // expected-error {{using declaration in class refers into 'InhCtor::NS::', which is not a class}}
+
+ };
+
+ typedef int I;
+ struct UsingInt {
+ using I::I; // expected-error {{expected a class or namespace}}
+ };
+ template<typename T> struct UsingIntTemplate {
+ using T::T; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
+ };
+ UsingIntTemplate<int> uit; // expected-note {{here}}
+#endif
+}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp
index 4ffe538..7da3087 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp
@@ -17,3 +17,33 @@ namespace N {
int i = 2;
N::S N::j = i;
N::S N::j2(i);
+
+// <rdar://problem/13317030>
+namespace M {
+ class X { };
+ inline X operator-(int, X);
+
+ template<typename T>
+ class Y { };
+
+ typedef Y<float> YFloat;
+
+ namespace yfloat {
+ YFloat operator-(YFloat, YFloat);
+ }
+ using namespace yfloat;
+}
+
+using namespace M;
+
+namespace M {
+
+class Other {
+ void foo(YFloat a, YFloat b);
+};
+
+}
+
+void Other::foo(YFloat a, YFloat b) {
+ YFloat c = a - b;
+}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp
index d2afd5d..9632fda 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp
@@ -33,5 +33,5 @@ namespace test1 {
// specifiers.
namespace test2 {
template <class T> struct bar {};
- template <class T> struct foo : bar<foo> {}; // expected-error {{use of class template foo requires template arguments}} expected-note {{template is declared here}}
+ template <class T> struct foo : bar<foo> {}; // expected-error {{use of class template 'foo' requires template arguments}} expected-note {{template is declared here}}
}
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2.cpp b/test/CXX/basic/basic.start/basic.start.main/p2.cpp
new file mode 100644
index 0000000..a5386f1
--- /dev/null
+++ b/test/CXX/basic/basic.start/basic.start.main/p2.cpp
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST1
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST2
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST3
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST4
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST5
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST6
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST7
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST8
+
+// RUN: cp %s %t
+// RUN: %clang_cc1 -x c++ %s -std=c++11 -fsyntax-only -verify -DTEST9
+// RUN: not %clang_cc1 -x c++ %t -std=c++11 -fixit -DTEST9
+// RUN: %clang_cc1 -x c++ %t -std=c++11 -fsyntax-only -DTEST9
+
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST10
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST12
+
+#if TEST1
+
+// expected-no-diagnostics
+typedef int Int;
+typedef char Char;
+typedef Char* Carp;
+
+Int main(Int argc, Carp argv[]) {
+}
+
+#elif TEST2
+
+// expected-no-diagnostics
+typedef int Int;
+typedef char Char;
+typedef Char* Carp;
+
+Int main(Int argc, Carp argv[], Char *env[]) {
+}
+
+#elif TEST3
+
+// expected-no-diagnostics
+int main() {
+}
+
+#elif TEST4
+
+static int main() { // expected-error {{'main' is not allowed to be declared static}}
+}
+
+#elif TEST5
+
+inline int main() { // expected-error {{'main' is not allowed to be declared inline}}
+}
+
+#elif TEST6
+
+void // expected-error {{'main' must return 'int'}}
+main( // expected-error {{first parameter of 'main' (argument count) must be of type 'int'}}
+ float a
+) {
+}
+
+#elif TEST7
+
+// expected-no-diagnostics
+int main(int argc, const char* const* argv) {
+}
+
+#elif TEST8
+
+template<typename T>
+int main() { } // expected-error{{'main' cannot be a template}}
+
+#elif TEST9
+
+constexpr int main() { } // expected-error{{'main' is not allowed to be declared constexpr}}
+
+#elif TEST10
+
+// PR15100
+// expected-no-diagnostics
+typedef char charT;
+int main(int, const charT**) {}
+
+#elif TEST11
+
+// expected-no-diagnostics
+typedef char charT;
+int main(int, charT* const *) {}
+
+#elif TEST12
+
+// expected-no-diagnostics
+typedef char charT;
+int main(int, const charT* const *) {}
+
+#else
+
+#error Unknown test mode
+
+#endif
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2a.cpp b/test/CXX/basic/basic.start/basic.start.main/p2a.cpp
deleted file mode 100644
index b27d492..0000000
--- a/test/CXX/basic/basic.start/basic.start.main/p2a.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// expected-no-diagnostics
-
-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
deleted file mode 100644
index 65cd202..0000000
--- a/test/CXX/basic/basic.start/basic.start.main/p2b.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// expected-no-diagnostics
-
-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
deleted file mode 100644
index 2b082ec..0000000
--- a/test/CXX/basic/basic.start/basic.start.main/p2c.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// expected-no-diagnostics
-
-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
deleted file mode 100644
index bcdbdb2..0000000
--- a/test/CXX/basic/basic.start/basic.start.main/p2d.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: %clang_cc1 -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
deleted file mode 100644
index 954fdbd..0000000
--- a/test/CXX/basic/basic.start/basic.start.main/p2e.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: %clang_cc1 -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
deleted file mode 100644
index ea5a752..0000000
--- a/test/CXX/basic/basic.start/basic.start.main/p2f.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-void // expected-error {{'main' must return 'int'}}
-main( // expected-error {{first parameter of 'main' (argument count) must 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
deleted file mode 100644
index 45f643f..0000000
--- a/test/CXX/basic/basic.start/basic.start.main/p2g.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// expected-no-diagnostics
-
-int main(int argc, const char* const* argv) {
-}
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2h.cpp b/test/CXX/basic/basic.start/basic.start.main/p2h.cpp
deleted file mode 100644
index abf8faa..0000000
--- a/test/CXX/basic/basic.start/basic.start.main/p2h.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-template<typename T>
-int main() { } // expected-error{{'main' cannot be a template}}
-
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2i.cpp b/test/CXX/basic/basic.start/basic.start.main/p2i.cpp
deleted file mode 100644
index db8da3c..0000000
--- a/test/CXX/basic/basic.start/basic.start.main/p2i.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: cp %s %t
-// RUN: %clang_cc1 -x c++ %s -std=c++11 -fsyntax-only -verify
-// RUN: not %clang_cc1 -x c++ %t -std=c++11 -fixit
-// RUN: %clang_cc1 -x c++ %t -std=c++11 -fsyntax-only
-
-constexpr int main() { } // expected-error{{'main' is not allowed to be declared constexpr}}
diff --git a/test/CXX/basic/basic.types/p10.cpp b/test/CXX/basic/basic.types/p10.cpp
index 191d42b..6401c29 100644
--- a/test/CXX/basic/basic.types/p10.cpp
+++ b/test/CXX/basic/basic.types/p10.cpp
@@ -39,7 +39,7 @@ struct UserProvDtor {
struct NonTrivDtor {
constexpr NonTrivDtor();
constexpr int f(); // expected-error {{non-literal type 'NonTrivDtor' cannot have constexpr members}}
- virtual ~NonTrivDtor() = default; // expected-note {{has a non-trivial destructor}}
+ virtual ~NonTrivDtor() = default; // expected-note {{has a non-trivial destructor}} expected-note {{because it is virtual}}
};
struct NonTrivDtorBase {
~NonTrivDtorBase();
OpenPOWER on IntegriCloud