blob: 06ef49fc0ae1cae7a76bba26baa1c4ba138205fb [file] [log] [blame]
Richard Smith762bb9d2011-10-13 22:29:44 +00001// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
Sean Hunta6c058d2010-01-13 09:01:02 +00002
3#include <stddef.h>
4
Sean Hunt6cf75022010-08-30 17:47:05 +00005struct tag {
Douglas Gregor1155c422011-08-30 22:40:35 +00006 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 Hunta6c058d2010-01-13 09:01:02 +00008};
9
Douglas Gregor1155c422011-08-30 22:40:35 +000010namespace ns { void operator "" _ns_good (const char *); }
Sean Hunta6c058d2010-01-13 09:01:02 +000011
Sean Hunt6cf75022010-08-30 17:47:05 +000012// Check extern "C++" declarations
Douglas Gregor1155c422011-08-30 22:40:35 +000013extern "C++" void operator "" _extern_good (const char *);
14extern "C++" { void operator "" _extern_good (const char *); }
Sean Hunta6c058d2010-01-13 09:01:02 +000015
Douglas Gregor1155c422011-08-30 22:40:35 +000016void fn () { void operator "" _fn_bad (const char *); } // expected-error {{literal operator 'operator "" _fn_bad' must be in a namespace or global scope}}
Sean Hunta6c058d2010-01-13 09:01:02 +000017
Sean Hunt6cf75022010-08-30 17:47:05 +000018// One-param declarations (const char * was already checked)
Douglas Gregor1155c422011-08-30 22:40:35 +000019void operator "" _good (char);
20void operator "" _good (wchar_t);
21void operator "" _good (char16_t);
22void operator "" _good (char32_t);
23void operator "" _good (unsigned long long);
24void operator "" _good (long double);
Sean Hunta6c058d2010-01-13 09:01:02 +000025
Sean Hunt6cf75022010-08-30 17:47:05 +000026// Two-param declarations
Douglas Gregor1155c422011-08-30 22:40:35 +000027void operator "" _good (const char *, size_t);
28void operator "" _good (const wchar_t *, size_t);
29void operator "" _good (const char16_t *, size_t);
30void operator "" _good (const char32_t *, size_t);
Sean Hunta6c058d2010-01-13 09:01:02 +000031
Sean Hunt6cf75022010-08-30 17:47:05 +000032// Check typedef and array equivalences
Douglas Gregor1155c422011-08-30 22:40:35 +000033void operator "" _good (const char[]);
Sean Hunt6cf75022010-08-30 17:47:05 +000034typedef const char c;
Douglas Gregor1155c422011-08-30 22:40:35 +000035void operator "" _good (c*);
Sean Hunt6cf75022010-08-30 17:47:05 +000036
37// Check extra cv-qualifiers
Douglas Gregor1155c422011-08-30 22:40:35 +000038void operator "" _cv_good (volatile const char *, const size_t);
Sean Hunt6cf75022010-08-30 17:47:05 +000039
40// Template delcaration (not implemented yet)
41// template <char...> void operator "" good ();
42
43// FIXME: Test some invalid decls that might crop up.