[Patch testsuite obvious] g++.dg/ext/pr57735.C should not run if the
[gcc.git] / gcc / testsuite / g++.dg / ext / pr57735.C
1 /* { dg-do compile { target arm*-*-* } } */
2 /* { dg-require-effective-target arm_arch_v5te_ok } */
3 /* { dg-require-effective-target arm_arm_ok } */
4 /* { dg-skip-if "do not override -mfloat-abi" { *-*-* } { "-mfloat-abi=*" } {"-mfloat-abi=soft" } } */
5 /* { dg-options "-march=armv5te -marm -mtune=xscale -mfloat-abi=soft -O1" } */
6
7 typedef unsigned int size_t;
8 __extension__
9 typedef long long int int64_t;
10 namespace WTF {
11 template<typename T> class RefPtr {
12 public:
13 inline T* operator->() const { return m_ptr; }
14 T* m_ptr;
15 };
16 }
17 using WTF::RefPtr;
18 namespace JSC {
19 class ExecState;
20 class JSString;
21 typedef int64_t EncodedJSValue;
22 class JSValue {
23 public:
24 static EncodedJSValue encode(JSValue);
25 JSString* toString(ExecState*) const;
26 };
27 }
28 typedef unsigned char LChar;
29 typedef short unsigned int UChar;
30 namespace WTF {
31 template<typename T, size_t inlineCapacity = 0>
32 class Vector {
33 public:
34 template<typename U> bool tryAppend(const U*, size_t);
35 };
36 }
37 using WTF::Vector;
38 namespace WTF {
39 template<typename CharType> inline bool isASCIIDigit(CharType c)
40 {
41 }
42 template<typename CharType> inline bool isASCIIHexDigit(CharType c)
43 {
44 return isASCIIDigit(c) || ((c | 0x20) >= 'a' && (c | 0x20) <= 'f');
45 }
46 class StringImpl;
47 }
48 using WTF::StringImpl;
49 namespace WTF {
50 class StringImpl {
51 public:
52 unsigned length() const { return m_length; }
53 unsigned m_length;
54 };
55 }
56 namespace JSC {
57 class Register {
58 };
59 class UString {
60 public:
61 unsigned length() const
62 {
63 return m_impl->length();
64 }
65 const LChar* characters8() const
66 {
67 }
68 RefPtr<StringImpl> m_impl;
69 };
70 class ExecState : private Register {
71 public:
72 JSValue argument(size_t argument)
73 {
74 }
75 };
76 class JSCell {
77 };
78 class JSString : public JSCell {
79 public:
80 const UString& value(ExecState*) const;
81 };
82 class JSStringBuilder {
83 public:
84 void append(const UChar u)
85 {
86 m_okay &= buffer16.tryAppend(&u, 1);
87 }
88 Vector<UChar, 64> buffer16;
89 bool m_okay;
90 };
91 template <typename T>
92 class Lexer {
93 public:
94 static unsigned char convertHex(int c1, int c2);
95 };
96 }
97 namespace WTF {
98 namespace Unicode {
99 int UTF8SequenceLength(char);
100 int decodeUTF8Sequence(const char*);
101 }
102 }
103 using namespace WTF;
104 using namespace Unicode;
105 namespace JSC {
106 template <typename CharType>
107 static JSValue decode(ExecState* exec, const CharType* characters, int length, const char* doNotUnescape, bool strict)
108 {
109 JSStringBuilder builder;
110 int k = 0;
111 UChar u = 0;
112 while (k < length) {
113 const CharType* p = characters + k;
114 CharType c = *p;
115 if (c == '%') {
116 int charLen = 0;
117 if (k <= length - 3 && isASCIIHexDigit(p[1]) && isASCIIHexDigit(p[2])) {
118 const char b0 = Lexer<CharType>::convertHex(p[1], p[2]);
119 const int sequenceLen = UTF8SequenceLength(b0);
120 if (sequenceLen && k <= length - sequenceLen * 3) {
121 charLen = sequenceLen * 3;
122 char sequence[5];
123 if (charLen != 0) {
124 const int character = decodeUTF8Sequence(sequence);
125 if (character < 0 || character >= 0x110000)
126 charLen = 0;
127 else if (character >= 0x10000) {
128 builder.append(static_cast<UChar>(0xD800 | ((character - 0x10000) >> 10)));
129 } else
130 u = static_cast<UChar>(character);
131 }
132 }
133 }
134 }
135 }
136 }
137 static JSValue decode(ExecState* exec, const char* doNotUnescape, bool strict)
138 {
139 UString str = exec->argument(0).toString(exec)->value(exec);
140 return decode(exec, str.characters8(), str.length(), doNotUnescape, strict);
141 }
142 EncodedJSValue globalFuncDecodeURI(ExecState* exec)
143 {
144 static const char do_not_unescape_when_decoding_URI[] =
145 "#$&+,/:;=?@";
146 return JSValue::encode(decode(exec, do_not_unescape_when_decoding_URI, true));
147 }
148 }