File: string-literal-encoding.c

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (33 lines) | stat: -rw-r--r-- 2,120 bytes parent folder | download | duplicates (38)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// RUN: %clang_cc1 -x c++ -std=c++0x -fsyntax-only -verify %s

// This file should be encoded using ISO-8859-1, the string literals should
// contain the ISO-8859-1 encoding for the code points U+00C0 U+00E9 U+00EE
// U+00F5 U+00FC

void f() {
    wchar_t const *a = L""; // expected-error {{illegal character encoding in string literal}}

    char16_t const *b = u""; // expected-error {{illegal character encoding in string literal}}
    char32_t const *c = U""; // expected-error {{illegal character encoding in string literal}}
    wchar_t const *d = LR"()"; // expected-error {{illegal character encoding in string literal}}
    char16_t const *e = uR"()"; // expected-error {{illegal character encoding in string literal}}
    char32_t const *f = UR"()"; // expected-error {{illegal character encoding in string literal}}

    char const *g = ""; // expected-warning {{illegal character encoding in string literal}}
    char const *h = u8""; // expected-error {{illegal character encoding in string literal}}
    char const *i = R"()"; // expected-warning {{illegal character encoding in string literal}}
}

void g() {
    wchar_t const *a = L"foo "; // expected-error {{illegal character encoding in string literal}}

    char16_t const *b = u"foo "; // expected-error {{illegal character encoding in string literal}}
    char32_t const *c = U"foo "; // expected-error {{illegal character encoding in string literal}}
    wchar_t const *d = LR"(foo )"; // expected-error {{illegal character encoding in string literal}}
    char16_t const *e = uR"(foo )"; // expected-error {{illegal character encoding in string literal}}
    char32_t const *f = UR"(foo )"; // expected-error {{illegal character encoding in string literal}}

    char const *g = "foo "; // expected-warning {{illegal character encoding in string literal}}
    char const *h = u8"foo "; // expected-error {{illegal character encoding in string literal}}
    char const *i = R"(foo )"; // expected-warning {{illegal character encoding in string literal}}
}