disable fix for parsetest/fehler053.c for now (as it breaks more common use cases)
authorMatthias Braun <matze@braunis.de>
Mon, 6 Oct 2008 13:20:23 +0000 (13:20 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 6 Oct 2008 13:20:23 +0000 (13:20 +0000)
[r22530]

adt/array.c [deleted file]
ast2firm.c
parser.c

diff --git a/adt/array.c b/adt/array.c
deleted file mode 100644 (file)
index 0ab29f2..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief       Array --- dynamic & flexible arrays.
- * @author      Markus Armbruster
- * @version     $Id$
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
-#include "array.h"
-#include "xmalloc.h"
-
-/* Undefine the macros to get the functions instead, cf tmalloc.c.  */
-#undef xmalloc
-#undef xrealloc
-#undef xstrdup
-#undef xfree
-
-#ifndef MAX
-# define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif
-#ifndef MIN
-# define MIN(a,b) ((a) > (b) ? (b) : (a))
-#endif
-
-/**
- * An empty dynamic array descriptor.
- */
-_arr_descr arr_mt_descr
-#ifndef NDEBUG
-       = { ARR_D_MAGIC, 0, {0}, 0, {{{0}}} }
-#endif
-;
-
-/**
- * Creates a dynamic array on a obstack.
- *
- * @param obstack    An struct obstack * were the data will be allocated
- * @param nelts      The number of elements
- * @param elts_size  The size of the array elements.
- *
- * @return A pointer to the dynamic array (can be used as a pointer to the
- *         first element of this array).
- *
- * @remark Helper function, use NEW_ARR_D() instead.
- */
-void *
-_new_arr_d (struct obstack *obstack, int nelts, size_t elts_size)
-{
-  _arr_descr *new;
-
-  assert (obstack && (nelts >= 0));
-
-  new = obstack_alloc (obstack, _ARR_ELTS_OFFS+elts_size);
-  _ARR_SET_DBGINF (new, ARR_D_MAGIC, elts_size/nelts);
-  new->u.obstack = obstack;
-  new->nelts = nelts;
-  return new->v.elts;
-}
-
-/**
- * Creates a flexible array.
- *
- * @param nelts      The number of elements
- * @param elts_size  The size of the array elements.
- *
- * @return A pointer to the flexible array (can be used as a pointer to the
- *         first element of this array).
- *
- * @remark Helper function, use NEW_ARR_F() instead.
- */
-void *
-_new_arr_f (int nelts, size_t elts_size)
-{
-  _arr_descr *new;
-
-  assert (nelts >= 0);
-  new = xmalloc (_ARR_ELTS_OFFS+elts_size);
-  _ARR_SET_DBGINF (new, ARR_F_MAGIC, nelts ? elts_size/nelts : 0);
-  new->u.allocated = new->nelts = nelts;
-  return new->v.elts;
-}
-
-/**
- * Delete a flexible array.
- *
- * @param elts    The flexible array (pointer to the first element).
- *
- * @remark Helper function, use DEL_ARR_F() instead.
- */
-void
-_del_arr_f (void *elts)
-{
-  _arr_descr *dp = _ARR_DESCR (elts);
-
-  ARR_VRFY (elts);
-  assert (dp->magic == ARR_F_MAGIC);
-
-#ifndef NDEBUG
-  dp->magic = 0xdeadbeef;
-#endif
-  free (dp);
-}
-
-/**
- * Resize a flexible array, always reallocate data.
- *
- * @param elts       The flexible array (pointer to the first element).
- * @param nelts      The new number of elements.
- * @param elts_size  The size of the array elements.
- *
- * @return A resized flexible array, possibly other address than
- *         elts.
- *
- * @remark Helper function, use ARR_SETLEN() instead.
- */
-void *
-_arr_setlen (void *elts, int nelts, size_t elts_size)
-{
-  _arr_descr *dp = _ARR_DESCR (elts);
-
-  assert ((dp->magic == ARR_F_MAGIC) && (nelts >= 0));
-  ARR_VRFY (elts);
-  assert (!dp->eltsize || !nelts || (dp->eltsize == elts_size/nelts));
-
-  dp = xrealloc (dp, _ARR_ELTS_OFFS+elts_size);
-  dp->u.allocated = dp->nelts = nelts;
-
-  return dp->v.elts;
-}
-
-/**
- * Resize a flexible array, allocate more data if needed but do NOT
- * reduce.
- *
- * @param elts     The flexible array (pointer to the first element).
- * @param nelts    The new number of elements.
- * @param eltsize  The size of the array elements.
- *
- * @return A resized flexible array, possibly other address than
- *         elts.
- *
- * @remark Helper function, use ARR_RESIZE() instead.
- */
-void *
-_arr_resize (void *elts, int nelts, size_t eltsize)
-{
-  _arr_descr *dp = _ARR_DESCR (elts);
-  int n;
-
-  assert ((dp->magic == ARR_F_MAGIC) && (nelts >= 0));
-  ARR_VRFY (elts);
-  assert (dp->eltsize ? dp->eltsize == eltsize : (dp->eltsize = eltsize, 1));
-
-  /* @@@ lots of resizes for small nelts */
-  n = MAX (1, dp->u.allocated);
-  while (nelts > n) n <<= 1;
-  while (3*nelts < n) n >>= 1;
-  assert (n >= nelts);
-
-  if (n != dp->u.allocated) {
-    dp = xrealloc (dp, _ARR_ELTS_OFFS+eltsize*n);
-    dp->u.allocated = n;
-#if defined(DEBUG) && defined(HAVE_GNU_MALLOC)
-  } else {
-    tmalloc_tag = NULL;
-#endif
-  }
-  dp->nelts = nelts;
-
-  return dp->v.elts;
-}
-
-#ifdef DEBUG_libfirm
-/**
- * This function returns the length of a flexible array.
- * Do NOT use is in code, use ARR_LEN() macro!
- * This function is intended to be called from a debugger.
- */
-int array_len(void *arr) {
-  return ARR_LEN(arr);
-}
-
-/**
- * This function returns the array descriptor of a flexible array.
- * Do NOT use is in code!.
- * This function is intended to be called from a debugger.
- */
-_arr_descr *array_descr(void *arr) {
-  if (! arr)
-    return NULL;
-  return _ARR_DESCR(arr);
-}
-#endif /* DEBUG_libfirm */
index d1d7370..e3520bd 100644 (file)
@@ -1797,12 +1797,16 @@ static tarval *create_bitfield_mask(ir_mode *mode, int offset, int size)
 static void bitfield_store_to_firm(dbg_info *dbgi,
                ir_entity *entity, ir_node *addr, ir_node *value, bool set_volatile)
 {
-       ir_mode *mode = get_irn_mode(value);
+       ir_type *entity_type = get_entity_type(entity);
+       ir_type *base_type   = get_primitive_base_type(entity_type);
+       assert(base_type != NULL);
+       ir_mode *mode        = get_type_mode(base_type);
+
+       value = create_conv(dbgi, value, mode);
 
        /* kill upper bits of value and shift to right position */
-       int        bitoffset    = get_entity_offset_bits_remainder(entity);
-       ir_type   *entity_type  = get_entity_type(entity);
-       int        bitsize      = get_mode_size_bits(get_type_mode(entity_type));
+       int      bitoffset    = get_entity_offset_bits_remainder(entity);
+       int      bitsize      = get_mode_size_bits(get_type_mode(entity_type));
 
        tarval  *mask            = create_bitfield_mask(mode, 0, bitsize);
        ir_node *mask_node       = new_d_Const(dbgi, mode, mask);
@@ -3715,20 +3719,6 @@ static void create_dynamic_null_initializer(ir_type *type, dbg_info *dbgi,
        }
 }
 
-static bool needs_bitfield_store(ir_entity *entity)
-{
-       int bitoffset = get_entity_offset_bits_remainder(entity);
-       if (bitoffset > 0)
-               return true;
-
-       ir_type *entity_type = get_entity_type(entity);
-       int      bitsize     = get_mode_size_bits(get_type_mode(entity_type));
-       if (!is_po2(bitsize) || bitsize < 8)
-               return true;
-
-       return false;
-}
-
 static void create_dynamic_initializer_sub(ir_initializer_t *initializer,
                ir_entity *entity, ir_type *type, dbg_info *dbgi, ir_node *base_addr)
 {
@@ -3738,10 +3728,12 @@ static void create_dynamic_initializer_sub(ir_initializer_t *initializer,
                return;
        }
        case IR_INITIALIZER_CONST: {
-               ir_node *node = get_initializer_const_value(initializer);
-               ir_mode *mode = get_irn_mode(node);
+               ir_node *node     = get_initializer_const_value(initializer);
+               ir_mode *mode     = get_irn_mode(node);
+               ir_type *ent_type = get_entity_type(entity);
 
-               if (needs_bitfield_store(entity)) {
+               /* is it a bitfield type? */
+               if (get_primitive_base_type(ent_type) != NULL) {
                        bitfield_store_to_firm(dbgi, entity, base_addr, node, false);
                        return;
                }
@@ -3754,11 +3746,13 @@ static void create_dynamic_initializer_sub(ir_initializer_t *initializer,
                return;
        }
        case IR_INITIALIZER_TARVAL: {
-               tarval  *tv   = get_initializer_tarval_value(initializer);
-               ir_mode *mode = get_tarval_mode(tv);
-               ir_node *cnst = new_d_Const(dbgi, mode, tv);
+               tarval  *tv       = get_initializer_tarval_value(initializer);
+               ir_mode *mode     = get_tarval_mode(tv);
+               ir_node *cnst     = new_d_Const(dbgi, mode, tv);
+               ir_type *ent_type = get_entity_type(entity);
 
-               if (needs_bitfield_store(entity)) {
+               /* is it a bitfield type? */
+               if (get_primitive_base_type(ent_type) != NULL) {
                        bitfield_store_to_firm(dbgi, entity, base_addr, cnst, false);
                        return;
                }
index 1c28374..497ecd6 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1991,9 +1991,11 @@ static initializer_t *initializer_from_expression(type_t *orig_type,
                            &expression->base.source_position);
 
        initializer_t *const result = allocate_initializer_zero(INITIALIZER_VALUE);
+#if 0
        if (type->kind == TYPE_BITFIELD) {
                type = type->bitfield.base_type;
        }
+#endif
        result->value.value = create_implicit_cast(expression, type);
 
        return result;