Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
Sean Hunt | a6c058d | 2010-01-13 09:01:02 +0000 | [diff] [blame] | 2 | |
| 3 | #include <stddef.h> |
| 4 | |
Sean Hunt | 6cf7502 | 2010-08-30 17:47:05 +0000 | [diff] [blame] | 5 | struct tag { |
Douglas Gregor | 1155c42 | 2011-08-30 22:40:35 +0000 | [diff] [blame] | 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 *); |
Sean Hunt | a6c058d | 2010-01-13 09:01:02 +0000 | [diff] [blame] | 8 | }; |
| 9 | |
Douglas Gregor | 1155c42 | 2011-08-30 22:40:35 +0000 | [diff] [blame] | 10 | namespace ns { void operator "" _ns_good (const char *); } |
Sean Hunt | a6c058d | 2010-01-13 09:01:02 +0000 | [diff] [blame] | 11 | |
Sean Hunt | 6cf7502 | 2010-08-30 17:47:05 +0000 | [diff] [blame] | 12 | // Check extern "C++" declarations |
Douglas Gregor | 1155c42 | 2011-08-30 22:40:35 +0000 | [diff] [blame] | 13 | extern "C++" void operator "" _extern_good (const char *); |
| 14 | extern "C++" { void operator "" _extern_good (const char *); } |
Sean Hunt | a6c058d | 2010-01-13 09:01:02 +0000 | [diff] [blame] | 15 | |
Douglas Gregor | 1155c42 | 2011-08-30 22:40:35 +0000 | [diff] [blame] | 16 | void fn () { void operator "" _fn_bad (const char *); } // expected-error {{literal operator 'operator "" _fn_bad' must be in a namespace or global scope}} |
Sean Hunt | a6c058d | 2010-01-13 09:01:02 +0000 | [diff] [blame] | 17 | |
Sean Hunt | 6cf7502 | 2010-08-30 17:47:05 +0000 | [diff] [blame] | 18 | // One-param declarations (const char * was already checked) |
Douglas Gregor | 1155c42 | 2011-08-30 22:40:35 +0000 | [diff] [blame] | 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); |
Sean Hunt | a6c058d | 2010-01-13 09:01:02 +0000 | [diff] [blame] | 25 | |
Sean Hunt | 6cf7502 | 2010-08-30 17:47:05 +0000 | [diff] [blame] | 26 | // Two-param declarations |
Douglas Gregor | 1155c42 | 2011-08-30 22:40:35 +0000 | [diff] [blame] | 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); |
Sean Hunt | a6c058d | 2010-01-13 09:01:02 +0000 | [diff] [blame] | 31 | |
Sean Hunt | 6cf7502 | 2010-08-30 17:47:05 +0000 | [diff] [blame] | 32 | // Check typedef and array equivalences |
Douglas Gregor | 1155c42 | 2011-08-30 22:40:35 +0000 | [diff] [blame] | 33 | void operator "" _good (const char[]); |
Sean Hunt | 6cf7502 | 2010-08-30 17:47:05 +0000 | [diff] [blame] | 34 | typedef const char c; |
Douglas Gregor | 1155c42 | 2011-08-30 22:40:35 +0000 | [diff] [blame] | 35 | void operator "" _good (c*); |
Sean Hunt | 6cf7502 | 2010-08-30 17:47:05 +0000 | [diff] [blame] | 36 | |
| 37 | // Check extra cv-qualifiers |
Douglas Gregor | 1155c42 | 2011-08-30 22:40:35 +0000 | [diff] [blame] | 38 | void operator "" _cv_good (volatile const char *, const size_t); |
Sean Hunt | 6cf7502 | 2010-08-30 17:47:05 +0000 | [diff] [blame] | 39 | |
| 40 | // Template delcaration (not implemented yet) |
| 41 | // template <char...> void operator "" good (); |
| 42 | |
| 43 | // FIXME: Test some invalid decls that might crop up. |