summaryrefslogtreecommitdiff
path: root/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc')
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp32
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp14
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp26
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp11
4 files changed, 83 insertions, 0 deletions
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp
new file mode 100644
index 0000000..cbb439e
--- /dev/null
+++ b/clang/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 has extraneous, inconsistent storage class 'static'}}
+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-warning{{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/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp
new file mode 100644
index 0000000..fd86276
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify %s
+// XFAIL: *
+
+typedef const int T0;
+typedef int& T1;
+
+struct s0 {
+ mutable const int f0; // expected-error{{'mutable' and 'const' cannot be mixed}}
+ mutable T0 f1; // expected-error{{'mutable' and 'const' cannot be mixed}}
+ mutable int &f2; // expected-error{{'mutable' cannot be applied to references}}
+ mutable T1 f3; // expected-error{{'mutable' cannot be applied to references}}
+ mutable struct s1 {}; // expected-error{{'mutable' cannot be applied to non-data members}}
+ mutable void im0(); // expected-error{{'mutable' cannot be applied to functions}}
+};
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp
new file mode 100644
index 0000000..44cc5a7
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++0x-compat %s
+
+// The auto or register specifiers can be applied only to names of objects
+// declared in a block (6.3) or to function parameters (8.4).
+
+auto int ao; // expected-error {{illegal storage class on file-scoped variable}}
+auto void af(); // expected-error {{illegal storage class on function}}
+
+register int ro; // expected-error {{illegal storage class on file-scoped variable}}
+register void rf(); // expected-error {{illegal storage class on function}}
+
+struct S {
+ auto int ao; // expected-error {{storage class specified for a member declaration}}
+ auto void af(); // expected-error {{storage class specified for a member declaration}}
+
+ register int ro; // expected-error {{storage class specified for a member declaration}}
+ register void rf(); // expected-error {{storage class specified for a member declaration}}
+};
+
+void foo(auto int ap, register int rp) {
+ auto int abo;
+ auto void abf(); // expected-error {{illegal storage class on function}}
+
+ register int rbo;
+ register void rbf(); // expected-error {{illegal storage class on function}}
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp
new file mode 100644
index 0000000..491ab17
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify %s
+
+struct S; // expected-note 2{{forward declaration of 'S'}}
+extern S a;
+extern S f(); // expected-note {{'f' declared here}}
+extern void g(S a);
+
+void h() {
+ g(a); // expected-error {{argument type 'S' is incomplete}}
+ f(); // expected-error {{calling 'f' with incomplete return type 'S'}}
+}