Sean Hunt | a6c058d | 2010-01-13 09:01:02 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s |
| 2 | |
| 3 | #include <stddef.h> |
| 4 | |
| 5 | struct tag { |
| 6 | void operator "" tag_bad (const char *); // expected-error {{literal operator 'operator "" tag_bad' must be in a namespace or global scope}} |
| 7 | friend void operator "" tag_good (const char *); |
| 8 | }; |
| 9 | |
| 10 | namespace ns { void operator "" ns_good (const char *); } |
| 11 | |
| 12 | // Check extern "C++" declarations |
| 13 | extern "C++" void operator "" extern_good (const char *); |
| 14 | extern "C++" { void operator "" extern_good (const char *); } |
| 15 | |
| 16 | void fn () { void operator "" fn_bad (const char *); } // expected-error {{literal operator 'operator "" fn_bad' must be in a namespace or global scope}} |
| 17 | |
| 18 | // One-param declarations (const char * was already checked) |
| 19 | void operator "" good (char); |
| 20 | void operator "" good (wchar_t); |
| 21 | void operator "" good (char16_t); |
| 22 | void operator "" good (char32_t); |
| 23 | void operator "" good (unsigned long long); |
| 24 | void operator "" good (long double); |
| 25 | |
| 26 | // Two-param declarations |
| 27 | void operator "" good (const char *, size_t); |
| 28 | void operator "" good (const wchar_t *, size_t); |
| 29 | void operator "" good (const char16_t *, size_t); |
| 30 | void operator "" good (const char32_t *, size_t); |
| 31 | |
| 32 | // Check typedef and array equivalences |
| 33 | void operator "" good (const char[]); |
| 34 | typedef const char c; |
| 35 | void operator "" good (c*); |
| 36 | |
| 37 | // Check extra cv-qualifiers |
| 38 | void operator "" cv_good (volatile const char *, const size_t); |
| 39 | |
| 40 | // Template delcaration (not implemented yet) |
| 41 | // template <char...> void operator "" good (); |
| 42 | |
| 43 | // FIXME: Test some invalid decls that might crop up. |