tst-gcc.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Test program for the gcc interface.
  2. Copyright (C) 2000-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include <stdio.h>
  16. #define __no_type_class -1
  17. #define __void_type_class 0
  18. #define __integer_type_class 1
  19. #define __char_type_class 2
  20. #define __enumeral_type_class 3
  21. #define __boolean_type_class 4
  22. #define __pointer_type_class 5
  23. #define __reference_type_class 6
  24. #define __offset_type_class 7
  25. #define __real_type_class 8
  26. #define __complex_type_class 9
  27. #define __function_type_class 10
  28. #define __method_type_class 11
  29. #define __record_type_class 12
  30. #define __union_type_class 13
  31. #define __array_type_class 14
  32. #define __string_type_class 15
  33. #define __set_type_class 16
  34. #define __file_type_class 17
  35. #define __lang_type_class 18
  36. #define TEST(var) \
  37. ({ int wrong = (__builtin_classify_type (__##var##_type) \
  38. != __##var##_type_class); \
  39. printf ("%-15s is %d: %s\n", \
  40. #var, __builtin_classify_type (__##var##_type), \
  41. wrong ? "WRONG" : "OK"); \
  42. wrong; \
  43. })
  44. static int
  45. do_test (void)
  46. {
  47. int result = 0;
  48. int __integer_type;
  49. void *__pointer_type;
  50. double __real_type;
  51. __complex__ double __complex_type;
  52. struct { int a; } __record_type;
  53. union { int a; int b; } __union_type;
  54. result |= TEST (integer);
  55. result |= TEST (pointer);
  56. result |= TEST (real);
  57. result |= TEST (complex);
  58. result |= TEST (record);
  59. result |= TEST (union);
  60. return result;
  61. }
  62. #define TEST_FUNCTION do_test ()
  63. #include "../test-skeleton.c"