+2003-12-16 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/9043
+ C++ ABI change: Mangling array indices in templates.
+ * decl.c (compute_array_index_type): Reorganize for earlier
+ template errors. Use value_dependent_expression_p for abi-2.
+ * mangle.c (write_array_type): Check broken mangling for
+ expression indices on abi-1
+
2003-12-16 Mark Mitchell <mark@codesourcery.com>
PR c++/13275
(cp_parser_unary_expression): Allow the use of "&" in a constant
expression if implementing offsetof.
-2003-12-16 Giovanni Bajo <giovannibajo@gcc.gnu.org>\r
-\r
- PR c++/2294\r
+2003-12-16 Giovanni Bajo <giovannibajo@gcc.gnu.org>
+
+ PR c++/2294
* name-lookup.c (push_overloaded_decl): always construct an OVERLOAD\r
- if the declaration comes from an using declaration.\r
+ if the declaration comes from an using declaration.
2003-12-16 Giovanni Bajo <giovannibajo@gcc.gnu.org>
* semantics.c (finish_id_expression): Refactor the code to handle
template parameters, and emit a more informative error message
when they are used within an integral constant expression.
-\r
+
2003-12-16 Nathan Sidwell <nathan@codesourcery.com>
PR c++/13387
* parse.y (member_init): Just pass in the type.
* init.c (expand_member_init): Handle getting a type.
-2000-07-04 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+2000-07-04 Martin v. Löwis <loewis@informatik.hu-berlin.de>
Jason Merrill <jason@redhat.com>
* decl.c (finish_function): Warn if a function has no return
* decl.c (pushdecl): Don't set DECL_CONTEXT from current_namespace.
(push_namespace): Set DECL_CONTEXT for a new NAMESPACE_DECL.
-2000-06-24 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+2000-06-24 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* parse.y (complex_direct_notype_declarator): Support global_scope.
* Makefile.in: Adjust conflict count.
* semantics.c (finish_member_declaration): Don't mark members of
classes declared in an extern "C" region as extern "C".
-2000-05-22 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+2000-05-22 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* decl2.c (qualified_lookup_using_namespace): Look through
namespace aliases.
* ir.texi: Correct typo.
-2000-04-25 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+2000-04-25 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* decl.c (grokdeclarator): Reject VLAs as members.
(interface_only): Don't declare.
(interface_unknown): Likewise.
-2000-04-11 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+2000-04-11 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* tree.h (HAVE_TEMPLATES): Remove definition.
* lang-options.h (-fthis-is-variable): Remove documentation.
(__pointer_to_member_type_info::__do_catch): Remove.
(__pointer_to_member_type_info::__pointer_catch): Implement.
-2000-04-10 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+2000-04-10 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* lex.c (init_parse): Remove traces of classof and headof.
* decl2.c (flag_operator_names): Default to 1.
* init.c (build_offset_ref): Handle the case of a templated member
function.
-2000-03-19 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+2000-03-19 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* except.c (expand_exception_blocks): Clear catch_clauses_last.
(layout_class_type): Implement new ABI handling of bitfields
longer than their types.
-2000-03-18 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+2000-03-18 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* parse.y (extdefs): Call ggc_collect.
* parse.c: Regenerated.
* decl.c (decls_match): Remove obsolete static member nadgering.
-2000-02-21 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+2000-02-21 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* decl.c (grokdeclarator): Change ANSI to ISO.
* lex.c (consume_string, readescape, do_identifier): Likewise.
* optimize.c (copy_body_r): Clear the operand three of a
TARGET_EXPR when copying it.
-2000-01-14 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+2000-01-14 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* method.c (build_decl_overload_real): Check whether we are in ::
before returning __builtin_new/delete.
(fixup_vtable_deltas1): Likewise.
(finish_struct_1): Likewise.
-2000-01-01 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+2000-01-01 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* call.c (build_new_method_call): Also check destructors.
tree
compute_array_index_type (tree name, tree size)
{
+ tree type = TREE_TYPE (size);
tree itype;
- /* If this involves a template parameter, it will be a constant at
- instantiation time, but we don't know what the value is yet.
- Even if no template parameters are involved, we may an expression
- that is not a constant; we don't even simplify `1 + 2' when
- processing a template. */
- if (processing_template_decl)
+ /* The array bound must be an integer type. */
+ if (!dependent_type_p (type) && !INTEGRAL_TYPE_P (type))
{
- /* Resolve a qualified reference to an enumerator or static
- const data member of ours. */
- if (TREE_CODE (size) == SCOPE_REF
- && TREE_OPERAND (size, 0) == current_class_type)
- {
- tree t = lookup_field (current_class_type,
- TREE_OPERAND (size, 1), 0, false);
- if (t)
- size = t;
- }
-
- return build_index_type (build_min (MINUS_EXPR, sizetype,
- size, integer_one_node));
+ if (name)
+ error ("size of array `%D' has non-integral type `%T'", name, type);
+ else
+ error ("size of array has non-integral type `%T'", type);
+ size = integer_one_node;
+ type = TREE_TYPE (size);
}
+ if (abi_version_at_least (2)
+ /* We should only handle value dependent expressions specially. */
+ ? value_dependent_expression_p (size)
+ /* But for abi-1, we handled all instances in templates. This
+ effects the manglings produced. */
+ : processing_template_decl)
+ return build_index_type (build_min (MINUS_EXPR, sizetype,
+ size, integer_one_node));
+
/* The size might be the result of a cast. */
STRIP_TYPE_NOPS (size);
/* It might be a const variable or enumeration constant. */
size = decl_constant_value (size);
- /* The array bound must be an integer type. */
- if (TREE_CODE (TREE_TYPE (size)) != INTEGER_TYPE
- && TREE_CODE (TREE_TYPE (size)) != ENUMERAL_TYPE
- && TREE_CODE (TREE_TYPE (size)) != BOOLEAN_TYPE)
- {
- if (name)
- error ("size of array `%D' has non-integer type", name);
- else
- error ("size of array has non-integer type");
- size = integer_one_node;
- }
-
/* Normally, the array-bound will be a constant. */
if (TREE_CODE (size) == INTEGER_CST)
{
else
error ("size of array is not an integral constant-expression");
}
-
- /* Compute the index of the largest element in the array. It is
- one less than the number of elements in the array. */
- itype
- = fold (cp_build_binary_op (MINUS_EXPR,
- cp_convert (ssizetype, size),
- cp_convert (ssizetype,
- integer_one_node)));
-
- /* Check for variable-sized arrays. We allow such things as an
- extension, even though they are not allowed in ANSI/ISO C++. */
- if (!TREE_CONSTANT (itype))
+ else if (pedantic)
{
- if (pedantic)
- {
- if (name)
- pedwarn ("ISO C++ forbids variable-size array `%D'",
- name);
- else
- pedwarn ("ISO C++ forbids variable-size array");
- }
-
- /* Create a variable-sized array index type. */
- itype = variable_size (itype);
+ if (name)
+ pedwarn ("ISO C++ forbids variable-size array `%D'", name);
+ else
+ pedwarn ("ISO C++ forbids variable-size array");
}
- /* Make sure that there was no overflow when creating to a signed
- index type. (For example, on a 32-bit machine, an array with
- size 2^32 - 1 is too big.) */
- else if (TREE_OVERFLOW (itype))
+
+ if (processing_template_decl && !TREE_CONSTANT (size))
+ /* A variable sized array. */
+ itype = build_min (MINUS_EXPR, sizetype, size, integer_one_node);
+ else
{
- error ("overflow in array dimension");
- TREE_OVERFLOW (itype) = 0;
+ /* Compute the index of the largest element in the array. It is
+ one less than the number of elements in the array. */
+ itype
+ = fold (cp_build_binary_op (MINUS_EXPR,
+ cp_convert (ssizetype, size),
+ cp_convert (ssizetype, integer_one_node)));
+ if (!TREE_CONSTANT (itype))
+ /* A variable sized array. */
+ itype = variable_size (itype);
+ /* Make sure that there was no overflow when creating to a signed
+ index type. (For example, on a 32-bit machine, an array with
+ size 2^32 - 1 is too big.) */
+ else if (TREE_OVERFLOW (itype))
+ {
+ error ("overflow in array dimension");
+ TREE_OVERFLOW (itype) = 0;
+ }
}
/* Create and return the appropriate index type. */
write_unsigned_number (tree_low_cst (max, 1));
}
else
- write_expression (TREE_OPERAND (max, 0));
+ {
+ max = TREE_OPERAND (max, 0);
+ if (!abi_version_at_least (2))
+ {
+ /* value_dependent_expression_p presumes nothing is
+ dependent when PROCESSING_TEMPLATE_DECL is zero. */
+ ++processing_template_decl;
+ if (!value_dependent_expression_p (max))
+ G.need_abi_warning = 1;
+ --processing_template_decl;
+ }
+ write_expression (max);
+ }
+
}
write_char ('_');
write_type (TREE_TYPE (type));
+2003-12-16 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/9043
+ * g++.dg/abi/mangle20-1.C: New test.
+ * g++.dg/abi/mangle20-2.C: New test.
+
2003-12-16 Mark Mitchell <mark@codesourcery.com>
PR c++/13275
--- /dev/null
+// { dg-do compile }
+// { dg-options "-fabi-version=2" }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 15 Dec 2003 <nathan@codesourcery.com>
+
+// PR 9043
+// mangled array types in templates
+
+template <int I> void f(int (*)[2]) {}
+template <int I> void g(int (*)[I+2]) {}
+
+static const int I=1;
+static const int J=2;
+
+template void f<1>(int (*)[2]);
+// { dg-final { scan-assembler "\n_Z1fILi1EEvPA2_i:" } }
+template void g<1>(int (*)[3]);
+// { dg-final { scan-assembler "\n_Z1gILi1EEvPAplT_Li2E_i:" } }
--- /dev/null
+// { dg-do compile }
+// { dg-options "-fabi-version=1 -Wabi" }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 15 Dec 2003 <nathan@codesourcery.com>
+
+// PR 9043
+// mangled array types in templates
+
+template <int I> void f(int (*)[2]) {}
+template <int I> void g(int (*)[I+2]) {}
+
+template void f<1>(int (*)[2]); // { dg-warning "mangled name" }
+// { dg-final { scan-assembler "\n_Z1fILi1EEvPALi2E_i:" } }
+template void g<1>(int (*)[3]);
+// { dg-final { scan-assembler "\n_Z1gILi1EEvPAplT_Li2E_i:" } }