aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/pr57735.C
blob: a8f7d05712c9a823564d58e2a149c7bc356a5e9e (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* { dg-do compile { target arm*-*-* } } */
/* { dg-require-effective-target arm_arch_v5te_ok } */
/* { dg-require-effective-target arm_arm_ok } */
/* { dg-skip-if "do not override -mfloat-abi" { *-*-* } { "-mfloat-abi=*" } {"-mfloat-abi=soft" } } */
/* { dg-options "-march=armv5te -marm  -mtune=xscale -mfloat-abi=soft -O1" } */

typedef unsigned int size_t;
__extension__
typedef long long int int64_t;
namespace WTF {
    template<typename T> class RefPtr {
    public:
        inline T* operator->() const { return m_ptr; }
        T* m_ptr;
    };
}
using WTF::RefPtr;
namespace JSC {
    class ExecState;
    class JSString;
    typedef int64_t EncodedJSValue;
    class JSValue {
    public:
        static EncodedJSValue encode(JSValue);
        JSString* toString(ExecState*) const;
    };
}
typedef unsigned char LChar;
    typedef short unsigned int UChar;
namespace WTF {
    template<typename T, size_t inlineCapacity = 0>
    class Vector {
    public:
        template<typename U> bool tryAppend(const U*, size_t);
    };
}
using WTF::Vector;
namespace WTF {
template<typename CharType> inline bool isASCIIDigit(CharType c)
{
}
template<typename CharType> inline bool isASCIIHexDigit(CharType c)
{
    return isASCIIDigit(c) || ((c | 0x20) >= 'a' && (c | 0x20) <= 'f');
}
    class StringImpl;
}
using WTF::StringImpl;
namespace WTF {
class StringImpl {
public:
    unsigned length() const { return m_length; }
    unsigned m_length;
};
}
namespace JSC {
    class Register {
    };
class UString {
public:
    unsigned length() const
    {
        return m_impl->length();
    }
    const LChar* characters8() const
    {
    }
    RefPtr<StringImpl> m_impl;
};
    class ExecState : private Register {
    public:
        JSValue argument(size_t argument)
        {
        }
    };
    class JSCell {
    };
    class JSString : public JSCell {
    public:
        const UString& value(ExecState*) const;
    };
class JSStringBuilder {
public:
    void append(const UChar u)
    {
        m_okay &= buffer16.tryAppend(&u, 1);
    }
    Vector<UChar, 64> buffer16;
    bool m_okay;
};
template <typename T>
class Lexer {
public:
    static unsigned char convertHex(int c1, int c2);
};
}
namespace WTF {
namespace Unicode {
    int UTF8SequenceLength(char);
    int decodeUTF8Sequence(const char*);
}
}
using namespace WTF;
using namespace Unicode;
namespace JSC {
template <typename CharType>
static JSValue decode(ExecState* exec, const CharType* characters, int length, const char* doNotUnescape, bool strict)
{
    JSStringBuilder builder;
    int k = 0;
    UChar u = 0;
    while (k < length) {
        const CharType* p = characters + k;
        CharType c = *p;
        if (c == '%') {
            int charLen = 0;
            if (k <= length - 3 && isASCIIHexDigit(p[1]) && isASCIIHexDigit(p[2])) {
                const char b0 = Lexer<CharType>::convertHex(p[1], p[2]);
                const int sequenceLen = UTF8SequenceLength(b0);
                if (sequenceLen && k <= length - sequenceLen * 3) {
                    charLen = sequenceLen * 3;
                    char sequence[5];
                    if (charLen != 0) {
                        const int character = decodeUTF8Sequence(sequence);
                        if (character < 0 || character >= 0x110000)
                            charLen = 0;
                        else if (character >= 0x10000) {
                            builder.append(static_cast<UChar>(0xD800 | ((character - 0x10000) >> 10)));
                        } else
                            u = static_cast<UChar>(character);
                    }
                }
            }
        }
    }
}
static JSValue decode(ExecState* exec, const char* doNotUnescape, bool strict)
{
    UString str = exec->argument(0).toString(exec)->value(exec);
        return decode(exec, str.characters8(), str.length(), doNotUnescape, strict);
}
EncodedJSValue globalFuncDecodeURI(ExecState* exec)
{
    static const char do_not_unescape_when_decoding_URI[] =
        "#$&+,/:;=?@";
    return JSValue::encode(decode(exec, do_not_unescape_when_decoding_URI, true));
}
}