PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / obj-c++.dg / encode-3.mm
blob1486a652a0d236e3f21fea375bcd5fa60f45f96b
1 /* { dg-do run } */
3 extern "C" {
4 extern void abort (void);
5 extern int strcmp (const char *, const char *);
8 template <class T>
9 struct Vec {
10   T x, y;
11   long z;
12   long long zz;
15 typedef 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;
24 //Vec<double> dd;
25 const char *enc = @encode(Vec<float>);
26 const char *enc2 = @encode(Vec<double>);
27 const char *enc3 = @encode(anonymous);
29 #ifdef __LP64__
30 #define L "q"
31 #else
32 #define L "l"
33 #endif
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
44 int main(void) {
45   const char *encode = @encode(long);
47   if (strcmp (encode, L))
48     abort ();
50   if (strcmp (enc, (const char *)"{Vec<float>=ff" L "q}"))
51     abort ();
53   if (strcmp (enc2, (const char *)"{Vec<double>=dd" L "q}"))
54     abort ();
56   if (strcmp (enc3, (const char *) E3))
57     abort ();
59   return 0;