diff options
author | dim <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
commit | c49018d9cce52d8c9f34b44865ec3ba8e89a1488 (patch) | |
tree | c5e9e10bc189de0058aa763c47b9920a8351b7df /test/CXX/dcl.dcl | |
parent | 110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab (diff) | |
download | FreeBSD-src-c49018d9cce52d8c9f34b44865ec3ba8e89a1488.zip FreeBSD-src-c49018d9cce52d8c9f34b44865ec3ba8e89a1488.tar.gz |
Vendor import of clang trunk r132879:
http://llvm.org/svn/llvm-project/cfe/trunk@132879
Diffstat (limited to 'test/CXX/dcl.dcl')
6 files changed, 76 insertions, 19 deletions
diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp index 198b013..e3d3d68 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp @@ -3,7 +3,7 @@ namespace NIL {} // expected-note {{previous definition}} inline namespace NIL {} // expected-error {{cannot be reopened as inline}} inline namespace IL {} // expected-note {{previous definition}} -namespace IL {} // expected-error {{cannot be reopened as non-inline}} +namespace IL {} // expected-warning{{inline namespace cannot be re-opened as a non-inline namespace}} namespace {} // expected-note {{previous definition}} inline namespace {} // expected-error {{cannot be reopened as inline}} 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() { |