Blame gnulib/tst-gcc.c

Packit 6c4009
/* Test program for the gcc interface.
Packit 6c4009
   Copyright (C) 2000-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Ulrich Drepper <drepper@cygnus.com>.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <stdio.h>
Packit 6c4009
Packit 6c4009
#define __no_type_class		-1
Packit 6c4009
#define __void_type_class	 0
Packit 6c4009
#define __integer_type_class	 1
Packit 6c4009
#define __char_type_class	 2
Packit 6c4009
#define __enumeral_type_class	 3
Packit 6c4009
#define __boolean_type_class	 4
Packit 6c4009
#define __pointer_type_class	 5
Packit 6c4009
#define __reference_type_class	 6
Packit 6c4009
#define __offset_type_class	 7
Packit 6c4009
#define __real_type_class	 8
Packit 6c4009
#define __complex_type_class	 9
Packit 6c4009
#define __function_type_class	10
Packit 6c4009
#define __method_type_class	11
Packit 6c4009
#define __record_type_class	12
Packit 6c4009
#define __union_type_class	13
Packit 6c4009
#define __array_type_class	14
Packit 6c4009
#define __string_type_class	15
Packit 6c4009
#define __set_type_class	16
Packit 6c4009
#define __file_type_class	17
Packit 6c4009
#define __lang_type_class	18
Packit 6c4009
Packit 6c4009
Packit 6c4009
#define TEST(var) \
Packit 6c4009
  ({ int wrong = (__builtin_classify_type (__##var##_type)		      \
Packit 6c4009
		  != __##var##_type_class);				      \
Packit 6c4009
     printf ("%-15s is %d: %s\n",					      \
Packit 6c4009
	     #var, __builtin_classify_type (__##var##_type),		      \
Packit 6c4009
	     wrong ? "WRONG" : "OK");					      \
Packit 6c4009
     wrong;								      \
Packit 6c4009
  })
Packit 6c4009
Packit 6c4009
Packit 6c4009
static int
Packit 6c4009
do_test (void)
Packit 6c4009
{
Packit 6c4009
  int result = 0;
Packit 6c4009
  int __integer_type;
Packit 6c4009
  void *__pointer_type;
Packit 6c4009
  double __real_type;
Packit 6c4009
  __complex__ double __complex_type;
Packit 6c4009
  struct { int a; } __record_type;
Packit 6c4009
  union { int a; int b; } __union_type;
Packit 6c4009
Packit 6c4009
  result |= TEST (integer);
Packit 6c4009
  result |= TEST (pointer);
Packit 6c4009
  result |= TEST (real);
Packit 6c4009
  result |= TEST (complex);
Packit 6c4009
  result |= TEST (record);
Packit 6c4009
  result |= TEST (union);
Packit 6c4009
Packit 6c4009
  return result;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#define TEST_FUNCTION do_test ()
Packit 6c4009
#include "../test-skeleton.c"