PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / obj-c++.dg / encode-10.mm
blob2b3af88dcb182064e3fdeb8b091089641394a7cb
1 /* Test for @encode in templates.  */
2 /* { dg-options "-lobjc" } */
3 /* { dg-do run } */
4 #include <string.h>           
5 #include <stdlib.h>
7 template<typename T>
8 const char *my_encode(int variant)
10   const char *result;
12   switch (variant)
13     {
14     case 0:
15       result = @encode(T);
16       break;
17     case 1:
18       result = @encode(T*);
19       break;
20     case 2:
21       result = @encode(const T*);
22       break;
23     default:
24       result = @encode(int);
25       break;
26     }
28   return result;
31 int main()
33   if (strcmp (@encode(char), my_encode<char>(0)))
34     abort ();
36   if (strcmp (@encode(char *), my_encode<char>(1)))
37     abort ();
39   if (strcmp (@encode(const char *), my_encode<char>(2)))
40     abort ();
42   if (strcmp (@encode(int), my_encode<char>(3)))
43     abort ();
45   return 0;