blob: ec585a61da9fab8ff2ca39f84ada477dc56a0d0b [file] [log] [blame]
Sean Hunta6c058d2010-01-13 09:01:02 +00001// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
2
3#include <stddef.h>
4
Sean Hunt6cf75022010-08-30 17:47:05 +00005struct 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 *);
Sean Hunta6c058d2010-01-13 09:01:02 +00008};
9
Sean Hunt6cf75022010-08-30 17:47:05 +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
13extern "C++" void operator "" extern_good (const char *);
14extern "C++" { void operator "" extern_good (const char *); }
Sean Hunta6c058d2010-01-13 09:01:02 +000015
Sean Hunt6cf75022010-08-30 17:47:05 +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)
19void 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
27void 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
33void operator "" good (const char[]);
34typedef const char c;
35void operator "" good (c*);
36
37// Check extra cv-qualifiers
38void 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.