brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 2a41e04 Raw
60 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s2 3#include <stddef.h>4 5struct 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 10namespace ns { void operator ""_ns_good (const char *); }11 12// Check extern "C++" declarations13extern "C++" void operator ""_extern_good (const char *);14extern "C++" { void operator ""_extern_good (const char *); }15 16void fn () { void operator ""_fn_good (const char *); }17 18// 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);25 26// Two-param declarations27void 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);31 32// Check typedef and array equivalences33void operator ""_good (const char[]);34typedef const char c;35void operator ""_good (c*);36 37// Check extra cv-qualifiers38void operator ""_cv_good (volatile const char *, const size_t); // expected-error {{invalid literal operator parameter type 'const volatile char *', did you mean 'const char *'?}}39 40// Template declaration41template <char...> void operator ""_good ();42 43template <typename...> void operator ""_invalid(); // expected-error {{template parameter list for literal operator must be either 'char...' or 'typename T, T...'}}44template <wchar_t...> void operator ""_invalid();  // expected-error {{template parameter list for literal operator must be either 'char...' or 'typename T, T...'}}45template <unsigned long long...> void operator ""_invalid();  // expected-error {{template parameter list for literal operator must be either 'char...' or 'typename T, T...'}}46 47_Complex float operator""if(long double); // expected-warning {{reserved}}48_Complex float test_if_1() { return 2.0f + 1.5if; };49void test_if_2() { "foo"if; } // expected-error {{no matching literal operator for call to 'operator""if'}}50 51template<typename T> void dependent_member_template() {52  T().template operator""_foo<int>(); // expected-error {{'operator""_foo' following the 'template' keyword cannot refer to a dependent template}}53}54 55namespace PR51142 {56// This code previously crashed due to a null template parameter declaration.57template<typename T> // expected-error {{template parameter list for literal operator must be either 'char...' or 'typename T, T...'}}58constexpr auto operator ""_l();59}60