Back to index

glibc  2.9
tst-gcc.c
Go to the documentation of this file.
00001 /* Test program for the gcc interface.
00002    Copyright (C) 2000 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@cygnus.com>.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <stdio.h>
00022 
00023 #define __no_type_class            -1
00024 #define __void_type_class    0
00025 #define __integer_type_class        1
00026 #define __char_type_class    2
00027 #define __enumeral_type_class       3
00028 #define __boolean_type_class        4
00029 #define __pointer_type_class        5
00030 #define __reference_type_class      6
00031 #define __offset_type_class  7
00032 #define __real_type_class    8
00033 #define __complex_type_class        9
00034 #define __function_type_class      10
00035 #define __method_type_class 11
00036 #define __record_type_class 12
00037 #define __union_type_class  13
00038 #define __array_type_class  14
00039 #define __string_type_class 15
00040 #define __set_type_class    16
00041 #define __file_type_class   17
00042 #define __lang_type_class   18
00043 
00044 
00045 #define TEST(var) \
00046   ({ int wrong = (__builtin_classify_type (__##var##_type)                  \
00047                 != __##var##_type_class);                            \
00048      printf ("%-15s is %d: %s\n",                                    \
00049             #var, __builtin_classify_type (__##var##_type),                 \
00050             wrong ? "WRONG" : "OK");                                        \
00051      wrong;                                                          \
00052   })
00053 
00054 
00055 int
00056 main (void)
00057 {
00058   int result = 0;
00059   int __integer_type;
00060   void *__pointer_type;
00061   double __real_type;
00062   __complex__ double __complex_type;
00063   struct { int a; } __record_type;
00064   union { int a; int b; } __union_type;
00065 
00066   result |= TEST (integer);
00067   result |= TEST (pointer);
00068   result |= TEST (real);
00069   result |= TEST (complex);
00070   result |= TEST (record);
00071   result |= TEST (union);
00072 
00073   return result;
00074 }