summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/torture/pr69264.C
blob: a531bfc9b8c30a96d77a5e7c7c405f5f93b169ad (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
// { dg-do compile }
// { dg-additional-options "-Wno-return-type" }
// { dg-additional-options "-mcpu=970 -maltivec" { target powerpc*-*-* } }

typedef union {
    long int asBits;
} jsval_layout;
static jsval_layout STRING_TO_JSVAL_IMPL() {}

typedef __attribute__ ((aligned(sizeof (long int)))) long int jsval;
class Value {
public:
    void setString() {
	data = STRING_TO_JSVAL_IMPL();
    }
    jsval_layout data;
} __attribute__ ((aligned(8)));

static Value StringValue()
{
  Value v;
  v.setString();
  return v;
}

static const jsval & Jsvalify(const Value & v)
{
  return (const jsval &)v;
}

static Value *Valueify(jsval *v)
{
  return (Value *) v;
}

struct JSObject {
    void getQNameLocalName();
};
static Value IdToValue(int id)
{
  if (id)
    return StringValue();
}

static jsval IdToJsval(int id)
{
  return Jsvalify(IdToValue(id));
}

class AutoGCRooter;
struct JSContext {
    AutoGCRooter *autoGCRooters;
};
class AutoGCRooter {
public:
    AutoGCRooter(JSContext *cx) {}
};
class AutoArrayRooter:AutoGCRooter {
public:
    AutoArrayRooter(JSContext *cx, Value *vec):AutoGCRooter(cx)
    {
      array = vec;
      cx->autoGCRooters = this;
    }
    Value *array;
};

static void PutProperty(JSContext *cx, int id, jsval *vp)
{
  JSObject *nameobj;
  jsval roots[3];
  roots[1] = IdToJsval(id);
  roots[2] = *vp;
  AutoArrayRooter tvr(cx, Valueify(roots));
  nameobj->getQNameLocalName();
}

void xml_defineProperty(JSContext *cx, int id, const Value *v)
{
  jsval tmp = Jsvalify(*v);
  PutProperty(cx, id, &tmp);
}