| 1 |
/* Test for @encode in templates. */ |
| 2 |
/* { dg-do run } */ |
| 3 |
#include <string.h> |
| 4 |
#include <stdlib.h> |
| 5 |
|
| 6 |
template<typename T> |
| 7 |
const char *my_encode(int variant) |
| 8 |
{ |
| 9 |
const char *result; |
| 10 |
|
| 11 |
switch (variant) |
| 12 |
{ |
| 13 |
case 0: |
| 14 |
result = @encode(T); |
| 15 |
break; |
| 16 |
case 1: |
| 17 |
result = @encode(T*); |
| 18 |
break; |
| 19 |
case 2: |
| 20 |
result = @encode(const T*); |
| 21 |
break; |
| 22 |
default: |
| 23 |
result = @encode(int); |
| 24 |
break; |
| 25 |
} |
| 26 |
|
| 27 |
return result; |
| 28 |
} |
| 29 |
|
| 30 |
int main() |
| 31 |
{ |
| 32 |
if (strcmp (@encode(char), my_encode<char>(0))) |
| 33 |
abort (); |
| 34 |
|
| 35 |
if (strcmp (@encode(char *), my_encode<char>(1))) |
| 36 |
abort (); |
| 37 |
|
| 38 |
if (strcmp (@encode(const char *), my_encode<char>(2))) |
| 39 |
abort (); |
| 40 |
|
| 41 |
if (strcmp (@encode(int), my_encode<char>(3))) |
| 42 |
abort (); |
| 43 |
|
| 44 |
return 0; |
| 45 |
} |