From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/CXX/over/over.oper/over.literal/p2.cpp | 35 ++++++++++++++++++++ clang/test/CXX/over/over.oper/over.literal/p3.cpp | 40 +++++++++++++++++++++++ clang/test/CXX/over/over.oper/over.literal/p5.cpp | 22 +++++++++++++ clang/test/CXX/over/over.oper/over.literal/p6.cpp | 13 ++++++++ clang/test/CXX/over/over.oper/over.literal/p7.cpp | 16 +++++++++ clang/test/CXX/over/over.oper/over.literal/p8.cpp | 19 +++++++++++ 6 files changed, 145 insertions(+) create mode 100644 clang/test/CXX/over/over.oper/over.literal/p2.cpp create mode 100644 clang/test/CXX/over/over.oper/over.literal/p3.cpp create mode 100644 clang/test/CXX/over/over.oper/over.literal/p5.cpp create mode 100644 clang/test/CXX/over/over.oper/over.literal/p6.cpp create mode 100644 clang/test/CXX/over/over.oper/over.literal/p7.cpp create mode 100644 clang/test/CXX/over/over.oper/over.literal/p8.cpp (limited to 'clang/test/CXX/over/over.oper/over.literal') diff --git a/clang/test/CXX/over/over.oper/over.literal/p2.cpp b/clang/test/CXX/over/over.oper/over.literal/p2.cpp new file mode 100644 index 0000000..c012104 --- /dev/null +++ b/clang/test/CXX/over/over.oper/over.literal/p2.cpp @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +void operator "" _a(const char *); + +namespace N { + using ::operator "" _a; + + void operator "" _b(const char *); +} + +using N::operator "" _b; + +class C { + void operator "" _c(const char *); // expected-error {{must be in a namespace or global scope}} + + static void operator "" _c(unsigned long long); // expected-error {{must be in a namespace or global scope}} + + friend void operator "" _d(const char *); +}; + +int operator "" _e; // expected-error {{cannot be the name of a variable}} + +void f() { + int operator "" _f; // expected-error {{cannot be the name of a variable}} +} + +extern "C++" { + void operator "" _g(const char *); +} + +template void operator "" _h() {} + +template<> void operator "" _h<'a', 'b', 'c'>() {} + +template void operator "" _h<'a', 'b', 'c', 'd'>(); diff --git a/clang/test/CXX/over/over.oper/over.literal/p3.cpp b/clang/test/CXX/over/over.oper/over.literal/p3.cpp new file mode 100644 index 0000000..674ace9 --- /dev/null +++ b/clang/test/CXX/over/over.oper/over.literal/p3.cpp @@ -0,0 +1,40 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +using size_t = decltype(sizeof(int)); + +// Acceptable parameter declarations +char operator "" _a(const char *); +char operator "" _a(const char []); +char operator "" _a(unsigned long long); +char operator "" _a(long double); +char operator "" _a(char); +char operator "" _a(const volatile char); +char operator "" _a(wchar_t); +char operator "" _a(char16_t); +char operator "" _a(char32_t); +char operator "" _a(const char *, size_t); +char operator "" _a(const wchar_t *, size_t); +char operator "" _a(const char16_t *, size_t); +char operator "" _a(const char32_t *, size_t); +char operator "" _a(const char [32], size_t); + +// Unacceptable parameter declarations +char operator "" _b(); // expected-error {{parameter}} +char operator "" _b(const wchar_t *); // expected-error {{parameter}} +char operator "" _b(long long); // expected-error {{parameter}} +char operator "" _b(double); // expected-error {{parameter}} +char operator "" _b(short); // expected-error {{parameter}} +char operator "" _a(char, int = 0); // expected-error {{parameter}} +char operator "" _b(unsigned short); // expected-error {{parameter}} +char operator "" _b(signed char); // expected-error {{parameter}} +char operator "" _b(unsigned char); // expected-error {{parameter}} +char operator "" _b(const short *, size_t); // expected-error {{parameter}} +char operator "" _b(const unsigned short *, size_t); // expected-error {{parameter}} +char operator "" _b(const signed char *, size_t); // expected-error {{parameter}} +char operator "" _b(const unsigned char *, size_t); // expected-error {{parameter}} +char operator "" _a(const volatile char *, size_t); // expected-error {{parameter}} +char operator "" _a(volatile wchar_t *, size_t); // expected-error {{parameter}} +char operator "" _a(char16_t *, size_t); // expected-error {{parameter}} +char operator "" _a(const char32_t *, size_t, bool = false); // expected-error {{parameter}} +char operator "" _a(const char *, signed long); // expected-error {{parameter}} +char operator "" _a(const char *, size_t = 0); // expected-error {{default argument}} diff --git a/clang/test/CXX/over/over.oper/over.literal/p5.cpp b/clang/test/CXX/over/over.oper/over.literal/p5.cpp new file mode 100644 index 0000000..66f3f97 --- /dev/null +++ b/clang/test/CXX/over/over.oper/over.literal/p5.cpp @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +using size_t = decltype(sizeof(int)); +template struct S {}; + +template void operator "" _a(); +template S operator "" _a(); + +template struct U { + friend int operator "" _a(const char *, size_t); + // FIXME: It's not entirely clear whether this is intended to be legal. + friend U operator "" _a(const T *, size_t); // expected-error {{parameter}} +}; +template struct V { + friend void operator "" _b(); // expected-error {{parameter}} +}; + +template void operator "" _b(); // expected-error {{parameter}} +template void operator "" _b(int N = 0); // expected-error {{parameter}} +template void operator "" _b(); // expected-error {{parameter}} +template T operator "" _b(const char *); // expected-error {{parameter}} +template int operator "" _b(const T *, size_t); // expected-error {{parameter}} diff --git a/clang/test/CXX/over/over.oper/over.literal/p6.cpp b/clang/test/CXX/over/over.oper/over.literal/p6.cpp new file mode 100644 index 0000000..6bfb856 --- /dev/null +++ b/clang/test/CXX/over/over.oper/over.literal/p6.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +extern "C" void operator "" _a(const char *); // expected-error {{must have C++ linkage}} +extern "C" template void operator "" _b(); // expected-error {{must have C++ linkage}} + +extern "C" { + void operator "" _c(const char *); // expected-error {{must have C++ linkage}} + template void operator "" _d(); // expected-error {{must have C++ linkage}} + namespace N { + void operator "" _e(const char *); // expected-error {{must have C++ linkage}} + template void operator "" _f(); // expected-error {{must have C++ linkage}} + } +} diff --git a/clang/test/CXX/over/over.oper/over.literal/p7.cpp b/clang/test/CXX/over/over.oper/over.literal/p7.cpp new file mode 100644 index 0000000..72411b9 --- /dev/null +++ b/clang/test/CXX/over/over.oper/over.literal/p7.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +constexpr int operator "" _a(const char *c) { + return c[0]; +} + +static_assert(operator "" _a("foo") == 'f', ""); + +void puts(const char *); +static inline void operator "" _puts(const char *c) { + puts(c); +} +void f() { + operator "" _puts("foo"); + operator "" _puts("bar"); +} diff --git a/clang/test/CXX/over/over.oper/over.literal/p8.cpp b/clang/test/CXX/over/over.oper/over.literal/p8.cpp new file mode 100644 index 0000000..3f76082 --- /dev/null +++ b/clang/test/CXX/over/over.oper/over.literal/p8.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +struct string; +namespace std { + using size_t = decltype(sizeof(int)); +} + +void operator "" _km(long double); // ok +string operator "" _i18n(const char*, std::size_t); // ok +// FIXME: This should be accepted once we support UCNs +template int operator "" \u03C0(); // ok, UCN for lowercase pi // expected-error {{expected identifier}} +float operator ""E(const char *); // expected-error {{C++11 requires a space between literal and identifier}} expected-warning {{reserved}} +float operator " " B(const char *); // expected-error {{must be '""'}} expected-warning {{reserved}} +string operator "" 5X(const char *, std::size_t); // expected-error {{expected identifier}} +double operator "" _miles(double); // expected-error {{parameter}} +template int operator "" j(const char*); // expected-error {{parameter}} + +// FIXME: Accept this as an extension, with a fix-it to add the space +float operator ""_E(const char *); // expected-error {{C++11 requires a space between the "" and the user-defined suffix in a literal operator}} -- cgit v1.2.3