gcc/testsuite/obj-c++.dg/encode-9.mm
raw| 1 | /* Test than @encode is properly instantiated. */ |
| 2 | /* { dg-do run } */ |
| 3 | |
| 4 | #include <string.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <objc/objc.h> |
| 7 | |
| 8 | template<typename T> |
| 9 | class typeOf { |
| 10 | public: |
| 11 | operator const char*() { return @encode(T); } |
| 12 | }; |
| 13 | |
| 14 | int main() { |
| 15 | typeOf<int> t; |
| 16 | if (strcmp ((const char *)t, @encode(int))) |
| 17 | abort(); |
| 18 | |
| 19 | typeOf<const char*> c; |
| 20 | if (strcmp ((const char *)c, @encode(const char*))) |
| 21 | abort(); |
| 22 | |
| 23 | return 0; |
| 24 | } |
| 25 |