blob: 2b3af88dcb182064e3fdeb8b091089641394a7cb (
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
|
/* Test for @encode in templates. */
/* { dg-options "-lobjc" } */
/* { dg-do run } */
#include <string.h>
#include <stdlib.h>
template<typename T>
const char *my_encode(int variant)
{
const char *result;
switch (variant)
{
case 0:
result = @encode(T);
break;
case 1:
result = @encode(T*);
break;
case 2:
result = @encode(const T*);
break;
default:
result = @encode(int);
break;
}
return result;
}
int main()
{
if (strcmp (@encode(char), my_encode<char>(0)))
abort ();
if (strcmp (@encode(char *), my_encode<char>(1)))
abort ();
if (strcmp (@encode(const char *), my_encode<char>(2)))
abort ();
if (strcmp (@encode(int), my_encode<char>(3)))
abort ();
return 0;
}
|