summaryrefslogtreecommitdiffstats
path: root/test/CXX/dcl.dcl/dcl.spec
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/dcl.dcl/dcl.spec')
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp32
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp25
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp8
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp19
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp9
5 files changed, 75 insertions, 18 deletions
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp
new file mode 100644
index 0000000..40917b8
--- /dev/null
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// A storage-class-specifier shall not be specified in an explicit
+// specialization (14.7.3) or an explicit instantiation (14.7.2)
+// directive.
+template<typename T> void f(T) {}
+template<typename T> static void g(T) {}
+
+
+template<> static void f<int>(int); // expected-error{{explicit specialization cannot have a storage class}}
+template static void f<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}
+
+template<> void f<double>(double);
+template void f<long>(long);
+
+template<> static void g<int>(int); // expected-error{{explicit specialization cannot have a storage class}}
+template static void g<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}
+
+template<> void g<double>(double);
+template void g<long>(long);
+
+template<typename T>
+struct X {
+ static int value;
+};
+
+template<typename T>
+int X<T>::value = 17;
+
+template static int X<int>::value; // expected-error{{explicit instantiation cannot have a storage class}}
+
+template<> static int X<float>::value; // expected-error{{'static' can only be specified inside the class definition}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp
index 34a1784..8a68e4b 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp
@@ -22,14 +22,21 @@ void f() {
new const auto (0);
new (auto) (0.0);
-#if 0
- // When clang supports for-range:
- for (auto i : {1,2,3}) {
+ int arr[] = {1, 2, 3};
+ for (auto i : arr) {
}
-
- // When clang supports inline initialization of members.
- class X {
- static const auto &n = 'x';
- };
-#endif
}
+
+class X {
+ static const auto n = 'x';
+
+ auto m = 0; // expected-error {{'auto' not allowed in non-static class member}}
+};
+
+struct S {
+ static const auto a; // expected-error {{declaration of variable 'a' with type 'auto const' requires an initializer}}
+ static const auto b = 0;
+ static const int c;
+};
+const int S::b;
+const auto S::c = 0;
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
index 09245cf..fabfb53 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
@@ -3,13 +3,13 @@
struct S {
virtual ~S();
- auto a; // expected-error{{'auto' not allowed in struct member}}
- auto *b; // expected-error{{'auto' not allowed in struct member}}
- const auto c; // expected-error{{'auto' not allowed in struct member}}
+ auto a; // expected-error{{'auto' not allowed in non-static struct member}}
+ auto *b; // expected-error{{'auto' not allowed in non-static struct member}}
+ const auto c; // expected-error{{'auto' not allowed in non-static struct member}}
void f() throw (auto); // expected-error{{'auto' not allowed here}}
- friend auto; // expected-error{{'auto' not allowed in struct member}}
+ friend auto; // expected-error{{'auto' not allowed in non-static struct member}}
operator auto(); // expected-error{{'auto' not allowed here}}
};
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
new file mode 100644
index 0000000..81204d8
--- /dev/null
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+struct A { typedef int type; };
+template<typename T> using X = A; // expected-note {{declared here}}
+struct X<int>* p2; // expected-error {{elaborated type refers to a type alias template}}
+
+
+template<typename T> using Id = T; // expected-note {{declared here}}
+template<template<typename> class F>
+struct Y {
+ struct F<int> i; // expected-error {{elaborated type refers to a type alias template}}
+ typename F<A>::type j; // ok
+
+ // FIXME: don't produce the diagnostic both for the definition and the instantiation.
+ template<typename T> using U = F<char>; // expected-note 2{{declared here}}
+ struct Y<F>::template U<char> k; // expected-error 2{{elaborated type refers to a type alias template}}
+ typename Y<F>::template U<char> l; // ok
+};
+template struct Y<Id>; // expected-note {{requested here}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
index 10184a0..b93e8e3 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
@@ -1,15 +1,14 @@
// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
-// FIXME: when clang supports alias-declarations.
-#if 0
using X = struct { // ok
};
-#endif
+template<typename T> using Y = struct { // expected-error {{can not be defined in a type alias template}}
+};
class K {
virtual ~K();
- // FIXME: the diagnostic here isn't very good
- operator struct S {} (); // expected-error 2{{}}
+ // FIXME: the diagnostic here is really bad
+ operator struct S {} (); // expected-error 2{{}} expected-note {{}}
};
void f() {
OpenPOWER on IntegriCloud