Commit 761c0d29 by Andrew Pinski Committed by Andrew Pinski

re PR libobjc/25354 (There should be an automated testsuite for objc_sizeof_type…

re PR libobjc/25354 (There should be an automated testsuite for objc_sizeof_type and objc_alignof_type)

2005-12-12  Andrew Pinski  <pinskia@physics.uc.edu>

        PR libobjc/25354
        * objc.dg/gnu-encoding: New directory.
        * objc.dg/gnu-encoding/compat-common.h: New file.
        * objc.dg/gnu-encoding/struct-layout-1.h: New file.
        * objc.dg/gnu-encoding/struct-layout-1_test.h: New file.
        * objc.dg/gnu-encoding/vector-defs.h: New file.
        * objc.dg/gnu-encoding/gnu-encoding.exp: New file.
        * objc.dg/gnu-encoding/generate-random.c: New file.
        * objc.dg/gnu-encoding/generate-random_r.c: New file.
        * objc.dg/gnu-encoding/struct-layout-encoding-1_generate.c: New file.
        * objc.dg/gnu-encoding/generate-random.h: New file.


2005-12-12  Andrew Pinski  <pinskia@physics.uc.edu>

        * encoding.c (TYPE_FIELDS): Fix to skip over just _C_STRUCT_B and        the name.
        (get_inner_array_type): Fix to skip over _C_ARY_B and size.
        (rs6000_special_round_type_align): Update for the ABI fix.
        (objc_layout_finish_structure): Correct the encoding which is passed to
        ROUND_TYPE_ALIGN.

From-SVN: r108398
parent 3897c0aa
2005-12-12 Andrew Pinski <pinskia@physics.uc.edu>
PR libobjc/25354
* objc.dg/gnu-encoding: New directory.
* objc.dg/gnu-encoding/compat-common.h: New file.
* objc.dg/gnu-encoding/struct-layout-1.h: New file.
* objc.dg/gnu-encoding/struct-layout-1_test.h: New file.
* objc.dg/gnu-encoding/vector-defs.h: New file.
* objc.dg/gnu-encoding/gnu-encoding.exp: New file.
* objc.dg/gnu-encoding/generate-random.c: New file.
* objc.dg/gnu-encoding/generate-random_r.c: New file.
* objc.dg/gnu-encoding/struct-layout-encoding-1_generate.c: New file.
* objc.dg/gnu-encoding/generate-random.h: New file.
2005-12-11 Mark Mitchell <mark@codesourcery.com>
PR c++/25337
/* Several of the binary compatibility tests use these macros to
allow debugging the test or tracking down a failure by getting an
indication of whether each individual check passed or failed.
When DBG is defined, each check is shown by a dot (pass) or 'F'
(fail) rather than aborting as soon as a failure is detected. */
#ifdef DBG
#include <stdio.h>
#define DEBUG_INIT setbuf (stdout, NULL);
#define DEBUG_FPUTS(x) fputs (x, stdout)
#define DEBUG_DOT putc ('.', stdout)
#define DEBUG_NL putc ('\n', stdout)
#define DEBUG_FAIL putc ('F', stdout); fails++
#define DEBUG_CHECK { DEBUG_FAIL; } else { DEBUG_DOT; }
#define DEBUG_FINI if (fails) DEBUG_FPUTS ("failed\n"); \
else DEBUG_FPUTS ("passed\n");
#else
#define DEBUG_INIT
#define DEBUG_FPUTS(x)
#define DEBUG_DOT
#define DEBUG_NL
#define DEBUG_FAIL abort ()
#define DEBUG_CHECK abort ();
#define DEBUG_FINI
#endif
#ifdef __GNUC__
#define CINT(x, y) (x + y * __extension__ 1i)
#define CDBL(x, y) (x + y * __extension__ 1i)
#else
#ifdef __SUNPRO_C
/* ??? Complex support without <complex.h>. */
#else
#include <complex.h>
#endif
#ifndef SKIP_COMPLEX_INT
#define CINT(x, y) ((_Complex int) (x + y * _Complex_I))
#endif
#define CDBL(x, y) (x + y * _Complex_I)
#endif
extern void abort (void);
extern int fails;
/* Copyright (C) 2004 Free Software Foundation
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA. */
struct generate_random_data
{
int *fptr, *rptr, *state;
int rand_type, rand_deg, rand_sep;
int *end_ptr;
};
extern void generate_srandom (unsigned int);
extern char *generate_initstate (unsigned int, char *, size_t);
extern char *generate_setstate (char *);
extern long int generate_random (void);
extern int generate_random_r (struct generate_random_data *, int *);
extern int generate_srandom_r (unsigned int, struct generate_random_data *);
extern int generate_initstate_r (unsigned int, char *, size_t,
struct generate_random_data *);
extern int generate_setstate_r (char *, struct generate_random_data *);
# GCC Objective-C testsuite that uses the `dg.exp' driver.
# Copyright (C) 1997, 2001 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Load support procs.
load_lib objc-dg.exp
# If a testcase doesn't have special options, use these.
global DEFAULT_CFLAGS
if ![info exists DEFAULT_CFLAGS] then {
set DEFAULT_CFLAGS "-fgnu-runtime"
}
# Initialize `dg'.
dg-init
#
# gnu-encoding tests
#
set tstobjdir "$tmpdir/objc.dg-struct-layout-encoding-1"
set generator "$tmpdir/objc.dg-struct-layout-encoding-1_generate"
set generator_src "$srcdir/$subdir/struct-layout-encoding-1_generate.c"
set generator_src "$generator_src $srcdir/$subdir/generate-random.c"
set generator_src "$generator_src $srcdir/$subdir/generate-random_r.c"
set generator_cmd "-o $generator $generator_src"
set status [remote_exec host "$HOSTCC $HOSTCFLAGS $generator_cmd"]
set status [lindex $status 0]
if { $status == 0 } then {
file delete -force $tstobjdir
file mkdir $tstobjdir
set generator_args "-s $srcdir/$subdir -d $tstobjdir"
# set generator_args "$generator_args -n 15000"
set status [remote_exec host "$generator $generator_args"]
set status [lindex $status 0]
if { $status == 0 } then {
foreach src [lsort [find $tstobjdir *_main.m]] {
# If we're only testing specific files and this isn't one
# of them, skip it.
if ![runtest_file_p $runtests $src] then {
continue
}
dg-runtest $src "" $DEFAULT_CFLAGS
}
} else {
warning "Could not execute objc.dg/gnu-encoding/struct-layout-encoding-1 generator"
}
} else {
warning "Could not compile objc.dg/gnu-encoding/struct-layout-encoding-1 generator"
}
# All done.
dg-finish
#include "struct-layout-1.h"
#define TX(n, type, attrs, fields, ops) \
type S##n { fields } attrs; \
void test##n (void) \
{ \
if (objc_sizeof_type (@encoding (type S##n)) != sizeof(type S##n)) \
fails ++; \
}
/* This includes all of the vector modes that are recognized by
c_common_type_for_mode. */
typedef int __attribute__((mode(QI))) qi;
typedef int __attribute__((mode(HI))) hi;
typedef int __attribute__((mode(SI))) si;
typedef int __attribute__((mode(DI))) di;
typedef float __attribute__((mode(SF))) sf;
typedef float __attribute__((mode(DF))) df;
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 5)
typedef qi __attribute__((vector_size (8))) v8qi;
typedef qi __attribute__((vector_size (16))) v16qi;
typedef hi __attribute__((vector_size (4))) v2hi;
typedef hi __attribute__((vector_size (8))) v4hi;
typedef hi __attribute__((vector_size (16))) v8hi;
typedef si __attribute__((vector_size (8))) v2si;
typedef si __attribute__((vector_size (16))) v4si;
typedef di __attribute__((vector_size (8))) v1di;
typedef di __attribute__((vector_size (16))) v2di;
typedef sf __attribute__((vector_size (8))) v2sf;
typedef sf __attribute__((vector_size (16))) v4sf;
typedef sf __attribute__((vector_size (64))) v16sf;
typedef df __attribute__((vector_size (16))) v2df;
#else
typedef int __attribute__((mode(V8QI))) v8qi;
typedef int __attribute__((mode(V16QI))) v16qi;
typedef int __attribute__((mode(V2HI))) v2hi;
typedef int __attribute__((mode(V4HI))) v4hi;
typedef int __attribute__((mode(V8HI))) v8hi;
typedef int __attribute__((mode(V2SI))) v2si;
typedef int __attribute__((mode(V4SI))) v4si;
typedef int __attribute__((mode(V1DI))) v1di;
typedef int __attribute__((mode(V2DI))) v2di;
typedef float __attribute__((mode(V2SF))) v2sf;
typedef float __attribute__((mode(V4SF))) v4sf;
typedef float __attribute__((mode(V16SF))) v16sf;
typedef float __attribute__((mode(V2DF))) v2df;
#endif
typedef union U8QI { v8qi v; qi a[8]; } u8qi;
typedef union U16QI { v16qi v; qi a[16]; } u16qi;
typedef union U2HI { v2hi v; hi a[2]; } u2hi;
typedef union U4HI { v4hi v; hi a[4]; } u4hi;
typedef union U8HI { v8hi v; hi a[8]; } u8hi;
typedef union U2SI { v2si v; si a[2]; } u2si;
typedef union U4SI { v4si v; si a[4]; } u4si;
typedef union U1DI { v1di v; di a[1]; } u1di;
typedef union U2DI { v2di v; di a[2]; } u2di;
typedef union U2SF { v2sf v; sf a[2]; } u2sf;
typedef union U4SF { v4sf v; sf a[4]; } u4sf;
typedef union U16SF { v16sf v; sf a[16]; } u16sf;
typedef union U2DF { v2df v; df a[2]; } u2df;
2005-12-12 Andrew Pinski <pinskia@physics.uc.edu>
* encoding.c (TYPE_FIELDS): Fix to skip over just _C_STRUCT_B and
the name.
(get_inner_array_type): Fix to skip over _C_ARY_B and size.
(rs6000_special_round_type_align): Update for the ABI fix.
(objc_layout_finish_structure): Correct the encoding which is passed to
ROUND_TYPE_ALIGN.
2005-12-11 Andrew Pinski <pinskia@physics.uc.edu>
PR libobjc/25347
......
......@@ -67,14 +67,24 @@ Boston, MA 02110-1301, USA. */
#define VECTOR_TYPE _C_VECTOR
#define TYPE_FIELDS(TYPE) objc_skip_typespec (TYPE)
#define TYPE_FIELDS(TYPE) ({const char *_field = (TYPE)+1; \
while (*_field != _C_STRUCT_E && *_field != _C_STRUCT_B \
&& *_field != _C_UNION_B && *_field++ != '=') \
/* do nothing */; \
_field;})
#define DECL_MODE(TYPE) *(TYPE)
#define TYPE_MODE(TYPE) *(TYPE)
#define DFmode _C_DBL
#define get_inner_array_type(TYPE) ((TYPE) + 1)
#define get_inner_array_type(TYPE) ({const char *_field = (TYPE); \
while (*_field == _C_ARY_B)\
{\
while (isdigit ((unsigned char)*++_field))\
;\
}\
_field;})
/* Some ports (eg ARM) allow the structure size boundary to be
selected at compile-time. We override the normal definition with
......@@ -103,10 +113,13 @@ static int __attribute__ ((__unused__)) not_target_flags = 0;
is only way around without really rewritting this file,
should look after the branch of 3.4 to fix this. */
#define rs6000_special_round_type_align(STRUCT, COMPUTED, SPECIFIED) \
((TYPE_FIELDS (STRUCT) != 0 \
&& DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode) \
({ const char *_fields = TYPE_FIELDS (STRUCT); \
((_fields != 0 \
&& TYPE_MODE (TREE_CODE (TREE_TYPE (_fields)) == ARRAY_TYPE \
? get_inner_array_type (_fields) \
: TREE_TYPE (_fields)) == DFmode) \
? MAX (MAX (COMPUTED, SPECIFIED), 64) \
: MAX (COMPUTED, SPECIFIED))
: MAX (COMPUTED, SPECIFIED));})
/*
return the size of an object specified by type
......@@ -901,9 +914,8 @@ void objc_layout_finish_structure (struct objc_struct_layout *layout,
/* Work out the alignment of the record as one expression and store
in the record type. Round it up to a multiple of the record's
alignment. */
#if defined (ROUND_TYPE_ALIGN) && ! defined (__sparc__)
layout->record_align = ROUND_TYPE_ALIGN (layout->original_type,
layout->record_align = ROUND_TYPE_ALIGN (layout->original_type-1,
1,
layout->record_align);
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment