File: string-literal-encoding.c

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,418,840 kB
  • sloc: cpp: 5,290,826; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,898; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,913; xml: 953; cs: 573; fortran: 539
file content (33 lines) | stat: -rw-r--r-- 2,120 bytes parent folder | download | duplicates (40)
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}}
}