summaryrefslogtreecommitdiff
path: root/clang/test/CXX/dcl.decl/dcl.meaning
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX/dcl.decl/dcl.meaning')
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp7
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp54
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp16
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp9
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp13
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp55
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp19
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp33
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp7
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp4
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp62
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp48
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp31
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp7
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp3
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp53
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp20
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp6
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp10
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp3
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp26
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp145
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp26
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp24
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/p1.cpp37
25 files changed, 718 insertions, 0 deletions
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp
new file mode 100644
index 0000000..102746c
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+void f() {
+ int b[5];
+ auto a[5] = b; // expected-error{{'a' declared as array of 'auto'}}
+ auto *c[5] = b; // expected-error{{'c' declared as array of 'auto *'}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp
new file mode 100644
index 0000000..bb4a48e
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -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 'volatile void'}}
+// - 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 with a negative size}}
+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}}
+
+// Ensure that negative array size errors include the name of the declared
+// array as this is often used to simulate static_assert with template
+// instantiations, placing the 'error message' in the declarator name.
+int
+user_error_message
+[-1]; // expected-error {{user_error_message}}
+typedef int
+another_user_error_message
+[-1]; // expected-error {{another_user_error_message}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp
new file mode 100644
index 0000000..385e45d
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+ virtual void f(int a = 7);
+};
+
+struct B : public A {
+ void f(int a); // expected-note{{'f' declared here}}
+};
+
+void m() {
+ B* pb = new B;
+ A* pa = pb;
+ pa->f(); // OK, calls pa->B::f(7)
+ pb->f(); // expected-error{{too few arguments}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp
new file mode 100644
index 0000000..0a107eb
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void point(int = 3, int = 4);
+
+void test_point() {
+ point(1,2);
+ point(1);
+ point();
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp
new file mode 100644
index 0000000..e9c5e0c
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void nondecl(int (*f)(int x = 5)) // {expected-error {{default arguments can only be specified}}}
+{
+ void (*f2)(int = 17) // {expected-error {{default arguments can only be specified}}}
+ = (void (*)(int = 42))f; // {expected-error {{default arguments can only be specified}}}
+}
+
+struct X0 {
+ int (*f)(int = 17); // expected-error{{default arguments can only be specified for parameters in a function declaration}}
+
+ void mem8(int (*fp)(int) = (int (*)(int = 17))0); // expected-error{{default arguments can only be specified for parameters in a function declaration}}
+};
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
new file mode 100644
index 0000000..f3dec52
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f0(int i, int j, int k = 3);
+void f0(int i, int j, int k);
+void f0(int i, int j = 2, int k);
+void f0(int i, int j, int k);
+void f0(int i = 1, // expected-note{{previous definition}}
+ int j, int k);
+void f0(int i, int j, int k);
+
+namespace N0 {
+ void f0(int, int, int); // expected-note{{candidate}}
+
+ void test_f0_inner_scope() {
+ f0(); // expected-error{{no matching}}
+ }
+}
+
+void test_f0_outer_scope() {
+ f0(); // okay
+}
+
+void f0(int i = 1, // expected-error{{redefinition of default argument}}
+ int, int);
+
+template<typename T> void f1(T); // expected-note{{previous}}
+
+template<typename T>
+void f1(T = T()); // expected-error{{cannot be added}}
+
+
+namespace N1 {
+ // example from C++03 standard
+ // FIXME: make these "f2"s into "f"s, then fix our scoping issues
+ void f2(int, int);
+ void f2(int, int = 7);
+ void h() {
+ f2(3); // OK, calls f(3, 7)
+ void f(int = 1, int); // expected-error{{missing default argument}}
+ }
+
+ void m()
+ {
+ void f(int, int); // expected-note{{'f' declared here}}
+ f(4); // expected-error{{too few arguments to function call}}
+ void f(int, int = 5); // expected-note{{previous definition}}
+ f(4); // okay
+ void f(int, int = 5); // expected-error{{redefinition of default argument}}
+ }
+
+ void n()
+ {
+ f2(6); // okay
+ }
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp
new file mode 100644
index 0000000..3100e56
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+float global_f;
+
+void f0(int *ip = &global_f); // expected-error{{cannot initialize}} \
+// expected-note{{passing argument to parameter 'ip' here}}
+
+// Example from C++03 standard
+int a = 1;
+int f(int);
+int g(int x = f(a));
+
+void h() {
+ a = 2;
+ {
+ int *a = 0;
+ g(); // FIXME: check that a is called with a value of 2
+ }
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp
new file mode 100644
index 0000000..9ab0b48
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class C {
+public:
+ void f(int i = 3); // expected-note{{here}}
+ void g(int i, int j = 99);
+};
+
+void C::f(int i = 3) { } // expected-error{{redefinition of default argument}}
+
+void C::g(int i = 88, int j) { }
+
+void test_C(C c) {
+ c.f();
+ c.g();
+}
+
+template<typename T>
+struct X0 {
+ void f(int);
+
+ struct Inner {
+ void g(int);
+ };
+};
+
+// DR217
+template<typename T>
+void X0<T>::f(int = 17) { } // expected-error{{cannot be added}}
+
+// DR217 + DR205 (reading tea leaves)
+template<typename T>
+void X0<T>::Inner::g(int = 17) { } // expected-error{{cannot be added}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
new file mode 100644
index 0000000..164eb36
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void h()
+{
+ int i;
+ extern void h2(int x = sizeof(i)); // expected-error {{default argument references local variable 'i' of enclosing function}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
new file mode 100644
index 0000000..1a08ab7
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class A {
+ void f(A* p = this) { } // expected-error{{invalid use of 'this'}}
+};
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp
new file mode 100644
index 0000000..a879829
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// FIXME: test with non-std qualifiers
+
+namespace move {
+ struct Const {
+ Const(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be const}}
+ Const& operator=(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be const}}
+ };
+
+ struct Volatile {
+ Volatile(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be volatile}}
+ Volatile& operator=(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be volatile}}
+ };
+
+ struct AssignmentRet1 {
+ AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct AssignmentRet2 {
+ const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct ConstAssignment {
+ ConstAssignment& operator=(ConstAssignment&&) const = default; // expected-error {{an explicitly-defaulted move assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
+ };
+}
+
+namespace copy {
+ struct Volatile {
+ Volatile(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy constructor may not be volatile}}
+ Volatile& operator=(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy assignment operator may not be volatile}}
+ };
+
+ struct Const {
+ Const(const Const&) = default;
+ Const& operator=(const Const&) = default;
+ };
+
+ struct NonConst {
+ NonConst(NonConst&) = default;
+ NonConst& operator=(NonConst&) = default;
+ };
+
+ struct BadConst {
+ NonConst nc; // makes implicit copy non-const
+ BadConst(const BadConst&) = default; // expected-error {{is const, but}}
+ BadConst& operator=(const BadConst&) = default; // expected-error {{is const, but}}
+ };
+
+ struct AssignmentRet1 {
+ AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct AssignmentRet2 {
+ const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct ConstAssignment {
+ ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
+ };
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp
new file mode 100644
index 0000000..19a5f23
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -fexceptions -verify %s
+
+// When it is part of a parameter-declaration-clause, the parameter
+// pack is a function parameter pack.
+template<typename ...Types>
+void f0(Types ...args);
+
+template<typename ...Types>
+void f1(const Types &...args);
+
+// [ Note: Otherwise, the parameter-declaration is part of a
+// template-parameter-list and the parameter pack is a template
+// parameter pack; see 14.1. -- end note ]
+template<int ...N>
+struct X0 { };
+
+template<typename ...Types>
+struct X1 {
+ template<Types ...Values> struct Inner;
+};
+
+// A declarator-id or abstract-declarator containing an ellipsis shall
+// only be used in a parameter-declaration.
+int (...f2)(int); // expected-error{{only function and template parameters can be parameter packs}}
+
+void f3() {
+ int ...x; // expected-error{{only function and template parameters can be parameter packs}}
+ if (int ...y = 17) { } // expected-error{{only function and template parameters can be parameter packs}}
+
+ for (int ...z = 0; z < 10; ++z) { } // expected-error{{only function and template parameters can be parameter packs}}
+
+ try {
+ } catch (int ...e) { // expected-error{{only function and template parameters can be parameter packs}}
+ }
+}
+
+template<typename ...Types>
+struct X2 {
+ Types ...members; // expected-error{{only function and template parameters can be parameter packs}} \
+ // expected-error{{data member type contains unexpanded parameter pack}}
+};
+
+// The type T of the declarator-id of the function parameter pack
+// shall contain a template parameter pack; each template parameter
+// pack in T is expanded by the function parameter pack.
+template<typename T>
+void f4(T ...args); // expected-error{{type 'T' of function parameter pack does not contain any unexpanded parameter packs}}
+
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp
new file mode 100644
index 0000000..0e69521
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T> struct identity;
+template<typename ...Types> struct tuple;
+
+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;
+};
+
+// There is a syntactic ambiguity when an ellipsis occurs at the end
+// of a parameter-declaration-clause without a preceding comma. In
+// this case, the ellipsis is parsed as part of the
+// abstract-declarator if the type of the parameter names a template
+// parameter pack that has not been expanded; otherwise, it is parsed
+// as part of the parameter-declaration-clause.
+
+template<typename T, typename ...Types>
+struct X0 {
+ typedef identity<T(Types...)> function_pack_1;
+ typedef identity<T(Types......)> variadic_function_pack_1;
+ typedef identity<T(T...)> variadic_1;
+ typedef tuple<T(Types, ...)...> template_arg_expansion_1;
+};
+
+
+
+// FIXME: Once function parameter packs are implemented, we can test all of the disambiguation
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp
new file mode 100644
index 0000000..6b1f3e4
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+auto a() -> int; // ok
+const auto b() -> int; // expected-error {{function with trailing return type must specify return type 'auto', not 'auto const'}}
+auto *c() -> int; // expected-error {{function with trailing return type must specify return type 'auto', not 'auto *'}}
+auto (d() -> int); // expected-error {{trailing return type may not be nested within parentheses}}
+auto e() -> auto (*)() -> auto (*)() -> void; // ok: same as void (*(*e())())();
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp
new file mode 100644
index 0000000..ad827fb
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void f(int) { } // expected-note {{previous definition is here}}
+void f(const int) { } // expected-error {{redefinition of 'f'}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
new file mode 100644
index 0000000..2ec1454
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+void f0() &; // expected-error {{non-member function cannot have '&' qualifier}}
+void f1() &&; // expected-error {{non-member function cannot have '&&' qualifier}}
+void f2() const volatile &&; // expected-error {{non-member function cannot have 'const volatile &&' qualifier}}
+
+struct X {
+ void f0() &;
+ void f1() &&;
+ static void f2() &; // expected-error{{static member function cannot have '&' qualifier}}
+ static void f3() &&; // expected-error{{static member function cannot have '&&' qualifier}}
+};
+
+typedef void func_type_lvalue() &;
+typedef void func_type_rvalue() &&;
+
+typedef func_type_lvalue *func_type_lvalue_ptr; // expected-error{{pointer to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
+typedef func_type_rvalue *func_type_rvalue_ptr; // expected-error{{pointer to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
+
+typedef func_type_lvalue &func_type_lvalue_ref; // expected-error{{reference to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
+typedef func_type_rvalue &func_type_rvalue_ref; // expected-error{{reference to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
+
+template<typename T = func_type_lvalue> struct wrap {
+ typedef T val;
+ typedef T *ptr;
+ typedef T &ref;
+};
+
+using func_type_lvalue = wrap<>::val;
+using func_type_lvalue = wrap<func_type_lvalue>::val;
+using func_type_rvalue = wrap<func_type_rvalue>::val;
+
+using func_type_lvalue_ptr = wrap<>::ptr;
+using func_type_lvalue_ptr = wrap<func_type_lvalue>::ptr;
+using func_type_rvalue_ptr = wrap<func_type_rvalue>::ptr;
+
+using func_type_lvalue_ref = wrap<>::ref;
+using func_type_lvalue_ref = wrap<func_type_lvalue>::ref;
+using func_type_rvalue_ref = wrap<func_type_rvalue>::ref;
+
+func_type_lvalue f2; // expected-error{{non-member function of type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
+func_type_rvalue f3; // expected-error{{non-member function of type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
+
+struct Y {
+ func_type_lvalue f0;
+ func_type_rvalue f1;
+};
+
+void (X::*mpf1)() & = &X::f0;
+void (X::*mpf2)() && = &X::f1;
+
+
+void (f() &&); // expected-error{{non-member function cannot have '&&' qualifier}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp
new file mode 100644
index 0000000..e2d94fb
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef void F() const;
+
+void f() const; // expected-error {{non-member function cannot have 'const' qualifier}}
+F g; // expected-error {{non-member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}}
+
+struct X {
+ void f() const;
+ friend void g() const; // expected-error {{non-member function cannot have 'const' qualifier}}
+ static void h() const; // expected-error {{static member function cannot have 'const' qualifier}}
+ F i; // ok
+ friend F j; // expected-error {{non-member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}}
+ static F k; // expected-error {{static member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}}
+};
+
+struct Y {
+ friend void X::f() const;
+ friend void ::f() const; // expected-error {{non-member function cannot have 'const' qualifier}}
+};
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp
new file mode 100644
index 0000000..11926f1
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+auto f() -> int[32]; // expected-error{{function cannot return array}}
+auto g() -> int(int); // expected-error{{function cannot return function}}
+auto h() -> auto() -> int; // expected-error{{function cannot return function}}
+auto i() -> auto(*)() -> int;
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp
new file mode 100644
index 0000000..34a8c85
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A { };
+A::A (enum { e1 }) {} // expected-error{{can not be defined in a parameter}} \
+// expected-error{{out-of-line definition}}
+void A::f(enum { e2 }) {} // expected-error{{can not be defined in a parameter}} \
+// expected-error{{out-of-line definition}}
+
+enum { e3 } A::g() { } // expected-error{{can not be defined in the result type}} \
+// expected-error{{out-of-line definition}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp
new file mode 100644
index 0000000..574a3e7
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+auto j() -> enum { e3 }; // expected-error{{unnamed enumeration must be a definition}} expected-error {{requires a specifier or qualifier}} expected-error {{without trailing return type}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp
new file mode 100644
index 0000000..7e35788
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class A {
+public:
+ int& i;
+
+ A(int& i) : i(i) { }
+
+ static int s;
+};
+
+template<typename T> void ft(T& t) {
+ t.*&T::i = 10; // expected-error{{cannot form a pointer-to-member to member 'i' of reference type 'int &'}}
+}
+
+void f() {
+ int b;
+ A a(b);
+
+ int A::*ip = &A::s; // expected-error {{cannot initialize a variable of type 'int A::*' with an rvalue of type 'int *'}}
+ 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<A>' requested here}}
+
+ void A::*p = 0; // expected-error{{'p' declared as a member pointer to void}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp
new file mode 100644
index 0000000..c02105c
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++ [dcl.ref]p5:
+// There shall be no references to references, no arrays of
+// references, and no pointers to references.
+
+// The crazy formatting in here is to enforce the exact report locations.
+
+typedef int &intref;
+typedef intref &intrefref;
+
+template <class T> class RefMem { // expected-warning{{class 'RefMem<int &>' does not declare any constructor to initialize its non-modifiable members}}
+ T
+ &
+ member; // expected-note{{reference member 'member' will never be initialized}}
+};
+
+struct RefRef {
+ int
+ &
+ & // expected-error {{declared as a reference to a reference}}
+ refref0;
+
+ intref
+ &
+ refref1; // collapses
+
+ intrefref
+ &
+ refref2; // collapses
+
+ RefMem
+ <
+ int
+ &
+ >
+ refref3; // collapses expected-note{{in instantiation of template class 'RefMem<int &>' requested here}}
+};
+
+
+template <class T> class PtrMem {
+ T
+ * // expected-error {{declared as a pointer to a reference}}
+ member;
+};
+
+struct RefPtr {
+ typedef
+ int
+ &
+ * // expected-error {{declared as a pointer to a reference}}
+ intrefptr;
+
+ typedef
+ intref
+ * // expected-error {{declared as a pointer to a reference}}
+ intrefptr2;
+
+ int
+ &
+ * // expected-error {{declared as a pointer to a reference}}
+ refptr0;
+
+ intref
+ * // expected-error {{declared as a pointer to a reference}}
+ refptr1;
+
+ PtrMem
+ <
+ int
+ &
+ >
+ refptr2; // expected-note {{in instantiation}}
+};
+
+template <class T> class ArrMem {
+ T
+ member
+ [ // expected-error {{declared as array of references}}
+ 10
+ ];
+};
+template <class T, unsigned N> class DepArrMem {
+ T
+ member
+ [ // expected-error {{declared as array of references}}
+ N
+ ];
+};
+
+struct RefArr {
+ typedef
+ int
+ &
+ intrefarr
+ [ // expected-error {{declared as array of references}}
+ 2
+ ];
+
+ typedef
+ intref
+ intrefarr
+ [ // expected-error {{declared as array of references}}
+ 2
+ ];
+
+ int
+ &
+ refarr0
+ [ // expected-error {{declared as array of references}}
+ 2
+ ];
+ intref
+ refarr1
+ [ // expected-error {{declared as array of references}}
+ 2
+ ];
+ ArrMem
+ <
+ int
+ &
+ >
+ refarr2; // expected-note {{in instantiation}}
+ DepArrMem
+ <
+ int
+ &,
+ 10
+ >
+ refarr3; // expected-note {{in instantiation}}
+};
+
+
+// The declaration of a reference shall contain an initializer
+// (8.5.3) except when the declaration contains an explicit extern
+// specifier (7.1.1), is a class member (9.2) declaration within a
+// class definition, or is the declaration of a parameter or a
+// return type (8.3.5); see 3.1. A reference shall be initialized to
+// refer to a valid object or function. [ Note: in particular, a
+// null reference cannot exist in a well-defined program, because
+// the only way to create such a reference would be to bind it to
+// the "object" obtained by dereferencing a null pointer, which
+// causes undefined behavior. As described in 9.6, a reference
+// cannot be bound directly to a bit-field.
+
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp
new file mode 100644
index 0000000..4ce80bc
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -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;
+};
+#define JOIN2(X,Y) X##Y
+#define JOIN(X,Y) JOIN2(X,Y)
+#define CHECK_EQUAL_TYPES(T1, T2) \
+ int JOIN(array,__LINE__)[is_same<T1, T2>::value? 1 : -1]
+
+int i;
+typedef int& LRI;
+typedef int&& RRI;
+
+typedef LRI& r1; CHECK_EQUAL_TYPES(r1, int&);
+typedef const LRI& r2; CHECK_EQUAL_TYPES(r2, int&);
+typedef const LRI&& r3; CHECK_EQUAL_TYPES(r3, int&);
+
+typedef RRI& r4; CHECK_EQUAL_TYPES(r4, int&);
+typedef RRI&& r5; CHECK_EQUAL_TYPES(r5, int&&);
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp
new file mode 100644
index 0000000..99334b8
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// The nested-name-specifier of a qualified declarator-id shall not begin with a decltype-specifier.
+class foo {
+ static int i;
+ void func();
+};
+
+int decltype(foo())::i; // expected-error{{'decltype' cannot be used to name a declaration}}
+void decltype(foo())::func() { // expected-error{{'decltype' cannot be used to name a declaration}}
+}
+
+
+template<typename T>
+class tfoo {
+ static int i;
+ void func();
+};
+
+template<typename T>
+int decltype(tfoo<T>())::i; // expected-error{{nested name specifier 'decltype(tfoo<T>())::' for declaration does not refer into a class, class template or class template partial specialization}}
+template<typename T>
+void decltype(tfoo<T>())::func() { // expected-error{{nested name specifier 'decltype(tfoo<T>())::' for declaration does not refer into a class, class template or class template partial specialization}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/p1.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/p1.cpp
new file mode 100644
index 0000000..3672ea0
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/p1.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR8019 {
+ struct x;
+ template<typename T> struct x2;
+ struct y {
+ struct PR8019::x { int x; }; // expected-error{{non-friend class member 'x' cannot have a qualified name}}
+
+ struct inner;
+ struct y::inner { }; // expected-warning{{extra qualification on member 'inner'}}
+
+ template<typename T>
+ struct PR8019::x2 { }; // expected-error{{non-friend class member 'x2' cannot have a qualified name}}
+
+ template<typename T>
+ struct inner_template;
+
+ template<typename T>
+ struct y::inner_template { }; // expected-warning{{extra qualification on member 'inner_template'}}
+ };
+
+}
+
+namespace NS {
+ void foo();
+ extern int bar;
+ struct X;
+ template<typename T> struct Y;
+ template<typename T> void wibble(T);
+}
+namespace NS {
+ void NS::foo() {} // expected-warning{{extra qualification on member 'foo'}}
+ int NS::bar; // expected-warning{{extra qualification on member 'bar'}}
+ struct NS::X { }; // expected-warning{{extra qualification on member 'X'}}
+ template<typename T> struct NS::Y; // expected-warning{{extra qualification on member 'Y'}}
+ template<typename T> void NS::wibble(T) { } // expected-warning{{extra qualification on member 'wibble'}}
+}