llvm-project/clang/test/SemaCXX/cxx1z-user-defined-literals.cpp
Reid Kleckner 0d9919d362 Revert "[Clang] CWG1473: do not err on the lack of space after operator"""
This reverts commit f2583f3acf596cc545c8c0e3cb28e712f4ebf21b.

There is a large body of non-conforming C-like code using format strings
like this:

  #define PRIuS "zu"
  void h(size_t foo, size_t bar) {
    printf("foo is %"PRIuS", bar is %"PRIuS, foo, bar);
  }

Rejecting this code would be very disruptive. We could decide to do
that, but it's sufficiently disruptive that I think it requires
gathering more community consensus with an RFC, and Aaron indicated [1]
it's OK to revert for now so continuous testing systems can see past
this issue while we decide what to do.

[1] https://reviews.llvm.org/D153156#4607717
2023-08-22 18:10:41 -07:00

22 lines
467 B
C++

// RUN: %clang_cc1 -std=c++1z %s -include %s -verify
#ifndef INCLUDED
#define INCLUDED
#pragma clang system_header
namespace std {
using size_t = decltype(sizeof(0));
struct string_view {};
string_view operator""sv(const char*, size_t);
}
#else
using namespace std;
string_view s = "foo"sv;
const char* p = "bar"sv; // expected-error {{no viable conversion}}
char error = 'x'sv; // expected-error {{invalid suffix}} expected-error {{expected ';'}}
#endif