1/* { dg-do run } */
2
3extern "C" {
4extern void abort (void);
5extern int strcmp (const char *, const char *);
6}
7
8template <class T>
9struct Vec {
10  T x, y;
11  long z;
12  long long zz;
13};
14
15typedef struct {
16  float fscalar;
17  double dv[10];
18  int iscalar;
19  long z;
20  long long zz;
21  Vec<const signed char> cv;
22} anonymous;
23
24//Vec<double> dd;
25const char *enc = @encode(Vec<float>);
26const char *enc2 = @encode(Vec<double>);
27const char *enc3 = @encode(anonymous);
28
29#ifdef __LP64__
30#define L "q"
31#else
32#define L "l"
33#endif
34
35/* Darwin (at least, as of XCode 3.2.3/Darwin10) does not encode the read-only
36   attribute  on the type.  Arguably, this is a bug, but we are compatible
37   with this when -fnext-runtime is selected.  */
38#ifdef __NEXT_RUNTIME__
39#define E3 "{?=f[10d]i" L "q{Vec<const signed char>=cc" L "q}}"
40#else
41#define E3 "{?=f[10d]i" L "q{Vec<const signed char>=rcrc" L "q}}"
42#endif
43
44int main(void) {
45  const char *encode = @encode(long);
46
47  if (strcmp (encode, L))
48    abort ();
49
50  if (strcmp (enc, (const char *)"{Vec<float>=ff" L "q}"))
51    abort ();
52
53  if (strcmp (enc2, (const char *)"{Vec<double>=dd" L "q}"))
54    abort ();
55
56  if (strcmp (enc3, (const char *) E3))
57    abort ();
58
59  return 0;
60}
61