1994-02-24 02:02:37 +01:00
|
|
|
|
/* Language-level data type conversion for GNU C++.
|
2000-02-26 21:16:12 +01:00
|
|
|
|
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
2006-01-18 03:13:02 +01:00
|
|
|
|
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
1994-02-24 02:02:37 +01:00
|
|
|
|
Hacked by Michael Tiemann (tiemann@cygnus.com)
|
|
|
|
|
|
call.c, [...]: Replace "GNU CC" with "GCC" in the copyright header.
* call.c, class.c, cp-lang.c, cp-tree.h, cvt.c, dump.c, error.c,
except.c, expr.c friend.c, g++spec.c, init.c, lang-options.h,
lang-specs.h, lex.c, mangle.c, method.c, optimize.c, parser.c,
pt.c, ptree.c, repo.c, rtti.c, search.c, semantics.c, tree.c,
typeck.c, typeck2.c: Replace "GNU CC" with "GCC" in the
copyright header.
* lex.h: parse.y is dead, so don't mention it. Also replace the
copyright header with the default GNU copyright header.
From-SVN: r60738
2003-01-01 12:58:58 +01:00
|
|
|
|
This file is part of GCC.
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
call.c, [...]: Replace "GNU CC" with "GCC" in the copyright header.
* call.c, class.c, cp-lang.c, cp-tree.h, cvt.c, dump.c, error.c,
except.c, expr.c friend.c, g++spec.c, init.c, lang-options.h,
lang-specs.h, lex.c, mangle.c, method.c, optimize.c, parser.c,
pt.c, ptree.c, repo.c, rtti.c, search.c, semantics.c, tree.c,
typeck.c, typeck2.c: Replace "GNU CC" with "GCC" in the
copyright header.
* lex.h: parse.y is dead, so don't mention it. Also replace the
copyright header with the default GNU copyright header.
From-SVN: r60738
2003-01-01 12:58:58 +01:00
|
|
|
|
GCC is free software; you can redistribute it and/or modify
|
1994-02-24 02:02:37 +01:00
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
call.c, [...]: Replace "GNU CC" with "GCC" in the copyright header.
* call.c, class.c, cp-lang.c, cp-tree.h, cvt.c, dump.c, error.c,
except.c, expr.c friend.c, g++spec.c, init.c, lang-options.h,
lang-specs.h, lex.c, mangle.c, method.c, optimize.c, parser.c,
pt.c, ptree.c, repo.c, rtti.c, search.c, semantics.c, tree.c,
typeck.c, typeck2.c: Replace "GNU CC" with "GCC" in the
copyright header.
* lex.h: parse.y is dead, so don't mention it. Also replace the
copyright header with the default GNU copyright header.
From-SVN: r60738
2003-01-01 12:58:58 +01:00
|
|
|
|
GCC is distributed in the hope that it will be useful,
|
1994-02-24 02:02:37 +01:00
|
|
|
|
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
|
call.c, [...]: Replace "GNU CC" with "GCC" in the copyright header.
* call.c, class.c, cp-lang.c, cp-tree.h, cvt.c, dump.c, error.c,
except.c, expr.c friend.c, g++spec.c, init.c, lang-options.h,
lang-specs.h, lex.c, mangle.c, method.c, optimize.c, parser.c,
pt.c, ptree.c, repo.c, rtti.c, search.c, semantics.c, tree.c,
typeck.c, typeck2.c: Replace "GNU CC" with "GCC" in the
copyright header.
* lex.h: parse.y is dead, so don't mention it. Also replace the
copyright header with the default GNU copyright header.
From-SVN: r60738
2003-01-01 12:58:58 +01:00
|
|
|
|
along with GCC; see the file COPYING. If not, write to
|
2005-06-25 02:59:41 +02:00
|
|
|
|
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA. */
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
|
2003-01-04 00:13:09 +01:00
|
|
|
|
/* This file contains the functions for converting C++ expressions
|
1994-02-24 02:02:37 +01:00
|
|
|
|
to different data types. The only entry point is `convert'.
|
|
|
|
|
Every language front end must have a `convert' function
|
|
|
|
|
but what kind of conversions it does will depend on the language. */
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
call.c: Include system.h.
* call.c: Include system.h. Remove includes, declarations and
defines provided by system.h.
* class.c, cvt.c, decl.c, decl2.c, errfn.c error.c: Likewise.
* except.c, expr.c friend.c, g++spec.c, init.c, input.c: Likewise.
* lex.c, parse.y, pt.c, ptree.c repo.c rtti.c, search.c: Likewise.
* semantics.c, sig.c, spew.c, tree.c, typeck.c: Likewise.
* typeck2.c, xref.c: Likewise.
* Makefile.in: Dependencies updated as appropriate.
* Make-lang.in: Likewise.
system.h cutover from the cp subdir
From-SVN: r18917
1998-03-31 15:25:46 +02:00
|
|
|
|
#include "system.h"
|
2002-12-16 19:23:00 +01:00
|
|
|
|
#include "coretypes.h"
|
|
|
|
|
#include "tm.h"
|
1994-02-24 02:02:37 +01:00
|
|
|
|
#include "tree.h"
|
|
|
|
|
#include "flags.h"
|
|
|
|
|
#include "cp-tree.h"
|
|
|
|
|
#include "convert.h"
|
1998-12-22 13:18:17 +01:00
|
|
|
|
#include "toplev.h"
|
1999-01-18 13:49:20 +01:00
|
|
|
|
#include "decl.h"
|
target.h (invalid_conversion, [...]): New hooks.
* target.h (invalid_conversion, invalid_unary_op,
invalid_binary_op): New hooks.
* target-def.h (TARGET_INVALID_CONVERSION,
TARGET_INVALID_UNARY_OP, TARGET_INVALID_BINARY_OP,
TARGET_INITIALIZER): Likewise.
* hooks.h (hook_constcharptr_tree_tree_null,
hook_constcharptr_int_tree_null,
hook_constcharptr_int_tree_tree_null): New.
* hooks.c (hook_constcharptr_tree_tree_null,
hook_constcharptr_int_tree_null,
hook_constcharptr_int_tree_tree_null): Likewise.
* gcc/doc/tm.texi (TARGET_INVALID_CONVERSION,
TARGET_INVALID_UNARY_OP, TARGET_INVALID_BINARY_OP): Document.
* c-convert.c (convert): Use invalid_conversion hook.
* c-typeck.c (build_unary_op): Use invalid_unary_op hook.
(build_binary_op): Use invalid_binary_op hook.
* config/ia64/ia64-modes.def: Define RFmode.
* config/ia64/ia64-protos.h (spill_xfmode_operand): Remove.
(ia64_expand_movxf_movrf): New.
* config/ia64/ia64.md (movxf): Move code to
ia64_expand_movxf_movrf.
(movrf, movrf_internal): New.
* ia64.c (ia64_invalid_conversion, ia64_invalid_unary_op,
ia64_invalid_binary_op, TARGET_INVALID_CONVERSION,
TARGET_INVALID_UNARY_OP, TARGET_INVALID_BINARY_OP): New.
(spill_xfmode_operand): Rename to spill_xfmode_rfmode_operand.
Add mode parameter. Make static.
(ia64_expand_movxf_movrf): New, moved from ia64.md. Handle RFmode
as well as XFmode.
(ia64_function_arg, ia64_function_value, ia64_register_move_cost,
ia64_scalar_mode_supported_p): Handle RFmode as well as XFmode.
(ia64_init_builtins): Set up __fpreg as RFmode.
(ia64_mangle_fundamental_type): Mangle __fpreg as u7__fpreg.
cp:
* cvt.c (ocp_convert): Use invalid_conversion hook.
* typeck.c (build_binary_op): Use invalid_binary_op hook.
(build_unary_op): Use invalid_unary_op hook.
testsuite:
* g++.dg/ext/fpreg1.C, gcc.target/ia64/fpreg-1.c,
gcc.target/ia64/fpreg-2.c: New tests.
From-SVN: r101391
2005-06-28 23:55:24 +02:00
|
|
|
|
#include "target.h"
|
1996-07-11 03:13:25 +02:00
|
|
|
|
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
static tree cp_convert_to_pointer (tree, tree, bool);
|
|
|
|
|
static tree convert_to_pointer_force (tree, tree);
|
2006-02-13 23:37:02 +01:00
|
|
|
|
static tree build_type_conversion (tree, tree);
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
static tree build_up_reference (tree, tree, int, tree);
|
|
|
|
|
static void warn_ref_binding (tree, tree, tree);
|
[multiple changes]
Wed Aug 20 17:25:08 1997 Jason Merrill <jason@yorick.cygnus.com>
* call.c (is_subseq): Don't try to be clever.
Wed Aug 20 03:13:36 1997 H.J. Lu (hjl@gnu.ai.mit.edu)
* parse.y, pt.c: Include "except.h".
* call.c, class.c, class.h, cp-tree.h, cvt.c, decl.c, decl2.c,
error.c, except.c, expr.c, friend.c, g++spec.c, init.c, input.c,
lex.c, lex.h, method.c, parse.y, pt.c, repo.c, rtti.c, search.c,
sig.c, spew.c, tree.c, typeck.c, typeck2.c, xref.c: Finish
prototyping.
Wed Aug 20 01:34:40 1997 Jason Merrill <jason@yorick.cygnus.com>
* decl2.c (mark_vtable_entries): Instead of replacing pure
virtuals with a reference to __pure_virtual, copy the decl and
change the RTL.
From-SVN: r14868
1997-08-21 02:50:39 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
/* Change of width--truncation and extension of integers or reals--
|
|
|
|
|
is represented with NOP_EXPR. Proper functioning of many things
|
|
|
|
|
assumes that no other conversions can be NOP_EXPRs.
|
|
|
|
|
|
|
|
|
|
Conversion between integer and pointer is represented with CONVERT_EXPR.
|
|
|
|
|
Converting integer to real uses FLOAT_EXPR
|
|
|
|
|
and real to integer uses FIX_TRUNC_EXPR.
|
|
|
|
|
|
|
|
|
|
Here is a list of all the functions that assume that widening and
|
|
|
|
|
narrowing is always done with a NOP_EXPR:
|
|
|
|
|
In convert.c, convert_to_integer.
|
|
|
|
|
In c-typeck.c, build_binary_op_nodefault (boolean ops),
|
2005-06-15 02:41:35 +02:00
|
|
|
|
and c_common_truthvalue_conversion.
|
1994-02-24 02:02:37 +01:00
|
|
|
|
In expr.c: expand_expr, for operands of a MULT_EXPR.
|
|
|
|
|
In fold-const.c: fold.
|
|
|
|
|
In tree.c: get_narrower and get_unwidened.
|
|
|
|
|
|
|
|
|
|
C++: in multiple-inheritance, converting between pointers may involve
|
|
|
|
|
adjusting them by a delta stored within the class definition. */
|
|
|
|
|
|
|
|
|
|
/* Subroutines of `convert'. */
|
|
|
|
|
|
|
|
|
|
/* if converting pointer to pointer
|
|
|
|
|
if dealing with classes, check for derived->base or vice versa
|
|
|
|
|
else if dealing with method pointers, delegate
|
|
|
|
|
else convert blindly
|
|
|
|
|
else if converting class, pass off to build_type_conversion
|
2000-11-27 11:55:32 +01:00
|
|
|
|
else try C-style pointer conversion. If FORCE is true then allow
|
|
|
|
|
conversions via virtual bases (these are permitted by reinterpret_cast,
|
|
|
|
|
but not static_cast). */
|
1996-07-11 03:13:25 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
static tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
cp_convert_to_pointer (tree type, tree expr, bool force)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2003-12-20 00:28:11 +01:00
|
|
|
|
tree intype = TREE_TYPE (expr);
|
|
|
|
|
enum tree_code form;
|
1998-02-19 11:05:22 +01:00
|
|
|
|
tree rval;
|
2004-09-23 22:04:21 +02:00
|
|
|
|
if (intype == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
1995-03-29 22:32:43 +02:00
|
|
|
|
|
1996-07-11 03:13:25 +02:00
|
|
|
|
if (IS_AGGR_TYPE (intype))
|
|
|
|
|
{
|
|
|
|
|
intype = complete_type (intype);
|
tree.h (COMPLETE_TYPE_P): New macro.
gcc
* tree.h (COMPLETE_TYPE_P): New macro.
(COMPLETE_OR_VOID_TYPE_P): New macro.
(COMPLETE_OR_UNBOUND_ARRAY_TYPE_P): New macro.
* stor-layout.c (layout_type, case VOID_TYPE): Don't set TYPE_SIZE.
* c-aux-info.c (gen_type): Use them.
* c-common.c (c_expand_expr_stmt): Likewise.
* c-decl.c (poplevel, pushdecl, start_decl, finish_decl,
grokdeclarator, grokparms, finish_struct, start_function,
store_parm_decls, combine_parm_decls): Likewise.
* c-parse.y (cast_expr): Likewise.
* c-typeck.c (require_complete_type, c_sizeof, c_sizeof_nowarn,
c_size_in_bytes, c_alignof, build_component_ref,
build_indirect_ref, build_array_ref, convert_arguments,
build_binary_op, pointer_diff, build_unary_op, digest_init: Likewise.
* calls.c (initialize_argument_information): Likewise.
* convert.c (convert_to_integer): Likewise.
* dbxout.c (dbxout_typedefs, dbxout_type, dbxout_symbol): Likewise.
* dwarfout.c (location_or_const_value_attribute,
output_enumeration_type_die, output_structure_type_die,
output_union_type_die, output_type): Likewise.
* expr.c (safe_from_p, expand_expr): Likewise.
* function.c (assign_parms): Likewise.
* sdbout.c (sdbout_symbol, sdbout_one_type): Likewise.
* tree.c (build_array_type, build_function_type,
build_method_type, build_offset_type, build_complex_type): Likewise.
* c-parse.c, c-parse.h: Regenerated.
gcc/cp
* typeck.c (require_complete_type, complete_type,
complete_type_or_else, c_sizeof, c_sizeof_nowarn,
build_array_ref, convert_arguments, pointer_diff,
build_x_unary_op, build_unary_op, build_c_cast,
build_modify_expr): Use COMPLETE_TYPE_P etc.
* call.c (is_complete, convert_like_real,
build_new_method_call): Likewise.
* class.c (build_vbase_pointer_fields, check_bases,
build_base_field, finish_struct_1, pushclass): Likewise.
* cvt.c (cp_convert_to_pointer, convert_to_void): Likewise.
* decl.c (maybe_process_template_type_declaration, pushtag,
pushdecl, redeclaration_error_message, start_decl, start_decl_1,
layout_var_decl, check_initializer, cp_finish_decl,
grokdeclarator, require_complete_types_for_parms,
grok_op_properties, xref_tag, xref_basetypes,
check_function_type): Likewise.
* decl2.c (check_classfn, reparse_absdcl_as_casts): Likewise.
* friend.c (do_friend): Likewise.
* init.c (build_offset_ref): Likewise.
* parse.y (structsp): Likewise.
* pt.c (maybe_process_partial_specialization,
tsubst_friend_function, instantiate_class_template, tsubst,
do_type_instantiation, instantiate_pending_templates): Likewise.
* repo.c (repo_get_id): Likewise.
* rtti.c (build_typeid, get_typeid, build_dynamic_cast_1,
synthesize_tinfo_var, emit_support_tinfos): Likewise.
* search.c (lookup_fnfields_1, lookup_conversions): Likewise.
* semantics.c (begin_class_definition): Likewise.
* tree.c (build_cplus_method_type): Likewise.
* typeck2.c (digest_init, build_functional_cast,
add_exception_specifier): Likewise.
* parse.h, parse.c: Regenerated.
From-SVN: r32671
2000-03-21 19:10:48 +01:00
|
|
|
|
if (!COMPLETE_TYPE_P (intype))
|
1996-07-11 03:13:25 +02:00
|
|
|
|
{
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("can't convert from incomplete type %qT to %qT",
|
2005-06-15 02:41:35 +02:00
|
|
|
|
intype, type);
|
1996-07-11 03:13:25 +02:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 22:55:25 +01:00
|
|
|
|
rval = build_type_conversion (type, expr);
|
1996-07-11 03:13:25 +02:00
|
|
|
|
if (rval)
|
|
|
|
|
{
|
|
|
|
|
if (rval == error_mark_node)
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("conversion of %qE from %qT to %qT is ambiguous",
|
2005-06-15 02:41:35 +02:00
|
|
|
|
expr, intype, type);
|
1996-07-11 03:13:25 +02:00
|
|
|
|
return rval;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1996-12-18 02:44:21 +01:00
|
|
|
|
/* Handle anachronistic conversions from (::*)() to cv void* or (*)(). */
|
1996-11-12 20:49:48 +01:00
|
|
|
|
if (TREE_CODE (type) == POINTER_TYPE
|
|
|
|
|
&& (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
|
2000-06-20 17:42:55 +02:00
|
|
|
|
|| VOID_TYPE_P (TREE_TYPE (type))))
|
1996-11-12 20:49:48 +01:00
|
|
|
|
{
|
2004-10-20 01:24:20 +02:00
|
|
|
|
if (TYPE_PTRMEMFUNC_P (intype)
|
|
|
|
|
|| TREE_CODE (intype) == METHOD_TYPE)
|
|
|
|
|
return convert_member_func_to_ptr (type, expr);
|
2003-07-04 07:05:19 +02:00
|
|
|
|
if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)
|
|
|
|
|
return build_nop (type, expr);
|
1996-11-12 20:49:48 +01:00
|
|
|
|
intype = TREE_TYPE (expr);
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-09 19:27:37 +02:00
|
|
|
|
if (expr == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
|
1995-03-29 22:32:43 +02:00
|
|
|
|
form = TREE_CODE (intype);
|
|
|
|
|
|
1998-12-14 16:35:40 +01:00
|
|
|
|
if (POINTER_TYPE_P (intype))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
|
|
|
|
intype = TYPE_MAIN_VARIANT (intype);
|
|
|
|
|
|
|
|
|
|
if (TYPE_MAIN_VARIANT (type) != intype
|
1998-12-14 16:35:40 +01:00
|
|
|
|
&& TREE_CODE (type) == POINTER_TYPE
|
1994-02-24 02:02:37 +01:00
|
|
|
|
&& TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE
|
1996-04-19 02:48:03 +02:00
|
|
|
|
&& IS_AGGR_TYPE (TREE_TYPE (type))
|
|
|
|
|
&& IS_AGGR_TYPE (TREE_TYPE (intype))
|
2001-11-25 14:21:45 +01:00
|
|
|
|
&& TREE_CODE (TREE_TYPE (intype)) == RECORD_TYPE)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
|
|
|
|
enum tree_code code = PLUS_EXPR;
|
2001-11-25 14:21:45 +01:00
|
|
|
|
tree binfo;
|
2003-03-03 22:55:25 +01:00
|
|
|
|
tree intype_class;
|
|
|
|
|
tree type_class;
|
|
|
|
|
bool same_p;
|
2001-11-25 14:21:45 +01:00
|
|
|
|
|
2003-03-03 22:55:25 +01:00
|
|
|
|
intype_class = TREE_TYPE (intype);
|
|
|
|
|
type_class = TREE_TYPE (type);
|
|
|
|
|
|
2005-06-14 22:01:59 +02:00
|
|
|
|
same_p = same_type_p (TYPE_MAIN_VARIANT (intype_class),
|
2003-03-03 22:55:25 +01:00
|
|
|
|
TYPE_MAIN_VARIANT (type_class));
|
|
|
|
|
binfo = NULL_TREE;
|
2002-09-13 02:22:59 +02:00
|
|
|
|
/* Try derived to base conversion. */
|
2003-03-03 22:55:25 +01:00
|
|
|
|
if (!same_p)
|
|
|
|
|
binfo = lookup_base (intype_class, type_class, ba_check, NULL);
|
|
|
|
|
if (!same_p && !binfo)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2002-09-13 02:22:59 +02:00
|
|
|
|
/* Try base to derived conversion. */
|
2003-03-03 22:55:25 +01:00
|
|
|
|
binfo = lookup_base (type_class, intype_class, ba_check, NULL);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
code = MINUS_EXPR;
|
|
|
|
|
}
|
2001-11-25 14:21:45 +01:00
|
|
|
|
if (binfo == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
2003-03-03 22:55:25 +01:00
|
|
|
|
if (binfo || same_p)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2003-03-03 22:55:25 +01:00
|
|
|
|
if (binfo)
|
|
|
|
|
expr = build_base_path (code, expr, binfo, 0);
|
2002-09-13 02:22:59 +02:00
|
|
|
|
/* Add any qualifier conversions. */
|
2003-03-03 22:55:25 +01:00
|
|
|
|
return build_nop (type, expr);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-23 01:30:22 +02:00
|
|
|
|
if (TYPE_PTRMEMFUNC_P (type))
|
1995-03-23 01:44:31 +01:00
|
|
|
|
{
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("cannot convert %qE from type %qT to type %qT",
|
2005-06-15 02:41:35 +02:00
|
|
|
|
expr, intype, type);
|
2003-07-23 01:30:22 +02:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
1999-05-22 03:30:11 +02:00
|
|
|
|
|
2003-07-23 01:30:22 +02:00
|
|
|
|
return build_nop (type, expr);
|
|
|
|
|
}
|
|
|
|
|
else if (TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))
|
|
|
|
|
{
|
2005-06-14 22:01:59 +02:00
|
|
|
|
tree b1;
|
2003-07-23 01:30:22 +02:00
|
|
|
|
tree b2;
|
|
|
|
|
tree binfo;
|
|
|
|
|
enum tree_code code = PLUS_EXPR;
|
|
|
|
|
base_kind bk;
|
|
|
|
|
|
|
|
|
|
b1 = TYPE_PTRMEM_CLASS_TYPE (type);
|
|
|
|
|
b2 = TYPE_PTRMEM_CLASS_TYPE (intype);
|
|
|
|
|
binfo = lookup_base (b1, b2, ba_check, &bk);
|
|
|
|
|
if (!binfo)
|
|
|
|
|
{
|
|
|
|
|
binfo = lookup_base (b2, b1, ba_check, &bk);
|
|
|
|
|
code = MINUS_EXPR;
|
|
|
|
|
}
|
|
|
|
|
if (binfo == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
1999-05-22 03:30:11 +02:00
|
|
|
|
|
2003-07-23 01:30:22 +02:00
|
|
|
|
if (bk == bk_via_virtual)
|
|
|
|
|
{
|
|
|
|
|
if (force)
|
diagnostic.c (warning): Accept parameter to classify warning option.
* diagnostic.c (warning): Accept parameter to classify warning option.
(warning0): New, for when a pointer to an error() like function is needed.
* errors.c (warning): Likewise.
* errors.h (warning, warning0): Adjust prototypes.
* toplev.h (warning, warning0): Likewise.
* attribs.c, builtins.c, c-common.c, c-decl.c, c-format.c,
c-gimplify.c, c-lex.c, c-objc-common.c, c-opts.c, c-parser.c,
c-pragma.c, c-typeck.c, calls.c, cgraph.c, coverage.c, emit-rtl.c,
fold-const.c, fortran/trans-decl.c, function.c, gcse.c,
genautomata.c, haifa-sched.c, opts.c, passes.c, regclass.c,
reload1.c, stmt.c, stor-layout.c, toplev.c, tree-cfg.c,
tree-dump.c, tree-inline.c, tree-mudflap.c, tree-optimize.c,
tree-ssa.c, tree.c, varasm.c: Adjust warning() callers.
* config/alpha/alpha.c, config/arc/arc.c, config/arm/arm.c,
config/avr/avr.c, config/bfin/bfin.c, config/c4x/c4x-c.c,
config/c4x/c4x.c, config/cris/cris.c, config/darwin-c.c,
config/darwin.c, config/darwin.h, config/h8300/h8300.c,
config/i386/cygming.h, config/i386/djgpp.h, config/i386/i386.c,
config/i386/winnt.c, config/ia64/ia64-c.c, config/ia64/ia64.c,
config/ip2k/ip2k.c, config/m32r/m32r.c, config/m68hc11/m68hc11.c,
config/m68k/m68k.c, config/mcore/mcore.c, config/mips/mips.c,
config/mmix/mmix.c, config/ns32k/ns32k.c, config/pa/pa-hpux11.h,
config/pa/pa.c, config/rs6000/aix43.h, config/rs6000/aix51.h,
config/rs6000/aix52.h, config/rs6000/darwin.h,
config/rs6000/rs6000-c.c, config/rs6000/rs6000.c,
config/s390/s390.c, config/sh/sh.c, config/sh/sh.h,
config/sh/symbian.c, config/sol2-c.c, config/sol2.c,
config/stormy16/stormy16.c, config/v850/v850-c.c,
config/v850/v850.c, config/xtensa/xtensa.c: Adjust warning()
callers.
* ada/misc.c: Adjust warning() callers.
* cp/call.c, cp/class.c, cp/cvt.c, cp/decl.c, cp/decl2.c,
cp/except.c, cp/friend.c, cp/init.c, cp/lex.c, cp/mangle.c,
cp/method.c, cp/name-lookup.c, cp/parser.c, cp/repo.c, cp/rtti.c,
cp/tree.c, cp/typeck.c, cp/typeck2.c: Adjust warning() callers.
* fortran/trans-decl.c: Adjust warning() callers.
* java/class.c, java/decl.c, java/expr.c, java/jcf-io.c,
java/jcf-parse.c, java/jv-scan.c, java/parse.y: Adjust warning()
callers.
* objc/objc-act.c: Adjust warning() callers.
* treelang/parse.y: Adjust warning() callers.
From-SVN: r98633
2005-04-23 23:29:07 +02:00
|
|
|
|
warning (0, "pointer to member cast from %qT to %qT is via"
|
2005-06-15 02:41:35 +02:00
|
|
|
|
" virtual base", intype, type);
|
2003-07-23 01:30:22 +02:00
|
|
|
|
else
|
1999-08-07 03:01:54 +02:00
|
|
|
|
{
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("pointer to member cast from %qT to %qT is"
|
2005-06-15 02:41:35 +02:00
|
|
|
|
" via virtual base", intype, type);
|
2003-07-23 01:30:22 +02:00
|
|
|
|
return error_mark_node;
|
1999-08-07 03:01:54 +02:00
|
|
|
|
}
|
2003-07-23 01:30:22 +02:00
|
|
|
|
/* This is a reinterpret cast, whose result is unspecified.
|
|
|
|
|
We choose to do nothing. */
|
|
|
|
|
return build1 (NOP_EXPR, type, expr);
|
1995-10-12 03:33:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-23 01:30:22 +02:00
|
|
|
|
if (TREE_CODE (expr) == PTRMEM_CST)
|
|
|
|
|
expr = cplus_expand_constant (expr);
|
|
|
|
|
|
|
|
|
|
if (binfo && !integer_zerop (BINFO_OFFSET (binfo)))
|
2005-06-14 22:01:59 +02:00
|
|
|
|
expr = size_binop (code,
|
2003-07-23 01:30:22 +02:00
|
|
|
|
build_nop (sizetype, expr),
|
|
|
|
|
BINFO_OFFSET (binfo));
|
2003-03-03 22:55:25 +01:00
|
|
|
|
return build_nop (type, expr);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
1998-12-14 16:35:40 +01:00
|
|
|
|
else if (TYPE_PTRMEMFUNC_P (type) && TYPE_PTRMEMFUNC_P (intype))
|
2004-10-21 23:23:42 +02:00
|
|
|
|
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0,
|
|
|
|
|
/*c_cast_p=*/false);
|
1998-12-14 16:35:40 +01:00
|
|
|
|
else if (TYPE_PTRMEMFUNC_P (intype))
|
|
|
|
|
{
|
2003-07-04 07:05:19 +02:00
|
|
|
|
if (!warn_pmf2ptr)
|
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (expr) == PTRMEM_CST)
|
|
|
|
|
return cp_convert_to_pointer (type,
|
|
|
|
|
PTRMEM_CST_MEMBER (expr),
|
|
|
|
|
force);
|
|
|
|
|
else if (TREE_CODE (expr) == OFFSET_REF)
|
|
|
|
|
{
|
|
|
|
|
tree object = TREE_OPERAND (expr, 0);
|
|
|
|
|
return get_member_function_from_ptrfunc (&object,
|
|
|
|
|
TREE_OPERAND (expr, 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("cannot convert %qE from type %qT to type %qT",
|
2005-06-15 02:41:35 +02:00
|
|
|
|
expr, intype, type);
|
1998-12-14 16:35:40 +01:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
if (integer_zerop (expr))
|
|
|
|
|
{
|
1998-12-14 16:35:40 +01:00
|
|
|
|
if (TYPE_PTRMEMFUNC_P (type))
|
2004-10-21 23:23:42 +02:00
|
|
|
|
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0,
|
|
|
|
|
/*c_cast_p=*/false);
|
2000-03-19 06:22:04 +01:00
|
|
|
|
|
2001-02-12 10:58:18 +01:00
|
|
|
|
if (TYPE_PTRMEM_P (type))
|
tree.h (build_int_cst): New.
.: * tree.h (build_int_cst): New.
(build_int_2): Remove.
* tree.c (build_int_2): Remove.
(build_int_cst): New.
(make_vector_type, build_common_tree_nodes,
build_common_tree_nodes_2): Use build_int_cst.
* builtins.c (expand_builtin_prefetch, expand_builtin_strstr,
expand_builtin_strpbrk, expand_builtin_fputs,
build_string_literal, expand_builtin_printf,
expand_builtin_sprintf, fold_builtin_lround, fold_builtin_bitop,
fold_builtin_bitop, fold_builtin_isascii, fold_builtin_toascii,
fold_builtin_isdigit, simplify_builtin_strstr,
simplify_builtin_strpbrk, fold_builtin_fputs,
simplify_builtin_sprintf): Use build_int_cst.
* c-common.c (start_fname_decls, fix_string_type,
c_common_nodes_and_builtins, c_init_attributes,
shorten_compare): Likewise.
* c-decl.c (complete_array_type,
check_bitfield_type_and_width): Likewise.
* c-lex.c (interpret_integer, lex_charconst): Likewise.
* c-parse.in (primary): <TYPES_COMPATIBLE_P> Likewise.
* c-pretty-print.c (pp_c_integer_constant): Likewise.
* c-typeck.c (really_start_incremental_init, push_init_level,
set_nonincremental_init_from_string): Likewise.
* calls.c (load_register_parameters): Likewise.
* convert.c (convert_to_pointer): Likewise.
* coverage.c (coverage_counter_alloc, tree_coverage_counter_ref,
build_fn_info_type, build_ctr_info_value, build_gcov_info):
Likewise.
* except.c (init_eh, assign_filter_values, assign_filter_values):
Likewise.
* expmed.c (store_fixed_bit_field, extract_bit_field,
extract_fixed_bit_field, extract_split_bit_field, expand_shift,
expand_mult_const, expand_mult_highpart_adjust, extract_high_half,
expand_sdiv_pow2, expand_divmod, make_tree): Likewise.
* expr.c (convert_move, emit_group_load, emit_group_store,
expand_assignment, store_constructor, store_field,
expand_expr_real_1, reduce_to_bit_field_precision): Likewise.
* fold-const.c (force_fit_type, int_const_binop, fold_convert_const,
invert_truthvalue, optimize_bit_field_compare,
decode_field_reference, all_ones_mask_p, constant_boolean_node,
fold_div_compare, fold, fold_read_from_constant_string,
fold_negate_const, fold_abs_const, fold_not_const): Likewise.
* function.c (assign_parm_setup_block): Likewise.
* stmt.c (shift_return_value, expand_end_case_type,
estimate_case_costs): Likewise.
* stor-layout.c (layout_type, initialize_sizetypes,
set_min_and_max_values_for_integral_type): Likewise.
* tree-chrec.c (chrec_fold_multiply_poly_poly,
reset_evolution_in_loop): Likewise.
* tree-chrec.h (build_polynomial_chrec): Likewise.
* tree-complex.c (build_replicated_const): Likewise.
* tree-eh.c (honor_protect_cleanup_actions,
lower_try_finally_onedest, lower_try_finally_copy,
lower_try_finally_switch): Likewise.
* tree-mudflap.c (mf_build_string, mx_register_decls,
mudflap_register_call, mudflap_enqueue_constant): Likewise.
* tree-nested.c (get_trampoline_type, get_nl_goto_field): Likewise.
* tree-pretty-print.c (dump_generic_node): Likewise.
* tree-ssa-ccp.c (widen_bitfield, maybe_fold_offset_to_array_ref):
Likewise.
* tree-ssa-dom.c (simplify_rhs_and_lookup_avail_expr): Likewise.
* tree-ssa-loop-niter.c (number_of_iterations_cond,
loop_niter_by_eval, upper_bound_in_type, lower_bound_in_type):
Likewise.
* config/alpha/alpha.c (alpha_initialize_trampoline,
alpha_va_start, alpha_gimplify_va_arg_1): Use build_int_cst.
* config/arm/arm.c (arm_get_cookie_size): Likewise.
* config/c4x/c4x.c (c4x_gimplify_va_arg_expr): Likewise.
* config/i386/i386.c (ix86_va_start, ix86_gimplify_va_arg): Likewise.
* config/i860/i860.c (i860_va_start): Likewise.
* config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise.
* config/mips/mips.c (mips_build_builtin_va_list, mips_va_start,
mips_gimplify_va_arg_expr): Likewise.
* config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise.
* config/rs6000/rs6000.c (rs6000_va_start, rs6000_gimplify_va_arg,
add_compiler_branch_island): Likewise.
* config/s390/s390.c (s390_va_start): Likewise.
* config/sh/sh.c (sh_va_start): Likewise.
* config/stormy16/stormy16.c (xstormy16_expand_builtin_va_start):
Likewise.
* config/xtensa/xtensa.c (xtensa_va_start,
xtensa_gimplify_va_arg_expr): Likewise.
* objc/objc-act.c (build_objc_string_object,
build_objc_symtab_template, init_def_list, init_objc_symtab,
init_module_descriptor, generate_static_references,
build_selector_translation_table, get_proto_encoding,
build_typed_selector_reference, build_selector_reference,
build_next_objc_exception_stuff,
build_method_prototype_list_template, generate_descriptor_table,
generate_protocols, build_protocol_initializer,
build_ivar_list_template, build_method_list_template,
build_ivar_list_initializer, generate_ivars_list,
generate_dispatch_table, generate_protocol_list,
build_category_initializer, build_shared_structure_initializer,
generate_shared_structures, handle_impent,
generate_objc_image_info): Use build_int_cst.
ada:
* cuintp.c (UI_To_gnu): Use build_int_cst..
* trans.c (Exception_Handler_to_gnu_sjlj, gnat_to_gnu): Likewise.
* utils.c (init_gigi_decls): Likewise.
* utils2.c (build_call_raise): Likewise.
cp:
* call.c (convert_class_to_reference,
build_user_type_conversion_1, convert_like_real,
build_java_interface_fn_ref, build_special_member_call): Use
build_int_cst.
* class.c (build_vtbl_initializer): Likewise.
* cp-gimplify.c (cp_gimplify_expr): Likewise.
* cvt.c (cp_convert_to_pointer): Likewise.
* decl.c (cxx_init_decl_processing, complete_array_type): Likewise.
* decl2.c (start_static_initialization_or_destruction,
generate_ctor_or_dtor_function): Likewise.
* except.c (build_throw): Likewise.
* lex.c (cxx_init): Likewise.
* mangle.c (write_integer_cst): Likewise.
* rtti.c (build_headof, get_tinfo_decl_dynamic,
build_dynamic_cast_1, ptr_initializer, ptm_initializer,
get_pseudo_ti_init): Likewise.
* search.c (get_dynamic_cast_base_type): Likewise.
* tree.c (build_shared_int_cst): Likewise.
fortran:
* trans-array.c (gfc_trans_array_constructor_value): Use
build_int_cst.
* trans-const.c (gfc_build_string_const,
gfc_init_constants, gfc_conv_mpz_to_tree,
gfc_conv_constant_to_tree): Likewise.
* trans-decl.c (gfc_get_symbol_decl): Likewise.
* trans-intrinsic.c (gfc_conv_intrinsic_ibits,
gfc_conv_intrinsic_len, prepare_arg_info): Likewise.
* trans-io.c (add_case, set_error_locus, build_dt,
transfer_expr): Likewise.
* trans-stmt.c (gfc_trans_label_assign, gfc_trans_pause,
gfc_trans_stop, gfc_trans_character_select): Likewise.
* trans-types.c (gfc_init_types, gfc_get_dtype): Likewise.
* trans.c (gfc_trans_runtime_check): Likewise.
java:
* boehm.c (get_boehm_type_descriptor): Use build_int_cst.
* class.c (build_utf8_ref, build_static_field_ref,
make_field_value, make_method_value, get_dispatch_table,
make_class_data, emit_symbol_table, emit_catch_table): Likewise.
* constants.c (get_tag_node, build_ref_from_constant_pool,
build_constants_constructor): Likewise.
* decl.c (java_init_decl_processing): Likewise.
* expr.c (build_java_array_length_access, build_newarray,
expand_java_multianewarray, expand_java_pushc, expand_iinc,
build_java_binop, build_field_ref, expand_java_add_case,
expand_java_call, build_known_method_ref, build_invokevirtual,
build_invokeinterface, build_jni_stub): Likewise.
* java-gimplify.c (java_gimplify_new_array_init): Likewise.
* jcf-parse.c (get_constant): Likewise.
* lex.c (do_java_lex): Likewise.
* parse.y (patch_binop, patch_unaryop, patch_cast,
build_null_of_type, patch_newarray): Likewise.
* resource.c (compile_resource_data): Likewise.
* typeck.c (build_prim_array_type): Likewise.
From-SVN: r86022
2004-08-15 17:45:33 +02:00
|
|
|
|
{
|
|
|
|
|
/* A NULL pointer-to-member is represented by -1, not by
|
|
|
|
|
zero. */
|
2007-01-08 23:53:20 +01:00
|
|
|
|
expr = build_int_cst_type (type, -1);
|
tree.h (build_int_cst): New.
.: * tree.h (build_int_cst): New.
(build_int_2): Remove.
* tree.c (build_int_2): Remove.
(build_int_cst): New.
(make_vector_type, build_common_tree_nodes,
build_common_tree_nodes_2): Use build_int_cst.
* builtins.c (expand_builtin_prefetch, expand_builtin_strstr,
expand_builtin_strpbrk, expand_builtin_fputs,
build_string_literal, expand_builtin_printf,
expand_builtin_sprintf, fold_builtin_lround, fold_builtin_bitop,
fold_builtin_bitop, fold_builtin_isascii, fold_builtin_toascii,
fold_builtin_isdigit, simplify_builtin_strstr,
simplify_builtin_strpbrk, fold_builtin_fputs,
simplify_builtin_sprintf): Use build_int_cst.
* c-common.c (start_fname_decls, fix_string_type,
c_common_nodes_and_builtins, c_init_attributes,
shorten_compare): Likewise.
* c-decl.c (complete_array_type,
check_bitfield_type_and_width): Likewise.
* c-lex.c (interpret_integer, lex_charconst): Likewise.
* c-parse.in (primary): <TYPES_COMPATIBLE_P> Likewise.
* c-pretty-print.c (pp_c_integer_constant): Likewise.
* c-typeck.c (really_start_incremental_init, push_init_level,
set_nonincremental_init_from_string): Likewise.
* calls.c (load_register_parameters): Likewise.
* convert.c (convert_to_pointer): Likewise.
* coverage.c (coverage_counter_alloc, tree_coverage_counter_ref,
build_fn_info_type, build_ctr_info_value, build_gcov_info):
Likewise.
* except.c (init_eh, assign_filter_values, assign_filter_values):
Likewise.
* expmed.c (store_fixed_bit_field, extract_bit_field,
extract_fixed_bit_field, extract_split_bit_field, expand_shift,
expand_mult_const, expand_mult_highpart_adjust, extract_high_half,
expand_sdiv_pow2, expand_divmod, make_tree): Likewise.
* expr.c (convert_move, emit_group_load, emit_group_store,
expand_assignment, store_constructor, store_field,
expand_expr_real_1, reduce_to_bit_field_precision): Likewise.
* fold-const.c (force_fit_type, int_const_binop, fold_convert_const,
invert_truthvalue, optimize_bit_field_compare,
decode_field_reference, all_ones_mask_p, constant_boolean_node,
fold_div_compare, fold, fold_read_from_constant_string,
fold_negate_const, fold_abs_const, fold_not_const): Likewise.
* function.c (assign_parm_setup_block): Likewise.
* stmt.c (shift_return_value, expand_end_case_type,
estimate_case_costs): Likewise.
* stor-layout.c (layout_type, initialize_sizetypes,
set_min_and_max_values_for_integral_type): Likewise.
* tree-chrec.c (chrec_fold_multiply_poly_poly,
reset_evolution_in_loop): Likewise.
* tree-chrec.h (build_polynomial_chrec): Likewise.
* tree-complex.c (build_replicated_const): Likewise.
* tree-eh.c (honor_protect_cleanup_actions,
lower_try_finally_onedest, lower_try_finally_copy,
lower_try_finally_switch): Likewise.
* tree-mudflap.c (mf_build_string, mx_register_decls,
mudflap_register_call, mudflap_enqueue_constant): Likewise.
* tree-nested.c (get_trampoline_type, get_nl_goto_field): Likewise.
* tree-pretty-print.c (dump_generic_node): Likewise.
* tree-ssa-ccp.c (widen_bitfield, maybe_fold_offset_to_array_ref):
Likewise.
* tree-ssa-dom.c (simplify_rhs_and_lookup_avail_expr): Likewise.
* tree-ssa-loop-niter.c (number_of_iterations_cond,
loop_niter_by_eval, upper_bound_in_type, lower_bound_in_type):
Likewise.
* config/alpha/alpha.c (alpha_initialize_trampoline,
alpha_va_start, alpha_gimplify_va_arg_1): Use build_int_cst.
* config/arm/arm.c (arm_get_cookie_size): Likewise.
* config/c4x/c4x.c (c4x_gimplify_va_arg_expr): Likewise.
* config/i386/i386.c (ix86_va_start, ix86_gimplify_va_arg): Likewise.
* config/i860/i860.c (i860_va_start): Likewise.
* config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise.
* config/mips/mips.c (mips_build_builtin_va_list, mips_va_start,
mips_gimplify_va_arg_expr): Likewise.
* config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise.
* config/rs6000/rs6000.c (rs6000_va_start, rs6000_gimplify_va_arg,
add_compiler_branch_island): Likewise.
* config/s390/s390.c (s390_va_start): Likewise.
* config/sh/sh.c (sh_va_start): Likewise.
* config/stormy16/stormy16.c (xstormy16_expand_builtin_va_start):
Likewise.
* config/xtensa/xtensa.c (xtensa_va_start,
xtensa_gimplify_va_arg_expr): Likewise.
* objc/objc-act.c (build_objc_string_object,
build_objc_symtab_template, init_def_list, init_objc_symtab,
init_module_descriptor, generate_static_references,
build_selector_translation_table, get_proto_encoding,
build_typed_selector_reference, build_selector_reference,
build_next_objc_exception_stuff,
build_method_prototype_list_template, generate_descriptor_table,
generate_protocols, build_protocol_initializer,
build_ivar_list_template, build_method_list_template,
build_ivar_list_initializer, generate_ivars_list,
generate_dispatch_table, generate_protocol_list,
build_category_initializer, build_shared_structure_initializer,
generate_shared_structures, handle_impent,
generate_objc_image_info): Use build_int_cst.
ada:
* cuintp.c (UI_To_gnu): Use build_int_cst..
* trans.c (Exception_Handler_to_gnu_sjlj, gnat_to_gnu): Likewise.
* utils.c (init_gigi_decls): Likewise.
* utils2.c (build_call_raise): Likewise.
cp:
* call.c (convert_class_to_reference,
build_user_type_conversion_1, convert_like_real,
build_java_interface_fn_ref, build_special_member_call): Use
build_int_cst.
* class.c (build_vtbl_initializer): Likewise.
* cp-gimplify.c (cp_gimplify_expr): Likewise.
* cvt.c (cp_convert_to_pointer): Likewise.
* decl.c (cxx_init_decl_processing, complete_array_type): Likewise.
* decl2.c (start_static_initialization_or_destruction,
generate_ctor_or_dtor_function): Likewise.
* except.c (build_throw): Likewise.
* lex.c (cxx_init): Likewise.
* mangle.c (write_integer_cst): Likewise.
* rtti.c (build_headof, get_tinfo_decl_dynamic,
build_dynamic_cast_1, ptr_initializer, ptm_initializer,
get_pseudo_ti_init): Likewise.
* search.c (get_dynamic_cast_base_type): Likewise.
* tree.c (build_shared_int_cst): Likewise.
fortran:
* trans-array.c (gfc_trans_array_constructor_value): Use
build_int_cst.
* trans-const.c (gfc_build_string_const,
gfc_init_constants, gfc_conv_mpz_to_tree,
gfc_conv_constant_to_tree): Likewise.
* trans-decl.c (gfc_get_symbol_decl): Likewise.
* trans-intrinsic.c (gfc_conv_intrinsic_ibits,
gfc_conv_intrinsic_len, prepare_arg_info): Likewise.
* trans-io.c (add_case, set_error_locus, build_dt,
transfer_expr): Likewise.
* trans-stmt.c (gfc_trans_label_assign, gfc_trans_pause,
gfc_trans_stop, gfc_trans_character_select): Likewise.
* trans-types.c (gfc_init_types, gfc_get_dtype): Likewise.
* trans.c (gfc_trans_runtime_check): Likewise.
java:
* boehm.c (get_boehm_type_descriptor): Use build_int_cst.
* class.c (build_utf8_ref, build_static_field_ref,
make_field_value, make_method_value, get_dispatch_table,
make_class_data, emit_symbol_table, emit_catch_table): Likewise.
* constants.c (get_tag_node, build_ref_from_constant_pool,
build_constants_constructor): Likewise.
* decl.c (java_init_decl_processing): Likewise.
* expr.c (build_java_array_length_access, build_newarray,
expand_java_multianewarray, expand_java_pushc, expand_iinc,
build_java_binop, build_field_ref, expand_java_add_case,
expand_java_call, build_known_method_ref, build_invokevirtual,
build_invokeinterface, build_jni_stub): Likewise.
* java-gimplify.c (java_gimplify_new_array_init): Likewise.
* jcf-parse.c (get_constant): Likewise.
* lex.c (do_java_lex): Likewise.
* parse.y (patch_binop, patch_unaryop, patch_cast,
build_null_of_type, patch_newarray): Likewise.
* resource.c (compile_resource_data): Likewise.
* typeck.c (build_prim_array_type): Likewise.
From-SVN: r86022
2004-08-15 17:45:33 +02:00
|
|
|
|
}
|
2000-03-19 06:22:04 +01:00
|
|
|
|
else
|
tree.h (build_int_cst): New, sign extended constant.
* tree.h (build_int_cst): New, sign extended constant.
(build_int_cstu): New, zero extended constant.
(build_int_cst_wide): Renamed from build_int_cst.
* tree.c (build_int_cst, build_int_cstu): New.
(build_int_cst_wide): Renamed from build_int_cst.
(make_vector_type, build_common_tree_nodes,
build_common_tree_nodes_2): Adjust build_int_cst calls.
* builtins.c (expand_builtin_prefetch, expand_builtin_strstr,
expand_builtin_strpbrk, expand_builtin_fputs,
build_string_literal, expand_builtin_printf,
expand_builtin_sprintf, fold_builtin_classify_type,
fold_builtin_lround, fold_builtin_bitop, fold_builtin_isascii,
fold_builtin_toascii, fold_builtin_isdigit,
simplify_builtin_strstr, simplify_builtin_strpbrk,
fold_builtin_fputs, simplify_builtin_sprintf): Likewise.
* c-common.c (start_fname_decls, fix_string_type, shorten_compare,
DEF_ATTR_INT): Likewise.
* c-decl.c (complete_array_type, check_bitfield_type_and_width):
Likewise.
* c-lex.c (interpret_integer, lex_charconst): Likewise.
* c-parse.in (primary) <TYPES_COMPATIBLE_P> Likewise.
* c-pretty-print.c (pp_c_integer_constant): Likewise.
* c-typeck.c (really_start_incremental_init, push_init_level,
set_nonincremental_init_from_string): Likewise.
* calls.c (load_register_parameters): Likewise.
convert.c (convert_to_pointer): Likewise.
coverage.c (coverage_counter_alloc, tree_coverage_counter_ref,
build_fn_info_type, build_fn_info_value, build_ctr_info_value,
build_gcov_info): Likewise.
* except.c (init_eh, assign_filter_values): Likewise.
* expmed.c (store_fixed_bit_field, extract_bit_field,
extract_fixed_bit_field, extract_split_bit_field, expand_shift,
expand_mult_const, expand_mult_highpart_adjust, extract_high_half,
expand_sdiv_pow2, expand_divmod, make_tree): Likewise.
* expr.c (convert_move, emit_group_load, emit_group_store,
expand_assignment, store_constructor, store_field,
expand_expr_real_1, reduce_to_bit_field_precision): Likewise.
fold-const.c (force_fit_type, int_const_binop, fold_convert_const,
invert_truthvalue, optimize_bit_field_compare,
decode_field_reference, all_ones_mask_p, constant_boolean_node,
fold_div_compare, fold, fold_read_from_constant_string,
fold_negate_const, fold_abs_const, fold_not_const, round_up,
round_down): Likewise.
* function.c (assign_parm_setup_block): Likewise.
* stmt.c (shift_return_value, expand_case, estimate_case_costs):
Likewise.
* stor-layout.c (layout_type, initialize_sizetypes,
set_min_and_max_values_for_integral_type): Likewise.
* tree-chrec.c (chrec_fold_multiply_poly_poly,
reset_evolution_in_loop): Likewise.
* tree-chrec.h (build_polynomial_chrec): Likewise.
* tree-complex.c (build_replicated_const): Likewise.
* tree-eh.c (honor_protect_cleanup_actions,
lower_try_finally_onedest, lower_try_finally_copy,
lower_try_finally_switch): Likewise.
* tree-mudflap.c (mf_build_string, mx_register_decls,
mudflap_register_call, mudflap_enqueue_constant): Likewise.
* tree-nested.c (get_trampoline_type, get_nl_goto_field): Likewise.
* tree-pretty-print.c (dump_generic_node): Likewise.
* tree-ssa-ccp.c (widen_bitfield, maybe_fold_offset_to_array_ref):
Likewise.
* tree-ssa-dom.c (simplify_rhs_and_lookup_avail_expr): Likewise.
* tree-ssa-loop-niter.c (number_of_iterations_cond,
loop_niter_by_eval, upper_bound_in_type, lower_bound_in_type):
Likewise.
* tree-ssa-loop-ivcanon.c (create_canonical_iv,
canonicalize_loop_induction_variables): Likewise.
* tree-vectorizer.c (vect_create_index_for_array_ref,
vect_transform_loop_bound, vect_compute_data_ref_alignment):
Likewise.
* config/alpha/alpha.c (alpha_initialize_trampoline, alpha_va_start,
alpha_gimplify_va_arg_1): Likewise.
* config/arm/arm.c (arm_get_cookie_size): Likewise.
* config/c4x/c4x.c (c4x_gimplify_va_arg_expr): Likewise.
* config/i386/i386.c (ix86_va_start, ix86_gimplify_va_arg): Likewise.
* config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise.
* config/mips/mips.c (mips_build_builtin_va_list, mips_va_start,
mips_gimplify_va_arg_expr): Likewise.
* config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise.
* config/rs6000/rs6000.c (rs6000_va_start, rs6000_gimplify_va_arg,
add_compiler_branch_island): Likewise.
* config/s390/s390.c (s390_va_start): Likewise.
* config/sh/sh.c (sh_va_start): Likewise.
* config/stormy16/stormy16.c (xstormy16_expand_builtin_va_start):
Likewise.
* config/xtensa/xtensa.c (xtensa_va_start,
xtensa_gimplify_va_arg_expr): Likewise.
* objc/objc-act.c (build_objc_string_object,
build_objc_symtab_template, init_def_list, init_objc_symtab,
init_module_descriptor, generate_static_references,
build_selector_translation_table, get_proto_encoding,
build_typed_selector_reference, build_selector_reference,
build_next_objc_exception_stuff,
build_method_prototype_list_template, generate_descriptor_table,
generate_protocols, build_protocol_initializer,
build_ivar_list_template, build_method_list_template,
build_ivar_list_initializer, generate_ivars_list,
generate_dispatch_table, generate_protocol_list,
build_category_initializer, build_shared_structure_initializer,
generate_shared_structures, handle_impent,
generate_objc_image_info): Likewise.
2004-04-25 Paolo Bonzini <bonzini@gnu.org>
* cfglayout.c (duplicate_insn_chain): Remove references to
NOTE_INSN_LOOP_VTOP and NOTE_INSN_LOOP_CONT.
* cfgloop.h (struct loop): Remove fields vtop, cont and cont_dominator.
* cfgrtl.c (rtl_delete_block): Remove handling of NOTE_INSN_LOOP_CONT.
* final.c (final_scan_insn): Remove references to NOTE_INSN_LOOP_VTOP
and NOTE_INSN_LOOP_CONT.
* insn-notes.def (NOTE_INSN_LOOP_VTOP, NOTE_INSN_LOOP_CONT): Remove.
* jump.c (squeeze_notes): Remove references to NOTE_INSN_LOOP_VTOP
and NOTE_INSN_LOOP_CONT.
* loop.c (scan_loops, find_and_verify_loops, for_each_insn_in_loop,
check_dbra_loop, loop_dump_aux): Remove references to removed notes
and fields.
* reorg.c (mostly_true_jump): Do not rely on NOTE_INSN_LOOP_VTOPs.
* unroll.c (unroll_loop, copy_loop_body, loop_iterations): Remove
references to removed notes and fields.
(subtract_reg_term, ujump_to_loop_cont): Remove.
From-SVN: r86544
2004-08-25 11:52:54 +02:00
|
|
|
|
expr = build_int_cst (type, 0);
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return expr;
|
|
|
|
|
}
|
2003-07-23 01:30:22 +02:00
|
|
|
|
else if (TYPE_PTR_TO_MEMBER_P (type) && INTEGRAL_CODE_P (form))
|
2002-08-05 05:56:16 +02:00
|
|
|
|
{
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("invalid conversion from %qT to %qT", intype, type);
|
2002-08-05 05:56:16 +02:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
1994-05-19 22:19:03 +02:00
|
|
|
|
if (INTEGRAL_CODE_P (form))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
1998-05-06 01:18:02 +02:00
|
|
|
|
if (TYPE_PRECISION (intype) == POINTER_SIZE)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return build1 (CONVERT_EXPR, type, expr);
|
Makefile.in (convert.o, [...]): Update.
* Makefile.in (convert.o, calls.o, expmed.o): Update.
* attribs.c (handle_mode_attribute, handle_vector_size_attribute):
Use new hooks.
* builtin-types.def (BT_PTRMODE): Update.
* c-common.c (type_for_size): Rename c_common_type_for_size.
(type_for_mode): Similarly.
(shorten_compare, pointer_int_sum, c_common_nodes_and_builtins):
Use new hook.
* c-bommon.h (c_common_type_for_size, c_common_type_for_mode): New.
* c-decl.c (finish_enum, build_enumerator): Use new hooks.
* c-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* c-typeck.c (common_type, comptypes, default_conversion):
Use new hooks.
* calls.c: Include langhooks.h.
(emit_library_call_value_1): Use new hooks. Avoid redundant
calls.
* convert.c: Include langhooks.h
(convert_to_pointer, convert_to_integer): Use new hooks.
* except.c (init_eh): Similarly.
* expmed.c: Include langhooks.h.
(expand_mult_add): Use new hooks.
* expr.c (store_expr, store_constructor, expand_expr, do_jump,
try_casesi): Similarly.
* fold-const.c (optimize_bit_field_compare, make_range,
decode_field_reference, fold_truthop, fold): Similarly.
* function.c (assign_stack_local_1, assign_stack_temp_for_type,
put_var_into_stack): Similarly.
* langhooks-def.h (LANG_HOOKS_TYPE_FOR_MODE,
LANG_HOOKS_TYPE_FOR_SIZE): New.
(LANG_HOOKS_TYPES_INITIALIZER): Update.
* langhooks.h (lang_hooks_for_types): New hooks.
* stmt.c (expand_decl_cleanup, emit_case_nodes): Use new hooks.
* tree.c (get_unwidened, get_narrower): Similarly.
* tree.h (type_for_mode, type_for_size): Remove.
* varasm.c (force_const_mem): Use new hooks.
ada:
* gigi.h (type_for_size, type_for_mode): Rename.
* misc.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* trans.c (tree_transform): Update.
* utils.c (gnat_init_decl_processing, init_gigi_decls,
builtin_function, float_type_for_size, signed_or_unsigned_type,
build_vms_descriptor, unchecked_convert): Update.
(type_for_mode, type_for_size): Rename.
* utils2.c (nonbinary_modular_operation): Update.
cp:
* cp-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* cvt.c (cp_convert_to_pointer, type_promotes_to): Use new hooks.
* decl.c (finish_enum): Similarly.
* error.c (dump_type): Similarly.
* lex.c (cxx_init): Similarly.
* mangle.c (write_builtin_type): Similarly.
* typeck.c (comptypes): Similarly.
f:
* com.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
(type_for_mode, type_for_size): Rename.
(signed_or_unsigned_type, signed_type, truthvalue_conversion,
unsigned_type): Use new hooks.
java:
* Make-lang.in (builtins.o): Update.
* boehm.c (get_boehm_type_descriptor): Update.
* builtins.c: Include langhooks.h.
* decl.c (java_init_decl_processing): Update.
* java-tree.h (java_type_for_mode, java_type_for_size): New.
* lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
* typeck.c (type_for_mode, type_for_size): Update.
objc:
* objc-act.c (handle_impent): Update.
* objc-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
From-SVN: r51571
2002-03-29 22:46:27 +01:00
|
|
|
|
expr = cp_convert (c_common_type_for_size (POINTER_SIZE, 0), expr);
|
call.c (check_dtor_name): Replace abort with gcc_assert or gcc_unreachable.
* call.c (check_dtor_name): Replace abort with gcc_assert or
gcc_unreachable.
(build_call, add_builtin_candidate, build_new_op,
convert_like_real, build_over_call, in_charge_arg_for_name,
source_type, joust): Likewise.
* class.c (build_simple_base_path, get_vcall_index,
finish_struct_1, instantiate_type, get_enclosing_class,
add_vcall_offset_vtbl_entries_1, cp_fold_obj_type_ref): Likewise.
* cp-gimplify.c (cp_genericize): Likewise.
* cp-lang.c (cp_expr_size, cp_tree_size): Likewise.
* cvt.c (cp_convert_to_pointer, ocp_convert): Likewise.
* decl.c (poplevel, make_unbound_class_template, reshape_init,
check_special_function_return_type, grokdeclarator,
grok_op_properties, tag_name, xref_tag, start_preparsed_function,
finish_function): Likewise.
* decl2.c (grokfield, maybe_emit_vtables):Likewise.
* error.c (dump_global_iord, dump_decl, dump_template_decl,
language_to_string): Likewise.
* except.c (choose_personality_routine): Likewise.
* friend.c (do_friend): Likewise.
* g++spec.c (lang_specific_driver): Likewise.
* init.c (build_zero_init, expand_default_init, build_new_1,
build_vec_delete_1, build_vec_init, build_dtor_call): Likewise.
* lex.c (retrofit_lang_decl, cp_type_qual_from_rid): Likewise.
* mangle.c (add_substitution, write_unscoped_name,
write_template_prefix, write_identifier,
write_special_name_destructor, write_type, write_builtin_type,
write_expression, write_template_param,
write_java_integer_type_codes): Likewise.
* method.c (implicitly_declare_fn): Likewise.
From-SVN: r86778
2004-08-30 17:28:48 +02:00
|
|
|
|
/* Modes may be different but sizes should be the same. There
|
|
|
|
|
is supposed to be some integral type that is the same width
|
|
|
|
|
as a pointer. */
|
|
|
|
|
gcc_assert (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr)))
|
|
|
|
|
== GET_MODE_SIZE (TYPE_MODE (type)));
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return convert_to_pointer (type, expr);
|
|
|
|
|
}
|
|
|
|
|
|
1998-10-27 23:33:40 +01:00
|
|
|
|
if (type_unknown_p (expr))
|
2006-02-08 00:25:02 +01:00
|
|
|
|
return instantiate_type (type, expr, tf_warning_or_error);
|
1998-10-27 23:33:40 +01:00
|
|
|
|
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("cannot convert %qE from type %qT to type %qT",
|
2005-06-15 02:41:35 +02:00
|
|
|
|
expr, intype, type);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Like convert, except permit conversions to take place which
|
|
|
|
|
are not normally allowed due to access restrictions
|
|
|
|
|
(such as conversion from sub-type to private super-type). */
|
1996-07-11 03:13:25 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
static tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
convert_to_pointer_force (tree type, tree expr)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2003-12-20 00:28:11 +01:00
|
|
|
|
tree intype = TREE_TYPE (expr);
|
|
|
|
|
enum tree_code form = TREE_CODE (intype);
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
if (form == POINTER_TYPE)
|
|
|
|
|
{
|
|
|
|
|
intype = TYPE_MAIN_VARIANT (intype);
|
|
|
|
|
|
|
|
|
|
if (TYPE_MAIN_VARIANT (type) != intype
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE
|
1996-04-19 02:48:03 +02:00
|
|
|
|
&& IS_AGGR_TYPE (TREE_TYPE (type))
|
|
|
|
|
&& IS_AGGR_TYPE (TREE_TYPE (intype))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
&& TREE_CODE (TREE_TYPE (intype)) == RECORD_TYPE)
|
|
|
|
|
{
|
|
|
|
|
enum tree_code code = PLUS_EXPR;
|
2001-11-25 14:21:45 +01:00
|
|
|
|
tree binfo;
|
|
|
|
|
|
|
|
|
|
binfo = lookup_base (TREE_TYPE (intype), TREE_TYPE (type),
|
2004-10-18 19:21:36 +02:00
|
|
|
|
ba_unique, NULL);
|
2001-11-25 14:21:45 +01:00
|
|
|
|
if (!binfo)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2001-11-25 14:21:45 +01:00
|
|
|
|
binfo = lookup_base (TREE_TYPE (type), TREE_TYPE (intype),
|
2004-10-18 19:21:36 +02:00
|
|
|
|
ba_unique, NULL);
|
2001-11-25 14:21:45 +01:00
|
|
|
|
code = MINUS_EXPR;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
2001-11-25 14:21:45 +01:00
|
|
|
|
if (binfo == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
if (binfo)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2001-11-25 14:21:45 +01:00
|
|
|
|
expr = build_base_path (code, expr, binfo, 0);
|
2005-06-15 02:41:35 +02:00
|
|
|
|
if (expr == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
2002-09-13 02:22:59 +02:00
|
|
|
|
/* Add any qualifier conversions. */
|
2001-11-25 14:21:45 +01:00
|
|
|
|
if (!same_type_p (TREE_TYPE (TREE_TYPE (expr)),
|
|
|
|
|
TREE_TYPE (type)))
|
2003-03-03 22:55:25 +01:00
|
|
|
|
expr = build_nop (type, expr);
|
2001-11-25 14:21:45 +01:00
|
|
|
|
return expr;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
return cp_convert_to_pointer (type, expr, true);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We are passing something to a function which requires a reference.
|
|
|
|
|
The type we are interested in is in TYPE. The initial
|
|
|
|
|
value we have to begin with is in ARG.
|
|
|
|
|
|
|
|
|
|
FLAGS controls how we manage access checking.
|
2001-07-25 17:04:32 +02:00
|
|
|
|
DIRECT_BIND in FLAGS controls how any temporaries are generated.
|
|
|
|
|
If DIRECT_BIND is set, DECL is the reference we're binding to. */
|
1996-07-11 03:13:25 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
static tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
build_up_reference (tree type, tree arg, int flags, tree decl)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
1997-04-24 00:39:53 +02:00
|
|
|
|
tree rval;
|
1994-04-08 08:08:43 +02:00
|
|
|
|
tree argtype = TREE_TYPE (arg);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree target_type = TREE_TYPE (type);
|
|
|
|
|
|
call.c (validate_conversion_obstack): Replace my_friendly_assert with gcc_assert or gcc_unreachable.
* call.c (validate_conversion_obstack): Replace
my_friendly_assert with gcc_assert or gcc_unreachable.
(direct_reference_binding, merge_conversion_sequences,
build_user_type_conversion_1, perform_overload_resolution,
build_op_delete_call, enforce_access, call_builtin_trap,
build_over_call, build_special_member_call, build_new_method_call,
initialize_reference): Likewise.
* class.c (build_base_path, build_primary_vtable, alter_access,
check_bases, update_vtable_entry_for_fn, layout_empty_base,
clone_function_decl, adjust_clone_args,
type_requires_array_cookie, include_empty_classes,
finish_struct_1, resolve_address_of_overloaded_function,
instantiate_type, get_vtbl_decl_for_binfo, build_vtt_inits,
dfs_build_secondary_vptr_vtt_inits, build_ctor_vtbl_group,
accumulate_vtbl_inits, build_vtbl_initializer,
build_vbase_offset_vtbl_entries, build_rtti_vtbl_entries): Likewise.
* cvt.c (build_up_reference, convert_to_reference): Likewise.
* decl.c (poplevel, duplicate_decls, make_typename_type,
cxx_init_decl_processing, reshape_init, check_initializer,
make_rtl_for_nonlocal_decl, initialize_local_var, cp_finish_decl,
expand_static_init, grokfndecl, grokvardecl, build_ptrmem_type,
grokdeclarator, copy_fn_p, grok_op_properties, xref_tag,
xref_basetypes, start_preparsed_function, save_function_data,
finish_function, finish_method, maybe_register_incomplete_var,
complete_vars): Likewise.
* decl2.c (grok_array_decl, check_member_template,
check_classfn, finish_static_data_member_decl, coerce_new_type,
coerce_delete_type, import_export_class, decl_needed_p,
determine_visibility, import_export_decl, build_cleanup,
start_static_initialization_or_destructi, do_static_destruction,
prune_vars_needing_no_initialization,
build_offset_ref_call_from_tree): Likewise.
* error.c (dump_decl, dump_expr): Likewise.
* init.c (finish_init_stmts, build_zero_init,
expand_virtual_init, expand_default_init, expand_aggr_init_1,
build_offset_ref, build_new_1, build_delete, build_vbase_delete):
Likewise.
* mangle.c (write_method_parms, write_template_args,
write_expression, write_template_arg): Likewise.
* method.c (make_thunk, finish_thunk, use_thunk): Likewise.
* name-lookup.c (pop_binding, begin_scope, leave_scope,
resume_scope, push_using_decl, validate_nonmember_using_decl,
is_ancestor, poplevel_class, set_inherited_value_binding_p,
push_class_level_binding, do_class_using_decl, push_namespace,
pop_namespace, add_using_namespace, ambiguous_decl,
lookup_namespace_name, lookup_type_current_level,
maybe_process_template_type_declaration): Likewise.
* parser.c (cp_lexer_peek_nth_token,
cp_parser_parse_and_diagnose_invalid_typ,
cp_parser_translation_unit, cp_parser_template_id,
cp_parser_lookup_name, cp_parser_late_parsing_for_member): Likewise.
* pt.c (push_access_scope, finish_member_template_decl,
push_inline_template_parms_recursive, add_outermost_template_args,
get_innermost_template_args, begin_explicit_instantiation,
end_explicit_instantiation, retrieve_specialization,
is_specialization_of, is_specialization_of_friend,
register_specialization, check_explicit_specialization,
comp_template_parms, process_template_parm,
process_partial_specialization, convert_nontype_argument,
coerce_template_template_parms, coerce_template_parms,
mangle_class_name_for_template, lookup_template_function,
lookup_template_class, instantiate_class_template, tsubst_decl,
tsubst_function_type, tsubst, tsubst_qualified_id, tsubst_copy,
instantiate_template, fn_type_unification, type_unification_real,
get_template_base, regenerate_decl_from_template,
template_for_substitution, instantiate_decl,
get_mostly_instantiated_function_type, dependent_scope_ref_p,
value_dependent_expression_p, resolve_typename_type): Likewise.
* repo.c (repo_emit_p): Likewise.
* rtti.c (build_headof, get_tinfo_decl, get_pseudo_ti_init,
create_tinfo_types, emit_tinfo_decl): Likewise.
* search.c (lookup_base_r, lookup_base, lookup_field_1,
dfs_access_in_type, build_baselink, lookup_member,
adjust_result_of_qualified_name_lookup, copied_binfo): Likewise.
* semantics.c (perform_or_defer_access_check,
finish_non_static_data_member, finish_stmt_expr_expr,
finish_stmt_expr, finish_call_expr, finish_pseudo_destructor_expr,
finish_template_template_parm, finish_member_declaration,
emit_associated_thunks): Likewise.
* tree.c (build_target_expr_with_type, force_target_expr,
copy_binfo, get_first_fn, cp_tree_equal): Likewise.
* typeck.c (type_after_usual_arithmetic_conversions, comptypes,
cxx_sizeof_or_alignof_type, perform_integral_promotions,
build_class_member_access_expr, finish_class_member_access_expr,
build_ptrmemfunc_access_expr, build_unary_op,
unary_complex_lvalue, cxx_mark_addressable, build_modify_expr,
build_ptrmemfunc, expand_ptrmemfunc_cst, check_return_expr
* typeck2.c (complete_type_check_abstract,
abstract_virtuals_error, process_init_constructor,
add_exception_specifier): Likewise.
From-SVN: r86669
2004-08-27 19:59:33 +02:00
|
|
|
|
gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
1997-04-24 00:39:53 +02:00
|
|
|
|
if ((flags & DIRECT_BIND) && ! real_lvalue_p (arg))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2001-07-25 17:04:32 +02:00
|
|
|
|
/* Create a new temporary variable. We can't just use a TARGET_EXPR
|
|
|
|
|
here because it needs to live as long as DECL. */
|
1997-04-24 00:39:53 +02:00
|
|
|
|
tree targ = arg;
|
2001-07-25 17:04:32 +02:00
|
|
|
|
|
2003-03-07 22:19:38 +01:00
|
|
|
|
arg = make_temporary_var_for_ref_to_temp (decl, TREE_TYPE (arg));
|
1999-08-30 20:54:20 +02:00
|
|
|
|
|
|
|
|
|
/* Process the initializer for the declaration. */
|
1996-11-12 20:49:48 +01:00
|
|
|
|
DECL_INITIAL (arg) = targ;
|
2006-02-18 09:36:11 +01:00
|
|
|
|
cp_finish_decl (arg, targ, /*init_const_expr_p=*/false, NULL_TREE,
|
1998-11-25 01:28:51 +01:00
|
|
|
|
LOOKUP_ONLYCONVERTING|DIRECT_BIND);
|
1996-05-30 21:11:58 +02:00
|
|
|
|
}
|
1997-04-24 00:39:53 +02:00
|
|
|
|
else if (!(flags & DIRECT_BIND) && ! lvalue_p (arg))
|
1999-11-14 06:04:19 +01:00
|
|
|
|
return get_target_expr (arg);
|
1996-05-30 21:11:58 +02:00
|
|
|
|
|
2001-07-25 17:04:32 +02:00
|
|
|
|
/* If we had a way to wrap this up, and say, if we ever needed its
|
1996-12-18 03:46:25 +01:00
|
|
|
|
address, transform all occurrences of the register, into a memory
|
|
|
|
|
reference we could win better. */
|
1997-04-24 00:39:53 +02:00
|
|
|
|
rval = build_unary_op (ADDR_EXPR, arg, 1);
|
1998-10-16 05:37:43 +02:00
|
|
|
|
if (rval == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
|
1997-06-18 04:25:37 +02:00
|
|
|
|
if ((flags & LOOKUP_PROTECT)
|
|
|
|
|
&& TYPE_MAIN_VARIANT (argtype) != TYPE_MAIN_VARIANT (target_type)
|
|
|
|
|
&& IS_AGGR_TYPE (argtype)
|
|
|
|
|
&& IS_AGGR_TYPE (target_type))
|
|
|
|
|
{
|
2001-11-29 18:15:56 +01:00
|
|
|
|
/* We go through lookup_base for the access control. */
|
2001-11-25 14:21:45 +01:00
|
|
|
|
tree binfo = lookup_base (argtype, target_type, ba_check, NULL);
|
1997-06-18 04:25:37 +02:00
|
|
|
|
if (binfo == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
if (binfo == NULL_TREE)
|
|
|
|
|
return error_not_base_type (target_type, argtype);
|
2001-11-25 14:21:45 +01:00
|
|
|
|
rval = build_base_path (PLUS_EXPR, rval, binfo, 1);
|
1997-06-18 04:25:37 +02:00
|
|
|
|
}
|
1997-04-24 00:39:53 +02:00
|
|
|
|
else
|
|
|
|
|
rval
|
|
|
|
|
= convert_to_pointer_force (build_pointer_type (target_type), rval);
|
2003-03-03 22:55:25 +01:00
|
|
|
|
return build_nop (type, rval);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-14 12:18:15 +02:00
|
|
|
|
/* Subroutine of convert_to_reference. REFTYPE is the target reference type.
|
|
|
|
|
INTYPE is the original rvalue type and DECL is an optional _DECL node
|
|
|
|
|
for diagnostics.
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
2000-08-14 12:18:15 +02:00
|
|
|
|
[dcl.init.ref] says that if an rvalue is used to
|
|
|
|
|
initialize a reference, then the reference must be to a
|
|
|
|
|
non-volatile const type. */
|
|
|
|
|
|
|
|
|
|
static void
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
warn_ref_binding (tree reftype, tree intype, tree decl)
|
2000-08-14 12:18:15 +02:00
|
|
|
|
{
|
|
|
|
|
tree ttl = TREE_TYPE (reftype);
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
2000-08-14 12:18:15 +02:00
|
|
|
|
if (!CP_TYPE_CONST_NON_VOLATILE_P (ttl))
|
|
|
|
|
{
|
|
|
|
|
const char *msg;
|
|
|
|
|
|
|
|
|
|
if (CP_TYPE_VOLATILE_P (ttl) && decl)
|
2004-11-01 01:11:49 +01:00
|
|
|
|
msg = "initialization of volatile reference type %q#T from"
|
2005-06-15 02:41:35 +02:00
|
|
|
|
" rvalue of type %qT";
|
2000-08-14 12:18:15 +02:00
|
|
|
|
else if (CP_TYPE_VOLATILE_P (ttl))
|
2004-11-01 01:11:49 +01:00
|
|
|
|
msg = "conversion to volatile reference type %q#T "
|
2005-06-15 02:41:35 +02:00
|
|
|
|
" from rvalue of type %qT";
|
2000-08-14 12:18:15 +02:00
|
|
|
|
else if (decl)
|
2004-11-01 01:11:49 +01:00
|
|
|
|
msg = "initialization of non-const reference type %q#T from"
|
2005-06-15 02:41:35 +02:00
|
|
|
|
" rvalue of type %qT";
|
2000-08-14 12:18:15 +02:00
|
|
|
|
else
|
2004-11-01 01:11:49 +01:00
|
|
|
|
msg = "conversion to non-const reference type %q#T from"
|
2005-06-15 02:41:35 +02:00
|
|
|
|
" rvalue of type %qT";
|
2000-08-14 12:18:15 +02:00
|
|
|
|
|
cp-tree.h: Delete #defines for cp_error, cp_warning, cp_pedwarn, and cp_compiler_error.
* cp-tree.h: Delete #defines for cp_error, cp_warning,
cp_pedwarn, and cp_compiler_error.
* call.c, class.c, cp-tree.h, cvt.c, decl.c, decl2.c, error.c,
except.c, friend.c, init.c, lex.c, method.c, parse.y, pt.c,
rtti.c, search.c, semantics.c, spew.c, tree.c, typeck.c,
typeck2.c: Change calls to the above macros to use their
language-independent equivalents: error, warning, pedwarn, and
internal_error respectively.
From-SVN: r48140
2001-12-18 04:35:42 +01:00
|
|
|
|
pedwarn (msg, reftype, intype);
|
2000-08-14 12:18:15 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
/* For C++: Only need to do one-level references, but cannot
|
|
|
|
|
get tripped up on signed/unsigned differences.
|
|
|
|
|
|
1994-05-13 04:46:07 +02:00
|
|
|
|
DECL is either NULL_TREE or the _DECL node for a reference that is being
|
|
|
|
|
initialized. It can be error_mark_node if we don't know the _DECL but
|
|
|
|
|
we know it's an initialization. */
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
convert_to_reference (tree reftype, tree expr, int convtype,
|
2005-06-15 02:41:35 +02:00
|
|
|
|
int flags, tree decl)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2003-12-20 00:28:11 +01:00
|
|
|
|
tree type = TYPE_MAIN_VARIANT (TREE_TYPE (reftype));
|
|
|
|
|
tree intype;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree rval = NULL_TREE;
|
1995-02-16 16:24:37 +01:00
|
|
|
|
tree rval_as_conversion = NULL_TREE;
|
2003-07-23 01:30:22 +02:00
|
|
|
|
bool can_convert_intype_to_type;
|
1995-02-16 16:24:37 +01:00
|
|
|
|
|
2005-06-14 22:01:59 +02:00
|
|
|
|
if (TREE_CODE (type) == FUNCTION_TYPE
|
2002-10-17 02:17:59 +02:00
|
|
|
|
&& TREE_TYPE (expr) == unknown_type_node)
|
2005-06-14 22:01:59 +02:00
|
|
|
|
expr = instantiate_type (type, expr,
|
2002-12-28 09:03:42 +01:00
|
|
|
|
(flags & LOOKUP_COMPLAIN)
|
2006-02-08 00:25:02 +01:00
|
|
|
|
? tf_warning_or_error : tf_none);
|
2002-12-28 09:03:42 +01:00
|
|
|
|
|
|
|
|
|
if (expr == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
|
|
|
|
|
intype = TREE_TYPE (expr);
|
1998-10-27 23:33:40 +01:00
|
|
|
|
|
call.c (validate_conversion_obstack): Replace my_friendly_assert with gcc_assert or gcc_unreachable.
* call.c (validate_conversion_obstack): Replace
my_friendly_assert with gcc_assert or gcc_unreachable.
(direct_reference_binding, merge_conversion_sequences,
build_user_type_conversion_1, perform_overload_resolution,
build_op_delete_call, enforce_access, call_builtin_trap,
build_over_call, build_special_member_call, build_new_method_call,
initialize_reference): Likewise.
* class.c (build_base_path, build_primary_vtable, alter_access,
check_bases, update_vtable_entry_for_fn, layout_empty_base,
clone_function_decl, adjust_clone_args,
type_requires_array_cookie, include_empty_classes,
finish_struct_1, resolve_address_of_overloaded_function,
instantiate_type, get_vtbl_decl_for_binfo, build_vtt_inits,
dfs_build_secondary_vptr_vtt_inits, build_ctor_vtbl_group,
accumulate_vtbl_inits, build_vtbl_initializer,
build_vbase_offset_vtbl_entries, build_rtti_vtbl_entries): Likewise.
* cvt.c (build_up_reference, convert_to_reference): Likewise.
* decl.c (poplevel, duplicate_decls, make_typename_type,
cxx_init_decl_processing, reshape_init, check_initializer,
make_rtl_for_nonlocal_decl, initialize_local_var, cp_finish_decl,
expand_static_init, grokfndecl, grokvardecl, build_ptrmem_type,
grokdeclarator, copy_fn_p, grok_op_properties, xref_tag,
xref_basetypes, start_preparsed_function, save_function_data,
finish_function, finish_method, maybe_register_incomplete_var,
complete_vars): Likewise.
* decl2.c (grok_array_decl, check_member_template,
check_classfn, finish_static_data_member_decl, coerce_new_type,
coerce_delete_type, import_export_class, decl_needed_p,
determine_visibility, import_export_decl, build_cleanup,
start_static_initialization_or_destructi, do_static_destruction,
prune_vars_needing_no_initialization,
build_offset_ref_call_from_tree): Likewise.
* error.c (dump_decl, dump_expr): Likewise.
* init.c (finish_init_stmts, build_zero_init,
expand_virtual_init, expand_default_init, expand_aggr_init_1,
build_offset_ref, build_new_1, build_delete, build_vbase_delete):
Likewise.
* mangle.c (write_method_parms, write_template_args,
write_expression, write_template_arg): Likewise.
* method.c (make_thunk, finish_thunk, use_thunk): Likewise.
* name-lookup.c (pop_binding, begin_scope, leave_scope,
resume_scope, push_using_decl, validate_nonmember_using_decl,
is_ancestor, poplevel_class, set_inherited_value_binding_p,
push_class_level_binding, do_class_using_decl, push_namespace,
pop_namespace, add_using_namespace, ambiguous_decl,
lookup_namespace_name, lookup_type_current_level,
maybe_process_template_type_declaration): Likewise.
* parser.c (cp_lexer_peek_nth_token,
cp_parser_parse_and_diagnose_invalid_typ,
cp_parser_translation_unit, cp_parser_template_id,
cp_parser_lookup_name, cp_parser_late_parsing_for_member): Likewise.
* pt.c (push_access_scope, finish_member_template_decl,
push_inline_template_parms_recursive, add_outermost_template_args,
get_innermost_template_args, begin_explicit_instantiation,
end_explicit_instantiation, retrieve_specialization,
is_specialization_of, is_specialization_of_friend,
register_specialization, check_explicit_specialization,
comp_template_parms, process_template_parm,
process_partial_specialization, convert_nontype_argument,
coerce_template_template_parms, coerce_template_parms,
mangle_class_name_for_template, lookup_template_function,
lookup_template_class, instantiate_class_template, tsubst_decl,
tsubst_function_type, tsubst, tsubst_qualified_id, tsubst_copy,
instantiate_template, fn_type_unification, type_unification_real,
get_template_base, regenerate_decl_from_template,
template_for_substitution, instantiate_decl,
get_mostly_instantiated_function_type, dependent_scope_ref_p,
value_dependent_expression_p, resolve_typename_type): Likewise.
* repo.c (repo_emit_p): Likewise.
* rtti.c (build_headof, get_tinfo_decl, get_pseudo_ti_init,
create_tinfo_types, emit_tinfo_decl): Likewise.
* search.c (lookup_base_r, lookup_base, lookup_field_1,
dfs_access_in_type, build_baselink, lookup_member,
adjust_result_of_qualified_name_lookup, copied_binfo): Likewise.
* semantics.c (perform_or_defer_access_check,
finish_non_static_data_member, finish_stmt_expr_expr,
finish_stmt_expr, finish_call_expr, finish_pseudo_destructor_expr,
finish_template_template_parm, finish_member_declaration,
emit_associated_thunks): Likewise.
* tree.c (build_target_expr_with_type, force_target_expr,
copy_binfo, get_first_fn, cp_tree_equal): Likewise.
* typeck.c (type_after_usual_arithmetic_conversions, comptypes,
cxx_sizeof_or_alignof_type, perform_integral_promotions,
build_class_member_access_expr, finish_class_member_access_expr,
build_ptrmemfunc_access_expr, build_unary_op,
unary_complex_lvalue, cxx_mark_addressable, build_modify_expr,
build_ptrmemfunc, expand_ptrmemfunc_cst, check_return_expr
* typeck2.c (complete_type_check_abstract,
abstract_virtuals_error, process_init_constructor,
add_exception_specifier): Likewise.
From-SVN: r86669
2004-08-27 19:59:33 +02:00
|
|
|
|
gcc_assert (TREE_CODE (intype) != REFERENCE_TYPE);
|
2006-04-19 19:15:54 +02:00
|
|
|
|
gcc_assert (TREE_CODE (reftype) == REFERENCE_TYPE);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
intype = TYPE_MAIN_VARIANT (intype);
|
|
|
|
|
|
2003-07-23 01:30:22 +02:00
|
|
|
|
can_convert_intype_to_type = can_convert (type, intype);
|
|
|
|
|
if (!can_convert_intype_to_type
|
|
|
|
|
&& (convtype & CONV_IMPLICIT) && IS_AGGR_TYPE (intype)
|
1995-02-16 16:24:37 +01:00
|
|
|
|
&& ! (flags & LOOKUP_NO_CONVERSION))
|
|
|
|
|
{
|
|
|
|
|
/* Look for a user-defined conversion to lvalue that we can use. */
|
|
|
|
|
|
call.c, [...]: Remove support for -fno-ansi-overloading and overloading METHOD_CALL_EXPR.
* call.c, class.c, cp-tree.h, cvt.c, decl.c, init.c, lex.c,
method.c, pt.c, ptree.c, typeck.c: Remove support for
-fno-ansi-overloading and overloading METHOD_CALL_EXPR.
* class.h: Remove.
* Makefile.in: Adjust.
From-SVN: r18384
1998-03-03 04:24:44 +01:00
|
|
|
|
rval_as_conversion
|
2003-03-03 22:55:25 +01:00
|
|
|
|
= build_type_conversion (reftype, expr);
|
1995-02-16 16:24:37 +01:00
|
|
|
|
|
|
|
|
|
if (rval_as_conversion && rval_as_conversion != error_mark_node
|
|
|
|
|
&& real_lvalue_p (rval_as_conversion))
|
|
|
|
|
{
|
|
|
|
|
expr = rval_as_conversion;
|
|
|
|
|
rval_as_conversion = NULL_TREE;
|
|
|
|
|
intype = type;
|
2003-07-23 01:30:22 +02:00
|
|
|
|
can_convert_intype_to_type = 1;
|
1995-02-16 16:24:37 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-23 01:30:22 +02:00
|
|
|
|
if (((convtype & CONV_STATIC) && can_convert (intype, type))
|
|
|
|
|
|| ((convtype & CONV_IMPLICIT) && can_convert_intype_to_type))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
|
|
|
|
if (flags & LOOKUP_COMPLAIN)
|
|
|
|
|
{
|
1994-04-29 00:48:45 +02:00
|
|
|
|
tree ttl = TREE_TYPE (reftype);
|
1998-08-17 19:13:42 +02:00
|
|
|
|
tree ttr = lvalue_type (expr);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
2000-08-14 12:18:15 +02:00
|
|
|
|
if (! real_lvalue_p (expr))
|
|
|
|
|
warn_ref_binding (reftype, intype, decl);
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
2000-08-14 12:18:15 +02:00
|
|
|
|
if (! (convtype & CONV_CONST)
|
cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals.
* cplus-dem.c (work_stuff): Replace const_type and volatile_type
with type_quals.
(TYPE_UNQUALIFIED): New macro.
(TYPE_QUAL_CONST): Likewise.
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(code_for_qualifier): New function.
(qualifier_string): Likewise.
(demangle_qualifier): Likewise.
(internal_cplus_demangle): Use them.
(demangle_signature): Likewise.
(demangle_template_value_parm): Likewise.
(do_type): Likewise.
(demangle_fund_type)): Likewise.
* Makefile.in (hash.h): Run gperf when necessary.
* cp-tree.h (CP_TYPE_READONLY): Remove.
(CP_TYPE_VOLATILE): Likewise.
(CP_TYPE_QUALS): New macro.
(CP_TYPE_CONST_P): Likewise.
(CP_TYPE_VOLATILE_P): Likewise.
(CP_TYPE_RESTRICT_P): Likewise.
(CP_TYPE_CONST_NON_VOLATILE_P): Likewise.
(cp_build_type_variant): Rename to ...
(cp_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Declare.
(SIGNATURE_POINTER_NAME_FORMAT): Modify to allow `restrict'.
(SIGNATURE_REFERENCE_NAME_FORMAT): Likewise.
(cp_type_qual_from_rid): New function.
(compparms): Remove unused parameter. All callers changed.
(cp_type_quals): New function.
(at_least_as_qualified_p): Likewise.
(more_qualified_p): Likewise.
* call.c (standard_conversion): Replace calls to
cp_build_type_variant with cp_build_qualified_type. Use
CP_TYPE_QUALS to get qualifiers and at_least_as_qualified_p to
compare them. Use CP_TYPE_* macros to check qualifiers.
(reference_binding): Likewise.
(implicit_conversion): Likewise.
(add_builtin_candidates): Likewise.
(build_over_call): Likewise.
* class.c (overrides): Compare all qualifiers, not just `const',
on method declarations.
* cvt.c (convert_to_reference): More CP_TYPE_QUALS conversion, etc.
(convert_pointer_to_real): Likewise.
(type_promotes_to): Likewise.
* decl.c (check_for_uninitialized_const_var): New function.
(init_decl_processing): More CP_TYPE_QUALS conversion, etc.
(cp_finish_decl): Use check_for_uninitialized_const_var.
(grokdeclarator): More CP_TYPE_QUALS conversion, etc. Update to
handle `restrict'.
(grok_ctor_properties): Likewise.
(grok_op_properties): Likewise.
(start_function): Likewise.
(rever_static_member_fn): Likewise.
* decl2.c (grok_method_quals): Likewise.
(grokfield): Likewise.
* error.c (dump_readonly_or_volatile): Rename to ...
(dump_qualifiers): New function. Handle `restrict'.
(dump_type_real): Use it.
(dump_aggr_type): Likewise.
(dump_type_prefix): Likewise.
(dump_type_suffix): Likewise.
(dump_function_decl): Likewise.
(cv_as_string): Likewise.
* gxx.gperf: Add __restrict and __restrict__.
* gxxint.texi: Document `u' as used for `__restrict', and a few
other previously undocumented codes.
* hash.h: Regenerated.
* init.c (expand_aggr_init): More CP_TYPE_QUALS conversion, etc.
(build_member_call): Likewise.
(build_new_1): Likewise.
* lex.c (init_parse): Add entry for RID_RESTRICT.
(cons_up_default_function): More CP_TYPE_QUALS conversion, etc.
(cp_type_qual_from_rid): Define.
* lex.h (enum rid): Add RID_RESTRICT.
* method.c (process_modifiers): Deal with `restrict'.
* parse.y (primary): More CP_TYPE_QUALS conversion, etc.
* parse.c: Regenerated.
* pt.c (convert_nontype_argument): More CP_TYPE_QUALS conversion, etc.
(tsubst_aggr_type): Likewise.
(tsubst): Likewise.
(check_cv_quals_for_unify): Likewise.
(unify): Likewise.
* rtti.c (init_rtti_processing): Likewise.
(build_headof): Likewise.
(get_tinfo_var): Likewise.
(buidl_dynamic_cast_1): Likewise. Fix `volatile' handling.
(expand_class_desc): Likewise.
(expand_attr_desc): Likewise.
(synthesize_tinfo_fn): Likewise.
* search.c (covariant_return_p): Likewise. Fix `volatile' handling.
(get_matching_virtual): Likewise.
(expand_upcast_fixups): Likewise.
* sig.c (build_signature_pointer_or_reference_name): Take
type_quals, not constp and volatilep.
(build_signature_pointer_or_reference_type): Likewise.
(match_method_types): More CP_TYPE_QUALS conversion, etc.
(build_signature_pointer_constructor): Likewise.
(build_signature_method_call): Likewise.
* tree.c (build_cplus_array_type): Likewise.
(cp_build_type_variant): Rename to ...
(cp_build_qualified_type): New function. Deal with `__restrict'.
(canonical_type_variant): More CP_TYPE_QUALS conversion, etc.
(build_exception_variant): Likewise.
(mapcar): Likewise.
* typeck.c (qualif_type): Likewise.
(common_type): Likewise.
(comptypes): Likewise.
(comp_cv_target_types): Likewise.
(at_least_as_qualified_p): Define.
(more_qualified_p): Likewise.
(comp_cv_qualification): More CP_TYPE_QUALS conversion, etc.
(compparms): Likewise.
(inline_conversion): Likewise.
(string_conv_p): Likewise.
(build_component_ref): Likewise.
(build_indirect_ref): Likewise.
(build_array_ref): Likewise.
(build_unary_op): Likewise.
(build_conditional_expr): Likewise.
(build_static_cast): Likewise.
(build_c_cast): Likewise.
(build_modify_expr): Likewise.
(convert_For_assignment): Likewise.
(comp_ptr_ttypes_real): Likewise.
(cp_type_quals): New function.
From-SVN: r23258
1998-10-23 16:53:28 +02:00
|
|
|
|
&& !at_least_as_qualified_p (ttl, ttr))
|
2004-11-01 01:11:49 +01:00
|
|
|
|
pedwarn ("conversion from %qT to %qT discards qualifiers",
|
2005-06-15 02:41:35 +02:00
|
|
|
|
ttr, reftype);
|
1994-04-08 08:08:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-25 17:04:32 +02:00
|
|
|
|
return build_up_reference (reftype, expr, flags, decl);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
1994-06-30 03:51:05 +02:00
|
|
|
|
else if ((convtype & CONV_REINTERPRET) && lvalue_p (expr))
|
1994-04-08 08:08:43 +02:00
|
|
|
|
{
|
|
|
|
|
/* When casting an lvalue to a reference type, just convert into
|
|
|
|
|
a pointer to the new type and deference it. This is allowed
|
1994-04-15 03:44:15 +02:00
|
|
|
|
by San Diego WP section 5.2.9 paragraph 12, though perhaps it
|
1994-04-08 08:08:43 +02:00
|
|
|
|
should be done directly (jason). (int &)ri ---> *(int*)&ri */
|
1994-04-15 03:44:15 +02:00
|
|
|
|
|
1995-01-25 21:00:09 +01:00
|
|
|
|
/* B* bp; A& ar = (A&)bp; is valid, but it's probably not what they
|
2005-06-15 02:41:35 +02:00
|
|
|
|
meant. */
|
1995-02-16 16:24:37 +01:00
|
|
|
|
if (TREE_CODE (intype) == POINTER_TYPE
|
2003-06-18 17:22:19 +02:00
|
|
|
|
&& (comptypes (TREE_TYPE (intype), type,
|
|
|
|
|
COMPARE_BASE | COMPARE_DERIVED)))
|
diagnostic.c (warning): Accept parameter to classify warning option.
* diagnostic.c (warning): Accept parameter to classify warning option.
(warning0): New, for when a pointer to an error() like function is needed.
* errors.c (warning): Likewise.
* errors.h (warning, warning0): Adjust prototypes.
* toplev.h (warning, warning0): Likewise.
* attribs.c, builtins.c, c-common.c, c-decl.c, c-format.c,
c-gimplify.c, c-lex.c, c-objc-common.c, c-opts.c, c-parser.c,
c-pragma.c, c-typeck.c, calls.c, cgraph.c, coverage.c, emit-rtl.c,
fold-const.c, fortran/trans-decl.c, function.c, gcse.c,
genautomata.c, haifa-sched.c, opts.c, passes.c, regclass.c,
reload1.c, stmt.c, stor-layout.c, toplev.c, tree-cfg.c,
tree-dump.c, tree-inline.c, tree-mudflap.c, tree-optimize.c,
tree-ssa.c, tree.c, varasm.c: Adjust warning() callers.
* config/alpha/alpha.c, config/arc/arc.c, config/arm/arm.c,
config/avr/avr.c, config/bfin/bfin.c, config/c4x/c4x-c.c,
config/c4x/c4x.c, config/cris/cris.c, config/darwin-c.c,
config/darwin.c, config/darwin.h, config/h8300/h8300.c,
config/i386/cygming.h, config/i386/djgpp.h, config/i386/i386.c,
config/i386/winnt.c, config/ia64/ia64-c.c, config/ia64/ia64.c,
config/ip2k/ip2k.c, config/m32r/m32r.c, config/m68hc11/m68hc11.c,
config/m68k/m68k.c, config/mcore/mcore.c, config/mips/mips.c,
config/mmix/mmix.c, config/ns32k/ns32k.c, config/pa/pa-hpux11.h,
config/pa/pa.c, config/rs6000/aix43.h, config/rs6000/aix51.h,
config/rs6000/aix52.h, config/rs6000/darwin.h,
config/rs6000/rs6000-c.c, config/rs6000/rs6000.c,
config/s390/s390.c, config/sh/sh.c, config/sh/sh.h,
config/sh/symbian.c, config/sol2-c.c, config/sol2.c,
config/stormy16/stormy16.c, config/v850/v850-c.c,
config/v850/v850.c, config/xtensa/xtensa.c: Adjust warning()
callers.
* ada/misc.c: Adjust warning() callers.
* cp/call.c, cp/class.c, cp/cvt.c, cp/decl.c, cp/decl2.c,
cp/except.c, cp/friend.c, cp/init.c, cp/lex.c, cp/mangle.c,
cp/method.c, cp/name-lookup.c, cp/parser.c, cp/repo.c, cp/rtti.c,
cp/tree.c, cp/typeck.c, cp/typeck2.c: Adjust warning() callers.
* fortran/trans-decl.c: Adjust warning() callers.
* java/class.c, java/decl.c, java/expr.c, java/jcf-io.c,
java/jcf-parse.c, java/jv-scan.c, java/parse.y: Adjust warning()
callers.
* objc/objc-act.c: Adjust warning() callers.
* treelang/parse.y: Adjust warning() callers.
From-SVN: r98633
2005-04-23 23:29:07 +02:00
|
|
|
|
warning (0, "casting %qT to %qT does not dereference pointer",
|
2003-06-18 17:22:19 +02:00
|
|
|
|
intype, reftype);
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1994-04-08 08:08:43 +02:00
|
|
|
|
rval = build_unary_op (ADDR_EXPR, expr, 0);
|
|
|
|
|
if (rval != error_mark_node)
|
cvt.c, [...]: Clean up more old overloading code, old RTTI code, and some formatting quirks.
* cvt.c, decl.c, decl2.c, init.c, rtti.c, typeck.c, typeck2.c,
cp-tree.h: Clean up more old overloading code, old RTTI code, and
some formatting quirks.
From-SVN: r18391
1998-03-03 23:27:04 +01:00
|
|
|
|
rval = convert_force (build_pointer_type (TREE_TYPE (reftype)),
|
|
|
|
|
rval, 0);
|
1994-04-08 08:08:43 +02:00
|
|
|
|
if (rval != error_mark_node)
|
1994-04-22 01:30:18 +02:00
|
|
|
|
rval = build1 (NOP_EXPR, reftype, rval);
|
1994-04-08 08:08:43 +02:00
|
|
|
|
}
|
call.c, [...]: Remove support for -fno-ansi-overloading and overloading METHOD_CALL_EXPR.
* call.c, class.c, cp-tree.h, cvt.c, decl.c, init.c, lex.c,
method.c, pt.c, ptree.c, typeck.c: Remove support for
-fno-ansi-overloading and overloading METHOD_CALL_EXPR.
* class.h: Remove.
* Makefile.in: Adjust.
From-SVN: r18384
1998-03-03 04:24:44 +01:00
|
|
|
|
else
|
1996-12-18 02:44:21 +01:00
|
|
|
|
{
|
|
|
|
|
rval = convert_for_initialization (NULL_TREE, type, expr, flags,
|
|
|
|
|
"converting", 0, 0);
|
1998-12-18 12:50:30 +01:00
|
|
|
|
if (rval == NULL_TREE || rval == error_mark_node)
|
|
|
|
|
return rval;
|
2000-08-14 12:18:15 +02:00
|
|
|
|
warn_ref_binding (reftype, intype, decl);
|
2001-07-25 17:04:32 +02:00
|
|
|
|
rval = build_up_reference (reftype, rval, flags, decl);
|
1996-12-18 02:44:21 +01:00
|
|
|
|
}
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
if (rval)
|
|
|
|
|
{
|
1996-07-11 03:13:25 +02:00
|
|
|
|
/* If we found a way to convert earlier, then use it. */
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return rval;
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-27 02:15:16 +02:00
|
|
|
|
if (flags & LOOKUP_COMPLAIN)
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("cannot convert type %qT to type %qT", intype, reftype);
|
1995-05-27 02:15:16 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We are using a reference VAL for its value. Bash that reference all the
|
1996-07-11 03:13:25 +02:00
|
|
|
|
way down to its lowest form. */
|
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
convert_from_reference (tree val)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2003-07-03 20:13:44 +02:00
|
|
|
|
if (TREE_CODE (TREE_TYPE (val)) == REFERENCE_TYPE)
|
2004-12-08 09:36:09 +01:00
|
|
|
|
{
|
|
|
|
|
tree t = canonical_type_variant (TREE_TYPE (TREE_TYPE (val)));
|
|
|
|
|
tree ref = build1 (INDIRECT_REF, t, val);
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
2004-12-08 09:36:09 +01:00
|
|
|
|
/* We *must* set TREE_READONLY when dereferencing a pointer to const,
|
|
|
|
|
so that we get the proper error message if the result is used
|
|
|
|
|
to assign to. Also, &* is supposed to be a no-op. */
|
|
|
|
|
TREE_READONLY (ref) = CP_TYPE_CONST_P (t);
|
|
|
|
|
TREE_THIS_VOLATILE (ref) = CP_TYPE_VOLATILE_P (t);
|
|
|
|
|
TREE_SIDE_EFFECTS (ref)
|
|
|
|
|
= (TREE_THIS_VOLATILE (ref) || TREE_SIDE_EFFECTS (val));
|
|
|
|
|
REFERENCE_REF_P (ref) = 1;
|
|
|
|
|
val = ref;
|
|
|
|
|
}
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return val;
|
|
|
|
|
}
|
2003-03-29 01:49:34 +01:00
|
|
|
|
|
|
|
|
|
/* Really perform an lvalue-to-rvalue conversion, including copying an
|
|
|
|
|
argument of class type into a temporary. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
force_rvalue (tree expr)
|
|
|
|
|
{
|
|
|
|
|
if (IS_AGGR_TYPE (TREE_TYPE (expr)) && TREE_CODE (expr) != TARGET_EXPR)
|
|
|
|
|
expr = ocp_convert (TREE_TYPE (expr), expr,
|
|
|
|
|
CONV_IMPLICIT|CONV_FORCE_TEMP, LOOKUP_NORMAL);
|
|
|
|
|
else
|
|
|
|
|
expr = decay_conversion (expr);
|
|
|
|
|
|
|
|
|
|
return expr;
|
|
|
|
|
}
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
1997-05-29 01:20:02 +02:00
|
|
|
|
/* C++ conversions, preference to static cast conversions. */
|
|
|
|
|
|
|
|
|
|
tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
cp_convert (tree type, tree expr)
|
1997-05-29 01:20:02 +02:00
|
|
|
|
{
|
|
|
|
|
return ocp_convert (type, expr, CONV_OLD_CONVERT, LOOKUP_NORMAL);
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-27 02:15:16 +02:00
|
|
|
|
/* Conversion...
|
|
|
|
|
|
|
|
|
|
FLAGS indicates how we should behave. */
|
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
ocp_convert (tree type, tree expr, int convtype, int flags)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2003-12-20 00:28:11 +01:00
|
|
|
|
tree e = expr;
|
|
|
|
|
enum tree_code code = TREE_CODE (type);
|
target.h (invalid_conversion, [...]): New hooks.
* target.h (invalid_conversion, invalid_unary_op,
invalid_binary_op): New hooks.
* target-def.h (TARGET_INVALID_CONVERSION,
TARGET_INVALID_UNARY_OP, TARGET_INVALID_BINARY_OP,
TARGET_INITIALIZER): Likewise.
* hooks.h (hook_constcharptr_tree_tree_null,
hook_constcharptr_int_tree_null,
hook_constcharptr_int_tree_tree_null): New.
* hooks.c (hook_constcharptr_tree_tree_null,
hook_constcharptr_int_tree_null,
hook_constcharptr_int_tree_tree_null): Likewise.
* gcc/doc/tm.texi (TARGET_INVALID_CONVERSION,
TARGET_INVALID_UNARY_OP, TARGET_INVALID_BINARY_OP): Document.
* c-convert.c (convert): Use invalid_conversion hook.
* c-typeck.c (build_unary_op): Use invalid_unary_op hook.
(build_binary_op): Use invalid_binary_op hook.
* config/ia64/ia64-modes.def: Define RFmode.
* config/ia64/ia64-protos.h (spill_xfmode_operand): Remove.
(ia64_expand_movxf_movrf): New.
* config/ia64/ia64.md (movxf): Move code to
ia64_expand_movxf_movrf.
(movrf, movrf_internal): New.
* ia64.c (ia64_invalid_conversion, ia64_invalid_unary_op,
ia64_invalid_binary_op, TARGET_INVALID_CONVERSION,
TARGET_INVALID_UNARY_OP, TARGET_INVALID_BINARY_OP): New.
(spill_xfmode_operand): Rename to spill_xfmode_rfmode_operand.
Add mode parameter. Make static.
(ia64_expand_movxf_movrf): New, moved from ia64.md. Handle RFmode
as well as XFmode.
(ia64_function_arg, ia64_function_value, ia64_register_move_cost,
ia64_scalar_mode_supported_p): Handle RFmode as well as XFmode.
(ia64_init_builtins): Set up __fpreg as RFmode.
(ia64_mangle_fundamental_type): Mangle __fpreg as u7__fpreg.
cp:
* cvt.c (ocp_convert): Use invalid_conversion hook.
* typeck.c (build_binary_op): Use invalid_binary_op hook.
(build_unary_op): Use invalid_unary_op hook.
testsuite:
* g++.dg/ext/fpreg1.C, gcc.target/ia64/fpreg-1.c,
gcc.target/ia64/fpreg-2.c: New tests.
From-SVN: r101391
2005-06-28 23:55:24 +02:00
|
|
|
|
const char *invalid_conv_diag;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
2003-07-23 01:30:22 +02:00
|
|
|
|
if (error_operand_p (e) || type == error_mark_node)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return error_mark_node;
|
1994-05-13 04:46:07 +02:00
|
|
|
|
|
1999-09-13 02:35:00 +02:00
|
|
|
|
complete_type (type);
|
|
|
|
|
complete_type (TREE_TYPE (expr));
|
|
|
|
|
|
target.h (invalid_conversion, [...]): New hooks.
* target.h (invalid_conversion, invalid_unary_op,
invalid_binary_op): New hooks.
* target-def.h (TARGET_INVALID_CONVERSION,
TARGET_INVALID_UNARY_OP, TARGET_INVALID_BINARY_OP,
TARGET_INITIALIZER): Likewise.
* hooks.h (hook_constcharptr_tree_tree_null,
hook_constcharptr_int_tree_null,
hook_constcharptr_int_tree_tree_null): New.
* hooks.c (hook_constcharptr_tree_tree_null,
hook_constcharptr_int_tree_null,
hook_constcharptr_int_tree_tree_null): Likewise.
* gcc/doc/tm.texi (TARGET_INVALID_CONVERSION,
TARGET_INVALID_UNARY_OP, TARGET_INVALID_BINARY_OP): Document.
* c-convert.c (convert): Use invalid_conversion hook.
* c-typeck.c (build_unary_op): Use invalid_unary_op hook.
(build_binary_op): Use invalid_binary_op hook.
* config/ia64/ia64-modes.def: Define RFmode.
* config/ia64/ia64-protos.h (spill_xfmode_operand): Remove.
(ia64_expand_movxf_movrf): New.
* config/ia64/ia64.md (movxf): Move code to
ia64_expand_movxf_movrf.
(movrf, movrf_internal): New.
* ia64.c (ia64_invalid_conversion, ia64_invalid_unary_op,
ia64_invalid_binary_op, TARGET_INVALID_CONVERSION,
TARGET_INVALID_UNARY_OP, TARGET_INVALID_BINARY_OP): New.
(spill_xfmode_operand): Rename to spill_xfmode_rfmode_operand.
Add mode parameter. Make static.
(ia64_expand_movxf_movrf): New, moved from ia64.md. Handle RFmode
as well as XFmode.
(ia64_function_arg, ia64_function_value, ia64_register_move_cost,
ia64_scalar_mode_supported_p): Handle RFmode as well as XFmode.
(ia64_init_builtins): Set up __fpreg as RFmode.
(ia64_mangle_fundamental_type): Mangle __fpreg as u7__fpreg.
cp:
* cvt.c (ocp_convert): Use invalid_conversion hook.
* typeck.c (build_binary_op): Use invalid_binary_op hook.
(build_unary_op): Use invalid_unary_op hook.
testsuite:
* g++.dg/ext/fpreg1.C, gcc.target/ia64/fpreg-1.c,
gcc.target/ia64/fpreg-2.c: New tests.
From-SVN: r101391
2005-06-28 23:55:24 +02:00
|
|
|
|
if ((invalid_conv_diag
|
|
|
|
|
= targetm.invalid_conversion (TREE_TYPE (expr), type)))
|
|
|
|
|
{
|
|
|
|
|
error (invalid_conv_diag);
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-16 12:04:09 +01:00
|
|
|
|
e = integral_constant_value (e);
|
1998-02-04 00:55:27 +01:00
|
|
|
|
|
1998-04-10 05:38:27 +02:00
|
|
|
|
if (IS_AGGR_TYPE (type) && (convtype & CONV_FORCE_TEMP)
|
|
|
|
|
/* Some internal structures (vtable_entry_type, sigtbl_ptr_type)
|
|
|
|
|
don't go through finish_struct, so they don't have the synthesized
|
|
|
|
|
constructors. So don't force a temporary. */
|
|
|
|
|
&& TYPE_HAS_CONSTRUCTOR (type))
|
1995-02-16 16:24:37 +01:00
|
|
|
|
/* We need a new temporary; don't take this shortcut. */;
|
|
|
|
|
else if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e)))
|
1998-10-04 01:11:19 +02:00
|
|
|
|
{
|
1998-11-01 16:45:11 +01:00
|
|
|
|
if (same_type_p (type, TREE_TYPE (e)))
|
1998-10-04 01:11:19 +02:00
|
|
|
|
/* The call to fold will not always remove the NOP_EXPR as
|
|
|
|
|
might be expected, since if one of the types is a typedef;
|
2003-07-05 05:02:05 +02:00
|
|
|
|
the comparison in fold is just equality of pointers, not a
|
1998-10-09 12:32:01 +02:00
|
|
|
|
call to comptypes. We don't call fold in this case because
|
|
|
|
|
that can result in infinite recursion; fold will call
|
|
|
|
|
convert, which will call ocp_convert, etc. */
|
|
|
|
|
return e;
|
2000-04-25 02:11:34 +02:00
|
|
|
|
/* For complex data types, we need to perform componentwise
|
2005-06-15 02:41:35 +02:00
|
|
|
|
conversion. */
|
2000-04-25 02:11:34 +02:00
|
|
|
|
else if (TREE_CODE (type) == COMPLEX_TYPE)
|
2005-06-15 02:41:35 +02:00
|
|
|
|
return fold_if_not_in_template (convert_to_complex (type, e));
|
2003-01-03 21:04:38 +01:00
|
|
|
|
else if (TREE_CODE (e) == TARGET_EXPR)
|
|
|
|
|
{
|
|
|
|
|
/* Don't build a NOP_EXPR of class type. Instead, change the
|
|
|
|
|
type of the temporary. Only allow this for cv-qual changes,
|
|
|
|
|
though. */
|
call.c (check_dtor_name): Replace abort with gcc_assert or gcc_unreachable.
* call.c (check_dtor_name): Replace abort with gcc_assert or
gcc_unreachable.
(build_call, add_builtin_candidate, build_new_op,
convert_like_real, build_over_call, in_charge_arg_for_name,
source_type, joust): Likewise.
* class.c (build_simple_base_path, get_vcall_index,
finish_struct_1, instantiate_type, get_enclosing_class,
add_vcall_offset_vtbl_entries_1, cp_fold_obj_type_ref): Likewise.
* cp-gimplify.c (cp_genericize): Likewise.
* cp-lang.c (cp_expr_size, cp_tree_size): Likewise.
* cvt.c (cp_convert_to_pointer, ocp_convert): Likewise.
* decl.c (poplevel, make_unbound_class_template, reshape_init,
check_special_function_return_type, grokdeclarator,
grok_op_properties, tag_name, xref_tag, start_preparsed_function,
finish_function): Likewise.
* decl2.c (grokfield, maybe_emit_vtables):Likewise.
* error.c (dump_global_iord, dump_decl, dump_template_decl,
language_to_string): Likewise.
* except.c (choose_personality_routine): Likewise.
* friend.c (do_friend): Likewise.
* g++spec.c (lang_specific_driver): Likewise.
* init.c (build_zero_init, expand_default_init, build_new_1,
build_vec_delete_1, build_vec_init, build_dtor_call): Likewise.
* lex.c (retrofit_lang_decl, cp_type_qual_from_rid): Likewise.
* mangle.c (add_substitution, write_unscoped_name,
write_template_prefix, write_identifier,
write_special_name_destructor, write_type, write_builtin_type,
write_expression, write_template_param,
write_java_integer_type_codes): Likewise.
* method.c (implicitly_declare_fn): Likewise.
From-SVN: r86778
2004-08-30 17:28:48 +02:00
|
|
|
|
gcc_assert (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (e)),
|
|
|
|
|
TYPE_MAIN_VARIANT (type)));
|
2003-01-03 21:04:38 +01:00
|
|
|
|
TREE_TYPE (e) = TREE_TYPE (TARGET_EXPR_SLOT (e)) = type;
|
|
|
|
|
return e;
|
|
|
|
|
}
|
1998-10-04 01:11:19 +02:00
|
|
|
|
else
|
call.c (check_dtor_name): Replace abort with gcc_assert or gcc_unreachable.
* call.c (check_dtor_name): Replace abort with gcc_assert or
gcc_unreachable.
(build_call, add_builtin_candidate, build_new_op,
convert_like_real, build_over_call, in_charge_arg_for_name,
source_type, joust): Likewise.
* class.c (build_simple_base_path, get_vcall_index,
finish_struct_1, instantiate_type, get_enclosing_class,
add_vcall_offset_vtbl_entries_1, cp_fold_obj_type_ref): Likewise.
* cp-gimplify.c (cp_genericize): Likewise.
* cp-lang.c (cp_expr_size, cp_tree_size): Likewise.
* cvt.c (cp_convert_to_pointer, ocp_convert): Likewise.
* decl.c (poplevel, make_unbound_class_template, reshape_init,
check_special_function_return_type, grokdeclarator,
grok_op_properties, tag_name, xref_tag, start_preparsed_function,
finish_function): Likewise.
* decl2.c (grokfield, maybe_emit_vtables):Likewise.
* error.c (dump_global_iord, dump_decl, dump_template_decl,
language_to_string): Likewise.
* except.c (choose_personality_routine): Likewise.
* friend.c (do_friend): Likewise.
* g++spec.c (lang_specific_driver): Likewise.
* init.c (build_zero_init, expand_default_init, build_new_1,
build_vec_delete_1, build_vec_init, build_dtor_call): Likewise.
* lex.c (retrofit_lang_decl, cp_type_qual_from_rid): Likewise.
* mangle.c (add_substitution, write_unscoped_name,
write_template_prefix, write_identifier,
write_special_name_destructor, write_type, write_builtin_type,
write_expression, write_template_param,
write_java_integer_type_codes): Likewise.
* method.c (implicitly_declare_fn): Likewise.
From-SVN: r86778
2004-08-30 17:28:48 +02:00
|
|
|
|
{
|
|
|
|
|
/* We shouldn't be treating objects of ADDRESSABLE type as
|
|
|
|
|
rvalues. */
|
|
|
|
|
gcc_assert (!TREE_ADDRESSABLE (type));
|
2004-09-28 04:56:11 +02:00
|
|
|
|
return fold_if_not_in_template (build_nop (type, e));
|
call.c (check_dtor_name): Replace abort with gcc_assert or gcc_unreachable.
* call.c (check_dtor_name): Replace abort with gcc_assert or
gcc_unreachable.
(build_call, add_builtin_candidate, build_new_op,
convert_like_real, build_over_call, in_charge_arg_for_name,
source_type, joust): Likewise.
* class.c (build_simple_base_path, get_vcall_index,
finish_struct_1, instantiate_type, get_enclosing_class,
add_vcall_offset_vtbl_entries_1, cp_fold_obj_type_ref): Likewise.
* cp-gimplify.c (cp_genericize): Likewise.
* cp-lang.c (cp_expr_size, cp_tree_size): Likewise.
* cvt.c (cp_convert_to_pointer, ocp_convert): Likewise.
* decl.c (poplevel, make_unbound_class_template, reshape_init,
check_special_function_return_type, grokdeclarator,
grok_op_properties, tag_name, xref_tag, start_preparsed_function,
finish_function): Likewise.
* decl2.c (grokfield, maybe_emit_vtables):Likewise.
* error.c (dump_global_iord, dump_decl, dump_template_decl,
language_to_string): Likewise.
* except.c (choose_personality_routine): Likewise.
* friend.c (do_friend): Likewise.
* g++spec.c (lang_specific_driver): Likewise.
* init.c (build_zero_init, expand_default_init, build_new_1,
build_vec_delete_1, build_vec_init, build_dtor_call): Likewise.
* lex.c (retrofit_lang_decl, cp_type_qual_from_rid): Likewise.
* mangle.c (add_substitution, write_unscoped_name,
write_template_prefix, write_identifier,
write_special_name_destructor, write_type, write_builtin_type,
write_expression, write_template_param,
write_java_integer_type_codes): Likewise.
* method.c (implicitly_declare_fn): Likewise.
From-SVN: r86778
2004-08-30 17:28:48 +02:00
|
|
|
|
}
|
1998-10-04 01:11:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
1994-05-13 04:46:07 +02:00
|
|
|
|
if (code == VOID_TYPE && (convtype & CONV_STATIC))
|
1998-11-16 06:05:20 +01:00
|
|
|
|
{
|
1999-09-09 14:07:46 +02:00
|
|
|
|
e = convert_to_void (e, /*implicit=*/NULL);
|
1999-02-27 00:37:04 +01:00
|
|
|
|
return e;
|
1998-11-16 06:05:20 +01:00
|
|
|
|
}
|
1994-05-13 04:46:07 +02:00
|
|
|
|
|
1994-05-19 22:19:03 +02:00
|
|
|
|
if (INTEGRAL_CODE_P (code))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
1994-06-15 20:30:58 +02:00
|
|
|
|
tree intype = TREE_TYPE (e);
|
1997-02-04 03:31:49 +01:00
|
|
|
|
/* enum = enum, enum = int, enum = float, (enum)pointer are all
|
2005-06-15 02:41:35 +02:00
|
|
|
|
errors. */
|
1998-08-31 14:54:18 +02:00
|
|
|
|
if (TREE_CODE (type) == ENUMERAL_TYPE
|
2004-11-04 14:07:35 +01:00
|
|
|
|
&& (((INTEGRAL_OR_ENUMERATION_TYPE_P (intype)
|
2005-06-15 02:41:35 +02:00
|
|
|
|
|| TREE_CODE (intype) == REAL_TYPE)
|
2004-11-04 14:07:35 +01:00
|
|
|
|
&& ! (convtype & CONV_STATIC))
|
|
|
|
|
|| TREE_CODE (intype) == POINTER_TYPE))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2004-11-04 14:07:35 +01:00
|
|
|
|
if (flags & LOOKUP_COMPLAIN)
|
|
|
|
|
pedwarn ("conversion from %q#T to %q#T", intype, type);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
if (flag_pedantic_errors)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
1994-08-05 22:25:20 +02:00
|
|
|
|
if (IS_AGGR_TYPE (intype))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
|
|
|
|
tree rval;
|
2003-03-03 22:55:25 +01:00
|
|
|
|
rval = build_type_conversion (type, e);
|
1994-08-18 22:50:43 +02:00
|
|
|
|
if (rval)
|
|
|
|
|
return rval;
|
1995-05-27 02:15:16 +02:00
|
|
|
|
if (flags & LOOKUP_COMPLAIN)
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("%q#T used where a %qT was expected", intype, type);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
1994-05-19 22:19:03 +02:00
|
|
|
|
if (code == BOOLEAN_TYPE)
|
2003-10-13 00:09:29 +02:00
|
|
|
|
return cp_truthvalue_conversion (e);
|
|
|
|
|
|
2004-09-28 04:56:11 +02:00
|
|
|
|
return fold_if_not_in_template (convert_to_integer (type, e));
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
2003-07-23 01:30:22 +02:00
|
|
|
|
if (POINTER_TYPE_P (type) || TYPE_PTR_TO_MEMBER_P (type))
|
2004-09-28 04:56:11 +02:00
|
|
|
|
return fold_if_not_in_template (cp_convert_to_pointer (type, e, false));
|
2001-01-16 18:57:34 +01:00
|
|
|
|
if (code == VECTOR_TYPE)
|
2004-09-23 20:22:25 +02:00
|
|
|
|
{
|
|
|
|
|
tree in_vtype = TREE_TYPE (e);
|
|
|
|
|
if (IS_AGGR_TYPE (in_vtype))
|
|
|
|
|
{
|
|
|
|
|
tree ret_val;
|
|
|
|
|
ret_val = build_type_conversion (type, e);
|
2005-06-15 02:41:35 +02:00
|
|
|
|
if (ret_val)
|
|
|
|
|
return ret_val;
|
|
|
|
|
if (flags & LOOKUP_COMPLAIN)
|
|
|
|
|
error ("%q#T used where a %qT was expected", in_vtype, type);
|
|
|
|
|
return error_mark_node;
|
2004-09-23 20:22:25 +02:00
|
|
|
|
}
|
2004-09-28 04:56:11 +02:00
|
|
|
|
return fold_if_not_in_template (convert_to_vector (type, e));
|
2004-09-23 20:22:25 +02:00
|
|
|
|
}
|
1997-05-29 01:20:02 +02:00
|
|
|
|
if (code == REAL_TYPE || code == COMPLEX_TYPE)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
|
|
|
|
if (IS_AGGR_TYPE (TREE_TYPE (e)))
|
|
|
|
|
{
|
|
|
|
|
tree rval;
|
2003-03-03 22:55:25 +01:00
|
|
|
|
rval = build_type_conversion (type, e);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
if (rval)
|
|
|
|
|
return rval;
|
|
|
|
|
else
|
1995-05-27 02:15:16 +02:00
|
|
|
|
if (flags & LOOKUP_COMPLAIN)
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("%q#T used where a floating point value was expected",
|
1995-05-27 02:15:16 +02:00
|
|
|
|
TREE_TYPE (e));
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
1997-05-29 01:20:02 +02:00
|
|
|
|
if (code == REAL_TYPE)
|
2004-09-28 04:56:11 +02:00
|
|
|
|
return fold_if_not_in_template (convert_to_real (type, e));
|
1997-05-29 01:20:02 +02:00
|
|
|
|
else if (code == COMPLEX_TYPE)
|
2004-09-28 04:56:11 +02:00
|
|
|
|
return fold_if_not_in_template (convert_to_complex (type, e));
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* New C++ semantics: since assignment is now based on
|
|
|
|
|
memberwise copying, if the rhs type is derived from the
|
|
|
|
|
lhs type, then we may still do a conversion. */
|
|
|
|
|
if (IS_AGGR_TYPE_CODE (code))
|
|
|
|
|
{
|
|
|
|
|
tree dtype = TREE_TYPE (e);
|
1994-11-29 01:59:16 +01:00
|
|
|
|
tree ctor = NULL_TREE;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
dtype = TYPE_MAIN_VARIANT (dtype);
|
|
|
|
|
|
|
|
|
|
/* Conversion between aggregate types. New C++ semantics allow
|
|
|
|
|
objects of derived type to be cast to objects of base type.
|
|
|
|
|
Old semantics only allowed this between pointers.
|
|
|
|
|
|
|
|
|
|
There may be some ambiguity between using a constructor
|
|
|
|
|
vs. using a type conversion operator when both apply. */
|
|
|
|
|
|
call.c, [...]: Remove support for -fno-ansi-overloading and overloading METHOD_CALL_EXPR.
* call.c, class.c, cp-tree.h, cvt.c, decl.c, init.c, lex.c,
method.c, pt.c, ptree.c, typeck.c: Remove support for
-fno-ansi-overloading and overloading METHOD_CALL_EXPR.
* class.h: Remove.
* Makefile.in: Adjust.
From-SVN: r18384
1998-03-03 04:24:44 +01:00
|
|
|
|
ctor = e;
|
1996-12-18 02:44:21 +01:00
|
|
|
|
|
1999-07-26 10:18:19 +02:00
|
|
|
|
if (abstract_virtuals_error (NULL_TREE, type))
|
|
|
|
|
return error_mark_node;
|
1998-11-18 13:27:30 +01:00
|
|
|
|
|
call.c, [...]: Remove support for -fno-ansi-overloading and overloading METHOD_CALL_EXPR.
* call.c, class.c, cp-tree.h, cvt.c, decl.c, init.c, lex.c,
method.c, pt.c, ptree.c, typeck.c: Remove support for
-fno-ansi-overloading and overloading METHOD_CALL_EXPR.
* class.h: Remove.
* Makefile.in: Adjust.
From-SVN: r18384
1998-03-03 04:24:44 +01:00
|
|
|
|
if ((flags & LOOKUP_ONLYCONVERTING)
|
|
|
|
|
&& ! (IS_AGGR_TYPE (dtype) && DERIVED_FROM_P (type, dtype)))
|
1998-05-23 01:13:28 +02:00
|
|
|
|
/* For copy-initialization, first we create a temp of the proper type
|
|
|
|
|
with a user-defined conversion sequence, then we direct-initialize
|
|
|
|
|
the target with the temp (see [dcl.init]). */
|
|
|
|
|
ctor = build_user_type_conversion (type, ctor, flags);
|
2000-12-09 19:34:12 +01:00
|
|
|
|
else
|
2005-06-14 22:01:59 +02:00
|
|
|
|
ctor = build_special_member_call (NULL_TREE,
|
2002-08-01 06:46:23 +02:00
|
|
|
|
complete_ctor_identifier,
|
|
|
|
|
build_tree_list (NULL_TREE, ctor),
|
2004-07-12 18:06:40 +02:00
|
|
|
|
type, flags);
|
call.c, [...]: Remove support for -fno-ansi-overloading and overloading METHOD_CALL_EXPR.
* call.c, class.c, cp-tree.h, cvt.c, decl.c, init.c, lex.c,
method.c, pt.c, ptree.c, typeck.c: Remove support for
-fno-ansi-overloading and overloading METHOD_CALL_EXPR.
* class.h: Remove.
* Makefile.in: Adjust.
From-SVN: r18384
1998-03-03 04:24:44 +01:00
|
|
|
|
if (ctor)
|
|
|
|
|
return build_cplus_new (type, ctor);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-27 02:15:16 +02:00
|
|
|
|
if (flags & LOOKUP_COMPLAIN)
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("conversion from %qT to non-scalar type %qT requested",
|
2005-06-15 02:41:35 +02:00
|
|
|
|
TREE_TYPE (expr), type);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-09 14:07:46 +02:00
|
|
|
|
/* When an expression is used in a void context, its value is discarded and
|
|
|
|
|
no lvalue-rvalue and similar conversions happen [expr.static.cast/4,
|
|
|
|
|
stmt.expr/1, expr.comma/1]. This permits dereferencing an incomplete type
|
|
|
|
|
in a void context. The C++ standard does not define what an `access' to an
|
2003-10-21 04:16:17 +02:00
|
|
|
|
object is, but there is reason to believe that it is the lvalue to rvalue
|
1999-09-09 14:07:46 +02:00
|
|
|
|
conversion -- if it were not, `*&*p = 1' would violate [expr]/4 in that it
|
|
|
|
|
accesses `*p' not to calculate the value to be stored. But, dcl.type.cv/8
|
|
|
|
|
indicates that volatile semantics should be the same between C and C++
|
|
|
|
|
where ever possible. C leaves it implementation defined as to what
|
|
|
|
|
constitutes an access to a volatile. So, we interpret `*vp' as a read of
|
|
|
|
|
the volatile object `vp' points to, unless that is an incomplete type. For
|
|
|
|
|
volatile references we do not do this interpretation, because that would
|
|
|
|
|
make it impossible to ignore the reference return value from functions. We
|
|
|
|
|
issue warnings in the confusing cases.
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1999-09-09 14:07:46 +02:00
|
|
|
|
IMPLICIT is tells us the context of an implicit void conversion. */
|
|
|
|
|
|
|
|
|
|
tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
convert_to_void (tree expr, const char *implicit)
|
1999-09-09 14:07:46 +02:00
|
|
|
|
{
|
2005-06-14 22:01:59 +02:00
|
|
|
|
if (expr == error_mark_node
|
2000-01-13 00:27:46 +01:00
|
|
|
|
|| TREE_TYPE (expr) == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
1999-09-09 14:07:46 +02:00
|
|
|
|
if (!TREE_TYPE (expr))
|
|
|
|
|
return expr;
|
2004-05-31 23:24:31 +02:00
|
|
|
|
if (invalid_nonstatic_memfn_p (expr))
|
|
|
|
|
return error_mark_node;
|
2005-02-09 03:53:41 +01:00
|
|
|
|
if (TREE_CODE (expr) == PSEUDO_DTOR_EXPR)
|
|
|
|
|
{
|
|
|
|
|
error ("pseudo-destructor is not called");
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
2000-06-20 17:42:55 +02:00
|
|
|
|
if (VOID_TYPE_P (TREE_TYPE (expr)))
|
1999-09-09 14:07:46 +02:00
|
|
|
|
return expr;
|
|
|
|
|
switch (TREE_CODE (expr))
|
|
|
|
|
{
|
|
|
|
|
case COND_EXPR:
|
|
|
|
|
{
|
2005-06-15 02:41:35 +02:00
|
|
|
|
/* The two parts of a cond expr might be separate lvalues. */
|
|
|
|
|
tree op1 = TREE_OPERAND (expr,1);
|
|
|
|
|
tree op2 = TREE_OPERAND (expr,2);
|
|
|
|
|
tree new_op1 = convert_to_void
|
2003-08-16 15:32:11 +02:00
|
|
|
|
(op1, (implicit && !TREE_SIDE_EFFECTS (op2)
|
|
|
|
|
? "second operand of conditional" : NULL));
|
2005-06-15 02:41:35 +02:00
|
|
|
|
tree new_op2 = convert_to_void
|
2003-08-16 15:32:11 +02:00
|
|
|
|
(op2, (implicit && !TREE_SIDE_EFFECTS (op1)
|
|
|
|
|
? "third operand of conditional" : NULL));
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
call.c (build_vfield_ref, [...]): Replace calls to build with calls to buildN.
* call.c (build_vfield_ref, build_call, build_conditional_expr,
convert_arg_to_ellipsis, build_x_va_arg, build_over_call,
build_java_interface_fn_ref, build_special_member_call,
build_new_method_call, initialize_reference): Replace calls to
build with calls to buildN.
* class.c (build_base_path, convert_to_base_statically,
build_vfn_ref, instantiate_type, dfs_accumulate_vtbl_inits,
build_vtbl_initializer): Likewise.
* cp-gimplify.c (genericize_try_block, genericize_catch_block,
gimplify_if_stmt, cp_genericize_r): Likewise.
* cvt.c (convert_to_void): Likewise.
* decl.c (check_initializer, finish_constructor_body,
finish_destructor_body): Likewise.
* error.c (dump_expr): Likewise.
* except.c (build_exc_ptr, expand_start_catch_block, build_throw):
Likewise.
* init.c (perform_member_init, expand_virtual_init,
expand_cleanup_for_base, build_init, expand_default_init,
build_offset_ref, decl_constant_value, build_new, build_new_1,
build_vec_delete_1, build_vec_init, build_delete,
push_base_cleanups, build_vec_delete): Likewise.
* mangle.c (write_integer_cst): Likewise.
* method.c (thunk_adjust, do_build_copy_constructor,
do_build_assign_ref): Likewise.
* pt.c (lookup_template_function, tsubst, tsubst_copy_and_build,
unify, build_non_dependent_expr): Likewise.
* rtti.c (build_headof, build_typeid, ifnonnull,
build_dyanmic_cast_1, tinfo_base_init): Likewise.
* semantics.c (begin_compound_stmt, finish_call_expr,
finish_pseudo_destructor_expr, finish_id_expression,
simplify_aggr_init_expr, finalize_nrv_r): Likewise.
* tree.c (build_target_expr, build_cplus_new, array_type_nelts_top,
array_type_nelts_total, stabilize_call): Likewise.
* typeck.c (decay_conversion, build_class_member_access_expr,
lookup_destructor, build_ptrmemfunc_access_expr, build_array_ref,
get_member_function_from_ptrfunc, build_binary_op, pointer_diff,
build_x_unary_op, build_unary_op, unary_complex_lvalue,
build_compound_expr, build_modify_expr, expand_ptrmemfunc_cst,
check_return_expr): Likewise.
* typeck2.c (split_nonconstant_1, split_nonconstant_init_1,
split_nonconstant_init, store_init_value, build_m_component_ref):
Likewise.
From-SVN: r86047
2004-08-16 04:08:06 +02:00
|
|
|
|
expr = build3 (COND_EXPR, TREE_TYPE (new_op1),
|
|
|
|
|
TREE_OPERAND (expr, 0), new_op1, new_op2);
|
2005-06-15 02:41:35 +02:00
|
|
|
|
break;
|
1999-09-09 14:07:46 +02:00
|
|
|
|
}
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1999-09-09 14:07:46 +02:00
|
|
|
|
case COMPOUND_EXPR:
|
|
|
|
|
{
|
2005-06-15 02:41:35 +02:00
|
|
|
|
/* The second part of a compound expr contains the value. */
|
|
|
|
|
tree op1 = TREE_OPERAND (expr,1);
|
|
|
|
|
tree new_op1 = convert_to_void
|
2004-05-13 08:41:07 +02:00
|
|
|
|
(op1, (implicit && !TREE_NO_WARNING (expr)
|
2003-12-20 04:21:25 +01:00
|
|
|
|
? "right-hand operand of comma" : NULL));
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
2005-06-15 02:41:35 +02:00
|
|
|
|
if (new_op1 != op1)
|
2001-08-17 06:32:09 +02:00
|
|
|
|
{
|
call.c (build_vfield_ref, [...]): Replace calls to build with calls to buildN.
* call.c (build_vfield_ref, build_call, build_conditional_expr,
convert_arg_to_ellipsis, build_x_va_arg, build_over_call,
build_java_interface_fn_ref, build_special_member_call,
build_new_method_call, initialize_reference): Replace calls to
build with calls to buildN.
* class.c (build_base_path, convert_to_base_statically,
build_vfn_ref, instantiate_type, dfs_accumulate_vtbl_inits,
build_vtbl_initializer): Likewise.
* cp-gimplify.c (genericize_try_block, genericize_catch_block,
gimplify_if_stmt, cp_genericize_r): Likewise.
* cvt.c (convert_to_void): Likewise.
* decl.c (check_initializer, finish_constructor_body,
finish_destructor_body): Likewise.
* error.c (dump_expr): Likewise.
* except.c (build_exc_ptr, expand_start_catch_block, build_throw):
Likewise.
* init.c (perform_member_init, expand_virtual_init,
expand_cleanup_for_base, build_init, expand_default_init,
build_offset_ref, decl_constant_value, build_new, build_new_1,
build_vec_delete_1, build_vec_init, build_delete,
push_base_cleanups, build_vec_delete): Likewise.
* mangle.c (write_integer_cst): Likewise.
* method.c (thunk_adjust, do_build_copy_constructor,
do_build_assign_ref): Likewise.
* pt.c (lookup_template_function, tsubst, tsubst_copy_and_build,
unify, build_non_dependent_expr): Likewise.
* rtti.c (build_headof, build_typeid, ifnonnull,
build_dyanmic_cast_1, tinfo_base_init): Likewise.
* semantics.c (begin_compound_stmt, finish_call_expr,
finish_pseudo_destructor_expr, finish_id_expression,
simplify_aggr_init_expr, finalize_nrv_r): Likewise.
* tree.c (build_target_expr, build_cplus_new, array_type_nelts_top,
array_type_nelts_total, stabilize_call): Likewise.
* typeck.c (decay_conversion, build_class_member_access_expr,
lookup_destructor, build_ptrmemfunc_access_expr, build_array_ref,
get_member_function_from_ptrfunc, build_binary_op, pointer_diff,
build_x_unary_op, build_unary_op, unary_complex_lvalue,
build_compound_expr, build_modify_expr, expand_ptrmemfunc_cst,
check_return_expr): Likewise.
* typeck2.c (split_nonconstant_1, split_nonconstant_init_1,
split_nonconstant_init, store_init_value, build_m_component_ref):
Likewise.
From-SVN: r86047
2004-08-16 04:08:06 +02:00
|
|
|
|
tree t = build2 (COMPOUND_EXPR, TREE_TYPE (new_op1),
|
|
|
|
|
TREE_OPERAND (expr, 0), new_op1);
|
2001-08-17 06:32:09 +02:00
|
|
|
|
expr = t;
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-15 02:41:35 +02:00
|
|
|
|
break;
|
1999-09-09 14:07:46 +02:00
|
|
|
|
}
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1999-09-09 14:07:46 +02:00
|
|
|
|
case NON_LVALUE_EXPR:
|
|
|
|
|
case NOP_EXPR:
|
2002-09-13 02:22:59 +02:00
|
|
|
|
/* These have already decayed to rvalue. */
|
1999-09-09 14:07:46 +02:00
|
|
|
|
break;
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
2003-12-21 22:07:32 +01:00
|
|
|
|
case CALL_EXPR: /* We have a special meaning for volatile void fn(). */
|
1999-09-09 14:07:46 +02:00
|
|
|
|
break;
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1999-09-09 14:07:46 +02:00
|
|
|
|
case INDIRECT_REF:
|
|
|
|
|
{
|
2005-06-15 02:41:35 +02:00
|
|
|
|
tree type = TREE_TYPE (expr);
|
|
|
|
|
int is_reference = TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0)))
|
|
|
|
|
== REFERENCE_TYPE;
|
|
|
|
|
int is_volatile = TYPE_VOLATILE (type);
|
|
|
|
|
int is_complete = COMPLETE_TYPE_P (complete_type (type));
|
|
|
|
|
|
2006-08-29 08:55:03 +02:00
|
|
|
|
/* Can't load the value if we don't know the type. */
|
2005-06-15 02:41:35 +02:00
|
|
|
|
if (is_volatile && !is_complete)
|
|
|
|
|
warning (0, "object of incomplete type %qT will not be accessed in %s",
|
|
|
|
|
type, implicit ? implicit : "void context");
|
2006-08-29 08:55:03 +02:00
|
|
|
|
/* Don't load the value if this is an implicit dereference, or if
|
|
|
|
|
the type needs to be handled by ctors/dtors. */
|
|
|
|
|
else if (is_volatile && (is_reference || TREE_ADDRESSABLE (type)))
|
2005-06-15 02:41:35 +02:00
|
|
|
|
warning (0, "object of type %qT will not be accessed in %s",
|
|
|
|
|
TREE_TYPE (TREE_OPERAND (expr, 0)),
|
|
|
|
|
implicit ? implicit : "void context");
|
2006-08-29 08:55:03 +02:00
|
|
|
|
if (is_reference || !is_volatile || !is_complete || TREE_ADDRESSABLE (type))
|
2005-06-15 02:41:35 +02:00
|
|
|
|
expr = TREE_OPERAND (expr, 0);
|
|
|
|
|
|
|
|
|
|
break;
|
1999-09-09 14:07:46 +02:00
|
|
|
|
}
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1999-09-09 14:07:46 +02:00
|
|
|
|
case VAR_DECL:
|
|
|
|
|
{
|
2005-06-15 02:41:35 +02:00
|
|
|
|
/* External variables might be incomplete. */
|
|
|
|
|
tree type = TREE_TYPE (expr);
|
|
|
|
|
int is_complete = COMPLETE_TYPE_P (complete_type (type));
|
|
|
|
|
|
|
|
|
|
if (TYPE_VOLATILE (type) && !is_complete)
|
|
|
|
|
warning (0, "object %qE of incomplete type %qT will not be accessed in %s",
|
|
|
|
|
expr, type, implicit ? implicit : "void context");
|
|
|
|
|
break;
|
1999-09-09 14:07:46 +02:00
|
|
|
|
}
|
2000-04-11 02:38:39 +02:00
|
|
|
|
|
2006-09-07 03:12:00 +02:00
|
|
|
|
case TARGET_EXPR:
|
|
|
|
|
/* Don't bother with the temporary object returned from a function if
|
|
|
|
|
we don't use it and don't need to destroy it. We'll still
|
|
|
|
|
allocate space for it in expand_call or declare_return_variable,
|
|
|
|
|
but we don't need to track it through all the tree phases. */
|
2006-09-08 00:47:34 +02:00
|
|
|
|
if (TARGET_EXPR_IMPLICIT_P (expr)
|
2006-09-07 03:12:00 +02:00
|
|
|
|
&& TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (expr)))
|
|
|
|
|
{
|
|
|
|
|
tree init = TARGET_EXPR_INITIAL (expr);
|
|
|
|
|
if (TREE_CODE (init) == AGGR_INIT_EXPR
|
|
|
|
|
&& !AGGR_INIT_VIA_CTOR_P (init))
|
|
|
|
|
{
|
|
|
|
|
tree fn = TREE_OPERAND (init, 0);
|
|
|
|
|
expr = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))),
|
|
|
|
|
fn, TREE_OPERAND (init, 1), NULL_TREE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
1999-09-09 14:07:46 +02:00
|
|
|
|
default:;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
tree probe = expr;
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1999-09-09 14:07:46 +02:00
|
|
|
|
if (TREE_CODE (probe) == ADDR_EXPR)
|
|
|
|
|
probe = TREE_OPERAND (expr, 0);
|
2001-01-02 20:48:02 +01:00
|
|
|
|
if (type_unknown_p (probe))
|
|
|
|
|
{
|
|
|
|
|
/* [over.over] enumerates the places where we can take the address
|
|
|
|
|
of an overloaded function, and this is not one of them. */
|
cp-tree.h: Delete #defines for cp_error, cp_warning, cp_pedwarn, and cp_compiler_error.
* cp-tree.h: Delete #defines for cp_error, cp_warning,
cp_pedwarn, and cp_compiler_error.
* call.c, class.c, cp-tree.h, cvt.c, decl.c, decl2.c, error.c,
except.c, friend.c, init.c, lex.c, method.c, parse.y, pt.c,
rtti.c, search.c, semantics.c, spew.c, tree.c, typeck.c,
typeck2.c: Change calls to the above macros to use their
language-independent equivalents: error, warning, pedwarn, and
internal_error respectively.
From-SVN: r48140
2001-12-18 04:35:42 +01:00
|
|
|
|
pedwarn ("%s cannot resolve address of overloaded function",
|
2001-01-02 20:48:02 +01:00
|
|
|
|
implicit ? implicit : "void cast");
|
2003-11-10 23:02:36 +01:00
|
|
|
|
expr = void_zero_node;
|
2001-01-02 20:48:02 +01:00
|
|
|
|
}
|
|
|
|
|
else if (implicit && probe == expr && is_overloaded_fn (probe))
|
2006-09-10 00:26:53 +02:00
|
|
|
|
{
|
|
|
|
|
/* Only warn when there is no &. */
|
|
|
|
|
warning (0, "%s is a reference, not call, to function %qE",
|
|
|
|
|
implicit, expr);
|
|
|
|
|
if (TREE_CODE (expr) == COMPONENT_REF)
|
|
|
|
|
expr = TREE_OPERAND (expr, 0);
|
|
|
|
|
}
|
1999-09-09 14:07:46 +02:00
|
|
|
|
}
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
2000-06-20 17:42:55 +02:00
|
|
|
|
if (expr != error_mark_node && !VOID_TYPE_P (TREE_TYPE (expr)))
|
1999-09-09 14:07:46 +02:00
|
|
|
|
{
|
2005-10-12 01:30:57 +02:00
|
|
|
|
if (implicit
|
|
|
|
|
&& warn_unused_value
|
|
|
|
|
&& !TREE_NO_WARNING (expr)
|
|
|
|
|
&& !processing_template_decl)
|
2004-12-22 19:00:39 +01:00
|
|
|
|
{
|
|
|
|
|
/* The middle end does not warn about expressions that have
|
|
|
|
|
been explicitly cast to void, so we must do so here. */
|
|
|
|
|
if (!TREE_SIDE_EFFECTS (expr))
|
2006-02-04 00:11:09 +01:00
|
|
|
|
warning (OPT_Wunused_value, "%s has no effect", implicit);
|
2005-06-14 22:01:59 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2004-12-22 19:00:39 +01:00
|
|
|
|
tree e;
|
|
|
|
|
enum tree_code code;
|
|
|
|
|
enum tree_code_class class;
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
2004-12-22 19:00:39 +01:00
|
|
|
|
e = expr;
|
|
|
|
|
/* We might like to warn about (say) "(int) f()", as the
|
|
|
|
|
cast has no effect, but the compiler itself will
|
|
|
|
|
generate implicit conversions under some
|
2004-12-23 17:31:16 +01:00
|
|
|
|
circumstances. (For example a block copy will be
|
2004-12-22 19:00:39 +01:00
|
|
|
|
turned into a call to "__builtin_memcpy", with a
|
|
|
|
|
conversion of the return value to an appropriate
|
|
|
|
|
type.) So, to avoid false positives, we strip
|
2004-12-30 01:31:00 +01:00
|
|
|
|
conversions. Do not use STRIP_NOPs because it will
|
|
|
|
|
not strip conversions to "void", as that is not a
|
|
|
|
|
mode-preserving conversion. */
|
|
|
|
|
while (TREE_CODE (e) == NOP_EXPR)
|
|
|
|
|
e = TREE_OPERAND (e, 0);
|
2004-12-22 19:00:39 +01:00
|
|
|
|
|
|
|
|
|
code = TREE_CODE (e);
|
|
|
|
|
class = TREE_CODE_CLASS (code);
|
|
|
|
|
if (class == tcc_comparison
|
|
|
|
|
|| class == tcc_unary
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|| (class == tcc_binary
|
2004-12-22 19:00:39 +01:00
|
|
|
|
&& !(code == MODIFY_EXPR
|
|
|
|
|
|| code == INIT_EXPR
|
|
|
|
|
|| code == PREDECREMENT_EXPR
|
|
|
|
|
|| code == PREINCREMENT_EXPR
|
|
|
|
|
|| code == POSTDECREMENT_EXPR
|
|
|
|
|
|| code == POSTINCREMENT_EXPR)))
|
2006-02-04 00:11:09 +01:00
|
|
|
|
warning (OPT_Wunused_value, "value computed is not used");
|
2004-12-22 19:00:39 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-08-16 15:32:11 +02:00
|
|
|
|
expr = build1 (CONVERT_EXPR, void_type_node, expr);
|
1999-09-09 14:07:46 +02:00
|
|
|
|
}
|
2006-09-06 19:06:00 +02:00
|
|
|
|
if (! TREE_SIDE_EFFECTS (expr))
|
|
|
|
|
expr = void_zero_node;
|
1999-09-09 14:07:46 +02:00
|
|
|
|
return expr;
|
|
|
|
|
}
|
|
|
|
|
|
1994-05-13 04:46:07 +02:00
|
|
|
|
/* Create an expression whose value is that of EXPR,
|
|
|
|
|
converted to type TYPE. The TREE_TYPE of the value
|
|
|
|
|
is always TYPE. This function implements all reasonable
|
|
|
|
|
conversions; callers should filter out those that are
|
1997-05-29 01:20:02 +02:00
|
|
|
|
not permitted by the language being compiled.
|
|
|
|
|
|
|
|
|
|
Most of this routine is from build_reinterpret_cast.
|
|
|
|
|
|
|
|
|
|
The backend cannot call cp_convert (what was convert) because
|
|
|
|
|
conversions to/from basetypes may involve memory references
|
|
|
|
|
(vbases) and adding or subtracting small values (multiple
|
|
|
|
|
inheritance), but it calls convert from the constant folding code
|
2000-12-14 20:30:43 +01:00
|
|
|
|
on subtrees of already built trees after it has ripped them apart.
|
1997-05-29 01:20:02 +02:00
|
|
|
|
|
|
|
|
|
Also, if we ever support range variables, we'll probably also have to
|
|
|
|
|
do a little bit more work. */
|
1994-05-13 04:46:07 +02:00
|
|
|
|
|
|
|
|
|
tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
convert (tree type, tree expr)
|
1994-05-13 04:46:07 +02:00
|
|
|
|
{
|
1997-05-29 01:20:02 +02:00
|
|
|
|
tree intype;
|
|
|
|
|
|
|
|
|
|
if (type == error_mark_node || expr == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
|
|
|
|
|
intype = TREE_TYPE (expr);
|
|
|
|
|
|
1997-06-18 04:25:37 +02:00
|
|
|
|
if (POINTER_TYPE_P (type) && POINTER_TYPE_P (intype))
|
2004-12-16 12:04:09 +01:00
|
|
|
|
return fold_if_not_in_template (build_nop (type, expr));
|
1997-05-29 01:20:02 +02:00
|
|
|
|
|
|
|
|
|
return ocp_convert (type, expr, CONV_OLD_CONVERT,
|
|
|
|
|
LOOKUP_NORMAL|LOOKUP_NO_CONVERSION);
|
1994-05-13 04:46:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
1997-05-29 01:20:02 +02:00
|
|
|
|
/* Like cp_convert, except permit conversions to take place which
|
1994-02-24 02:02:37 +01:00
|
|
|
|
are not normally allowed due to access restrictions
|
|
|
|
|
(such as conversion from sub-type to private super-type). */
|
1996-07-11 03:13:25 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
convert_force (tree type, tree expr, int convtype)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
2003-12-20 00:28:11 +01:00
|
|
|
|
tree e = expr;
|
|
|
|
|
enum tree_code code = TREE_CODE (type);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
if (code == REFERENCE_TYPE)
|
2005-06-14 22:01:59 +02:00
|
|
|
|
return (fold_if_not_in_template
|
2004-09-28 04:56:11 +02:00
|
|
|
|
(convert_to_reference (type, e, CONV_C_CAST, LOOKUP_COMPLAIN,
|
|
|
|
|
NULL_TREE)));
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
if (code == POINTER_TYPE)
|
2004-09-28 04:56:11 +02:00
|
|
|
|
return fold_if_not_in_template (convert_to_pointer_force (type, e));
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
1994-03-24 00:33:53 +01:00
|
|
|
|
/* From typeck.c convert_for_assignment */
|
1994-02-24 02:02:37 +01:00
|
|
|
|
if (((TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE && TREE_CODE (e) == ADDR_EXPR
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (TREE_TYPE (e))) == METHOD_TYPE)
|
1994-03-24 00:33:53 +01:00
|
|
|
|
|| integer_zerop (e)
|
|
|
|
|
|| TYPE_PTRMEMFUNC_P (TREE_TYPE (e)))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
&& TYPE_PTRMEMFUNC_P (type))
|
2004-10-21 23:23:42 +02:00
|
|
|
|
/* compatible pointer to member functions. */
|
|
|
|
|
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), e, 1,
|
|
|
|
|
/*c_cast_p=*/1);
|
1994-12-16 03:07:31 +01:00
|
|
|
|
|
1997-05-29 01:20:02 +02:00
|
|
|
|
return ocp_convert (type, e, CONV_C_CAST|convtype, LOOKUP_NORMAL);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Convert an aggregate EXPR to type XTYPE. If a conversion
|
|
|
|
|
exists, return the attempted conversion. This may
|
|
|
|
|
return ERROR_MARK_NODE if the conversion is not
|
|
|
|
|
allowed (references private members, etc).
|
|
|
|
|
If no conversion exists, NULL_TREE is returned.
|
|
|
|
|
|
1995-10-12 03:33:51 +01:00
|
|
|
|
FIXME: Ambiguity checking is wrong. Should choose one by the implicit
|
|
|
|
|
object parameter, or by the second standard conversion sequence if
|
|
|
|
|
that doesn't do it. This will probably wait for an overloading rewrite.
|
|
|
|
|
(jason 8/9/95) */
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
2006-02-13 23:37:02 +01:00
|
|
|
|
static tree
|
2003-03-03 22:55:25 +01:00
|
|
|
|
build_type_conversion (tree xtype, tree expr)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
|
|
|
|
/* C++: check to see if we can convert this aggregate type
|
1995-01-24 09:19:58 +01:00
|
|
|
|
into the required type. */
|
2003-03-03 22:55:25 +01:00
|
|
|
|
return build_user_type_conversion (xtype, expr, LOOKUP_NORMAL);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
1995-03-16 00:03:59 +01:00
|
|
|
|
/* Convert the given EXPR to one of a group of types suitable for use in an
|
|
|
|
|
expression. DESIRES is a combination of various WANT_* flags (q.v.)
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
which indicates which types are suitable. If COMPLAIN is true, complain
|
1995-03-16 00:03:59 +01:00
|
|
|
|
about ambiguity; otherwise, the caller will deal with it. */
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
1995-03-16 00:03:59 +01:00
|
|
|
|
tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
build_expr_type_conversion (int desires, tree expr, bool complain)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
1995-03-16 00:03:59 +01:00
|
|
|
|
tree basetype = TREE_TYPE (expr);
|
1998-09-25 11:00:04 +02:00
|
|
|
|
tree conv = NULL_TREE;
|
1998-06-10 05:13:19 +02:00
|
|
|
|
tree winner = NULL_TREE;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
2005-06-14 22:01:59 +02:00
|
|
|
|
if (expr == null_node
|
|
|
|
|
&& (desires & WANT_INT)
|
1998-08-23 14:47:24 +02:00
|
|
|
|
&& !(desires & WANT_NULL))
|
2006-01-18 01:15:37 +01:00
|
|
|
|
warning (OPT_Wconversion, "converting NULL to non-pointer type");
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1995-10-12 03:33:51 +01:00
|
|
|
|
basetype = TREE_TYPE (expr);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
2000-01-13 00:27:46 +01:00
|
|
|
|
if (basetype == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
|
1998-06-10 05:13:19 +02:00
|
|
|
|
if (! IS_AGGR_TYPE (basetype))
|
|
|
|
|
switch (TREE_CODE (basetype))
|
|
|
|
|
{
|
|
|
|
|
case INTEGER_TYPE:
|
1998-08-23 14:47:24 +02:00
|
|
|
|
if ((desires & WANT_NULL) && null_ptr_cst_p (expr))
|
1998-06-10 05:13:19 +02:00
|
|
|
|
return expr;
|
|
|
|
|
/* else fall through... */
|
|
|
|
|
|
|
|
|
|
case BOOLEAN_TYPE:
|
|
|
|
|
return (desires & WANT_INT) ? expr : NULL_TREE;
|
|
|
|
|
case ENUMERAL_TYPE:
|
|
|
|
|
return (desires & WANT_ENUM) ? expr : NULL_TREE;
|
|
|
|
|
case REAL_TYPE:
|
|
|
|
|
return (desires & WANT_FLOAT) ? expr : NULL_TREE;
|
|
|
|
|
case POINTER_TYPE:
|
|
|
|
|
return (desires & WANT_POINTER) ? expr : NULL_TREE;
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
1998-06-10 05:13:19 +02:00
|
|
|
|
case FUNCTION_TYPE:
|
|
|
|
|
case ARRAY_TYPE:
|
2003-07-06 05:30:57 +02:00
|
|
|
|
return (desires & WANT_POINTER) ? decay_conversion (expr)
|
2005-06-15 02:41:35 +02:00
|
|
|
|
: NULL_TREE;
|
2006-11-21 10:41:27 +01:00
|
|
|
|
|
|
|
|
|
case VECTOR_TYPE:
|
|
|
|
|
if ((desires & WANT_VECTOR) == 0)
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
switch (TREE_CODE (TREE_TYPE (basetype)))
|
|
|
|
|
{
|
|
|
|
|
case INTEGER_TYPE:
|
|
|
|
|
case BOOLEAN_TYPE:
|
|
|
|
|
return (desires & WANT_INT) ? expr : NULL_TREE;
|
|
|
|
|
case ENUMERAL_TYPE:
|
|
|
|
|
return (desires & WANT_ENUM) ? expr : NULL_TREE;
|
|
|
|
|
case REAL_TYPE:
|
|
|
|
|
return (desires & WANT_FLOAT) ? expr : NULL_TREE;
|
|
|
|
|
default:
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-10 05:13:19 +02:00
|
|
|
|
default:
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The code for conversions from class type is currently only used for
|
|
|
|
|
delete expressions. Other expressions are handled by build_new_op. */
|
2004-02-23 13:40:59 +01:00
|
|
|
|
if (!complete_type_or_else (basetype, expr))
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
if (!TYPE_HAS_CONVERSION (basetype))
|
1998-06-10 05:13:19 +02:00
|
|
|
|
return NULL_TREE;
|
|
|
|
|
|
|
|
|
|
for (conv = lookup_conversions (basetype); conv; conv = TREE_CHAIN (conv))
|
|
|
|
|
{
|
|
|
|
|
int win = 0;
|
|
|
|
|
tree candidate;
|
|
|
|
|
tree cand = TREE_VALUE (conv);
|
|
|
|
|
|
|
|
|
|
if (winner && winner == cand)
|
|
|
|
|
continue;
|
|
|
|
|
|
2003-07-08 03:38:44 +02:00
|
|
|
|
candidate = non_reference (TREE_TYPE (TREE_TYPE (cand)));
|
1998-06-10 05:13:19 +02:00
|
|
|
|
|
|
|
|
|
switch (TREE_CODE (candidate))
|
|
|
|
|
{
|
|
|
|
|
case BOOLEAN_TYPE:
|
|
|
|
|
case INTEGER_TYPE:
|
|
|
|
|
win = (desires & WANT_INT); break;
|
|
|
|
|
case ENUMERAL_TYPE:
|
|
|
|
|
win = (desires & WANT_ENUM); break;
|
|
|
|
|
case REAL_TYPE:
|
|
|
|
|
win = (desires & WANT_FLOAT); break;
|
|
|
|
|
case POINTER_TYPE:
|
|
|
|
|
win = (desires & WANT_POINTER); break;
|
|
|
|
|
|
2006-11-21 10:41:27 +01:00
|
|
|
|
case VECTOR_TYPE:
|
|
|
|
|
if ((desires & WANT_VECTOR) == 0)
|
|
|
|
|
break;
|
|
|
|
|
switch (TREE_CODE (TREE_TYPE (candidate)))
|
|
|
|
|
{
|
|
|
|
|
case BOOLEAN_TYPE:
|
|
|
|
|
case INTEGER_TYPE:
|
|
|
|
|
win = (desires & WANT_INT); break;
|
|
|
|
|
case ENUMERAL_TYPE:
|
|
|
|
|
win = (desires & WANT_ENUM); break;
|
|
|
|
|
case REAL_TYPE:
|
|
|
|
|
win = (desires & WANT_FLOAT); break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
1998-06-10 05:13:19 +02:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (win)
|
|
|
|
|
{
|
|
|
|
|
if (winner)
|
|
|
|
|
{
|
|
|
|
|
if (complain)
|
|
|
|
|
{
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error ("ambiguous default type conversion from %qT",
|
2005-06-15 02:41:35 +02:00
|
|
|
|
basetype);
|
2004-11-01 01:11:49 +01:00
|
|
|
|
error (" candidate conversions include %qD and %qD",
|
2005-06-15 02:41:35 +02:00
|
|
|
|
winner, cand);
|
1998-06-10 05:13:19 +02:00
|
|
|
|
}
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
winner = cand;
|
|
|
|
|
}
|
|
|
|
|
}
|
1995-03-16 00:03:59 +01:00
|
|
|
|
|
1998-06-10 05:13:19 +02:00
|
|
|
|
if (winner)
|
|
|
|
|
{
|
2003-07-08 03:38:44 +02:00
|
|
|
|
tree type = non_reference (TREE_TYPE (TREE_TYPE (winner)));
|
1998-06-10 05:13:19 +02:00
|
|
|
|
return build_user_type_conversion (type, expr, LOOKUP_NORMAL);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
1995-03-16 00:03:59 +01:00
|
|
|
|
|
cvt.c, [...]: Clean up more old overloading code, old RTTI code, and some formatting quirks.
* cvt.c, decl.c, decl2.c, init.c, rtti.c, typeck.c, typeck2.c,
cp-tree.h: Clean up more old overloading code, old RTTI code, and
some formatting quirks.
From-SVN: r18391
1998-03-03 23:27:04 +01:00
|
|
|
|
return NULL_TREE;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
1994-04-29 00:48:45 +02:00
|
|
|
|
|
1996-07-11 03:13:25 +02:00
|
|
|
|
/* Implements integral promotion (4.1) and float->double promotion. */
|
|
|
|
|
|
1994-04-29 00:48:45 +02:00
|
|
|
|
tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
type_promotes_to (tree type)
|
1994-04-29 00:48:45 +02:00
|
|
|
|
{
|
1995-10-12 03:33:51 +01:00
|
|
|
|
if (type == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
|
1994-04-29 00:48:45 +02:00
|
|
|
|
type = TYPE_MAIN_VARIANT (type);
|
1994-05-19 22:19:03 +02:00
|
|
|
|
|
|
|
|
|
/* bool always promotes to int (not unsigned), even if it's the same
|
|
|
|
|
size. */
|
1995-01-20 06:57:47 +01:00
|
|
|
|
if (type == boolean_type_node)
|
1994-05-19 22:19:03 +02:00
|
|
|
|
type = integer_type_node;
|
|
|
|
|
|
|
|
|
|
/* Normally convert enums to int, but convert wide enums to something
|
|
|
|
|
wider. */
|
|
|
|
|
else if (TREE_CODE (type) == ENUMERAL_TYPE
|
|
|
|
|
|| type == wchar_type_node)
|
1994-10-15 01:32:58 +01:00
|
|
|
|
{
|
|
|
|
|
int precision = MAX (TYPE_PRECISION (type),
|
|
|
|
|
TYPE_PRECISION (integer_type_node));
|
Makefile.in (convert.o, [...]): Update.
* Makefile.in (convert.o, calls.o, expmed.o): Update.
* attribs.c (handle_mode_attribute, handle_vector_size_attribute):
Use new hooks.
* builtin-types.def (BT_PTRMODE): Update.
* c-common.c (type_for_size): Rename c_common_type_for_size.
(type_for_mode): Similarly.
(shorten_compare, pointer_int_sum, c_common_nodes_and_builtins):
Use new hook.
* c-bommon.h (c_common_type_for_size, c_common_type_for_mode): New.
* c-decl.c (finish_enum, build_enumerator): Use new hooks.
* c-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* c-typeck.c (common_type, comptypes, default_conversion):
Use new hooks.
* calls.c: Include langhooks.h.
(emit_library_call_value_1): Use new hooks. Avoid redundant
calls.
* convert.c: Include langhooks.h
(convert_to_pointer, convert_to_integer): Use new hooks.
* except.c (init_eh): Similarly.
* expmed.c: Include langhooks.h.
(expand_mult_add): Use new hooks.
* expr.c (store_expr, store_constructor, expand_expr, do_jump,
try_casesi): Similarly.
* fold-const.c (optimize_bit_field_compare, make_range,
decode_field_reference, fold_truthop, fold): Similarly.
* function.c (assign_stack_local_1, assign_stack_temp_for_type,
put_var_into_stack): Similarly.
* langhooks-def.h (LANG_HOOKS_TYPE_FOR_MODE,
LANG_HOOKS_TYPE_FOR_SIZE): New.
(LANG_HOOKS_TYPES_INITIALIZER): Update.
* langhooks.h (lang_hooks_for_types): New hooks.
* stmt.c (expand_decl_cleanup, emit_case_nodes): Use new hooks.
* tree.c (get_unwidened, get_narrower): Similarly.
* tree.h (type_for_mode, type_for_size): Remove.
* varasm.c (force_const_mem): Use new hooks.
ada:
* gigi.h (type_for_size, type_for_mode): Rename.
* misc.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* trans.c (tree_transform): Update.
* utils.c (gnat_init_decl_processing, init_gigi_decls,
builtin_function, float_type_for_size, signed_or_unsigned_type,
build_vms_descriptor, unchecked_convert): Update.
(type_for_mode, type_for_size): Rename.
* utils2.c (nonbinary_modular_operation): Update.
cp:
* cp-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* cvt.c (cp_convert_to_pointer, type_promotes_to): Use new hooks.
* decl.c (finish_enum): Similarly.
* error.c (dump_type): Similarly.
* lex.c (cxx_init): Similarly.
* mangle.c (write_builtin_type): Similarly.
* typeck.c (comptypes): Similarly.
f:
* com.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
(type_for_mode, type_for_size): Rename.
(signed_or_unsigned_type, signed_type, truthvalue_conversion,
unsigned_type): Use new hooks.
java:
* Make-lang.in (builtins.o): Update.
* boehm.c (get_boehm_type_descriptor): Update.
* builtins.c: Include langhooks.h.
* decl.c (java_init_decl_processing): Update.
* java-tree.h (java_type_for_mode, java_type_for_size): New.
* lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
* typeck.c (type_for_mode, type_for_size): Update.
objc:
* objc-act.c (handle_impent): Update.
* objc-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
From-SVN: r51571
2002-03-29 22:46:27 +01:00
|
|
|
|
tree totype = c_common_type_for_size (precision, 0);
|
builtins.c, [...]: Change most occurrences of TREE_UNSIGNED to TYPE_UNSIGNED.
* builtins.c, c-aux-info.c, c-common.c, c-cppbuiltin.c, c-decl.c:
Change most occurrences of TREE_UNSIGNED to TYPE_UNSIGNED.
* c-format.c, c-opts.c, c-pretty-print.c, c-typeck.c: Likewise.
* calls.c, convert.c, dbxout.c, dojump.c, dwarf2out.c: Likewise.
* expmed.c, expr.c, fold-const.c, function.c, integrate.c: Likewise.
* optabs.c, sdbout.c, stmt.c, stor-layout.c, tree-dump.c: Likewise.
* tree.c, config/iq2000/iq2000.c, config/m32r/m32r.c: Likewise.
* config/mips/mips.c, config/rs6000/rs6000.c: Likewise.
* config/s390/s390.c, config/sparc/sparc.c, objc/objc-act.c: Likewise.
* stor-layout.c (layout_type, case COMPLEX_TYPE): Test for
REAL_TYPE, not INTEGER_TYPE.
(layout_type, case VECTOR_TYPE): Simplify code.
* tree.c (build_vector_type_for_mode): Remove dup unsigned setting.
* tree.h: Update comments.
(STRIP_NOPS): Use TYPE_UNSIGNED.
(TYPE_UNSIGNED): New macro.
(TYPE_TRAP_SIGNED): Remove now redundant check.
(SAVE_EXPR_NOPLACEHOLDER): Don't use TREE_UNSIGNED.
* cp/call.c (joust): Use TYPE_UNSIGNED, not TREE_UNSIGNED.
* cp/class.c (check_bitfield_decl): Likewise.
* cp/cvt.c (type_promotes_to): Likewise.
* cp/decl.c (finish_enum): Likewise.
* cp/mangle.c (write_builtin_type): Likewise.
* cp/semantics.c (finish_switch_cond, finish_unary_op_expr): Likewise.
* cp/typeck.c (type_after_usual_arithmetic_conversions): Likewise.
(build_binary_op): Likewise.
* f/com.c (ffecom_arrayref_): Use TYPE_UNSIGNED, not TREE_UNSIGNED.
(ffecom_expr_): Likewise.
* java/jcf-write.c (generate_bytecode_insns): Use TYPE_UNSIGNED.
* treelang/treetree.c (tree_lang_signed_or_unsigned_type):
Use TYPE_UNSIGNED, not TREE_UNSIGNED.
* ada/decl.c (gnat_to_gnu_entity, make_type_from_size):
Use TYPE_UNSIGNED, not TREE_UNSIGNED.
* ada/trans.c (tree_transform, convert_with_check): Likewise.
* ada/utils.c (gnat_signed_or_unsigned_type): Likewise.
(build_vms_descriptor, unchecked_convert): Likewise.
* ada/utils2.c (nonbinary_modular_operation): Likewise.
From-SVN: r80287
2004-04-01 05:50:43 +02:00
|
|
|
|
if (TYPE_UNSIGNED (type)
|
1994-10-15 01:32:58 +01:00
|
|
|
|
&& ! int_fits_type_p (TYPE_MAX_VALUE (type), totype))
|
Makefile.in (convert.o, [...]): Update.
* Makefile.in (convert.o, calls.o, expmed.o): Update.
* attribs.c (handle_mode_attribute, handle_vector_size_attribute):
Use new hooks.
* builtin-types.def (BT_PTRMODE): Update.
* c-common.c (type_for_size): Rename c_common_type_for_size.
(type_for_mode): Similarly.
(shorten_compare, pointer_int_sum, c_common_nodes_and_builtins):
Use new hook.
* c-bommon.h (c_common_type_for_size, c_common_type_for_mode): New.
* c-decl.c (finish_enum, build_enumerator): Use new hooks.
* c-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* c-typeck.c (common_type, comptypes, default_conversion):
Use new hooks.
* calls.c: Include langhooks.h.
(emit_library_call_value_1): Use new hooks. Avoid redundant
calls.
* convert.c: Include langhooks.h
(convert_to_pointer, convert_to_integer): Use new hooks.
* except.c (init_eh): Similarly.
* expmed.c: Include langhooks.h.
(expand_mult_add): Use new hooks.
* expr.c (store_expr, store_constructor, expand_expr, do_jump,
try_casesi): Similarly.
* fold-const.c (optimize_bit_field_compare, make_range,
decode_field_reference, fold_truthop, fold): Similarly.
* function.c (assign_stack_local_1, assign_stack_temp_for_type,
put_var_into_stack): Similarly.
* langhooks-def.h (LANG_HOOKS_TYPE_FOR_MODE,
LANG_HOOKS_TYPE_FOR_SIZE): New.
(LANG_HOOKS_TYPES_INITIALIZER): Update.
* langhooks.h (lang_hooks_for_types): New hooks.
* stmt.c (expand_decl_cleanup, emit_case_nodes): Use new hooks.
* tree.c (get_unwidened, get_narrower): Similarly.
* tree.h (type_for_mode, type_for_size): Remove.
* varasm.c (force_const_mem): Use new hooks.
ada:
* gigi.h (type_for_size, type_for_mode): Rename.
* misc.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* trans.c (tree_transform): Update.
* utils.c (gnat_init_decl_processing, init_gigi_decls,
builtin_function, float_type_for_size, signed_or_unsigned_type,
build_vms_descriptor, unchecked_convert): Update.
(type_for_mode, type_for_size): Rename.
* utils2.c (nonbinary_modular_operation): Update.
cp:
* cp-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* cvt.c (cp_convert_to_pointer, type_promotes_to): Use new hooks.
* decl.c (finish_enum): Similarly.
* error.c (dump_type): Similarly.
* lex.c (cxx_init): Similarly.
* mangle.c (write_builtin_type): Similarly.
* typeck.c (comptypes): Similarly.
f:
* com.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
(type_for_mode, type_for_size): Rename.
(signed_or_unsigned_type, signed_type, truthvalue_conversion,
unsigned_type): Use new hooks.
java:
* Make-lang.in (builtins.o): Update.
* boehm.c (get_boehm_type_descriptor): Update.
* builtins.c: Include langhooks.h.
* decl.c (java_init_decl_processing): Update.
* java-tree.h (java_type_for_mode, java_type_for_size): New.
* lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
* typeck.c (type_for_mode, type_for_size): Update.
objc:
* objc-act.c (handle_impent): Update.
* objc-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
From-SVN: r51571
2002-03-29 22:46:27 +01:00
|
|
|
|
type = c_common_type_for_size (precision, 1);
|
1994-10-15 01:32:58 +01:00
|
|
|
|
else
|
|
|
|
|
type = totype;
|
|
|
|
|
}
|
2001-05-01 01:59:10 +02:00
|
|
|
|
else if (c_promoting_integer_type_p (type))
|
1994-04-29 00:48:45 +02:00
|
|
|
|
{
|
1996-10-11 22:08:01 +02:00
|
|
|
|
/* Retain unsignedness if really not getting bigger. */
|
builtins.c, [...]: Change most occurrences of TREE_UNSIGNED to TYPE_UNSIGNED.
* builtins.c, c-aux-info.c, c-common.c, c-cppbuiltin.c, c-decl.c:
Change most occurrences of TREE_UNSIGNED to TYPE_UNSIGNED.
* c-format.c, c-opts.c, c-pretty-print.c, c-typeck.c: Likewise.
* calls.c, convert.c, dbxout.c, dojump.c, dwarf2out.c: Likewise.
* expmed.c, expr.c, fold-const.c, function.c, integrate.c: Likewise.
* optabs.c, sdbout.c, stmt.c, stor-layout.c, tree-dump.c: Likewise.
* tree.c, config/iq2000/iq2000.c, config/m32r/m32r.c: Likewise.
* config/mips/mips.c, config/rs6000/rs6000.c: Likewise.
* config/s390/s390.c, config/sparc/sparc.c, objc/objc-act.c: Likewise.
* stor-layout.c (layout_type, case COMPLEX_TYPE): Test for
REAL_TYPE, not INTEGER_TYPE.
(layout_type, case VECTOR_TYPE): Simplify code.
* tree.c (build_vector_type_for_mode): Remove dup unsigned setting.
* tree.h: Update comments.
(STRIP_NOPS): Use TYPE_UNSIGNED.
(TYPE_UNSIGNED): New macro.
(TYPE_TRAP_SIGNED): Remove now redundant check.
(SAVE_EXPR_NOPLACEHOLDER): Don't use TREE_UNSIGNED.
* cp/call.c (joust): Use TYPE_UNSIGNED, not TREE_UNSIGNED.
* cp/class.c (check_bitfield_decl): Likewise.
* cp/cvt.c (type_promotes_to): Likewise.
* cp/decl.c (finish_enum): Likewise.
* cp/mangle.c (write_builtin_type): Likewise.
* cp/semantics.c (finish_switch_cond, finish_unary_op_expr): Likewise.
* cp/typeck.c (type_after_usual_arithmetic_conversions): Likewise.
(build_binary_op): Likewise.
* f/com.c (ffecom_arrayref_): Use TYPE_UNSIGNED, not TREE_UNSIGNED.
(ffecom_expr_): Likewise.
* java/jcf-write.c (generate_bytecode_insns): Use TYPE_UNSIGNED.
* treelang/treetree.c (tree_lang_signed_or_unsigned_type):
Use TYPE_UNSIGNED, not TREE_UNSIGNED.
* ada/decl.c (gnat_to_gnu_entity, make_type_from_size):
Use TYPE_UNSIGNED, not TREE_UNSIGNED.
* ada/trans.c (tree_transform, convert_with_check): Likewise.
* ada/utils.c (gnat_signed_or_unsigned_type): Likewise.
(build_vms_descriptor, unchecked_convert): Likewise.
* ada/utils2.c (nonbinary_modular_operation): Likewise.
From-SVN: r80287
2004-04-01 05:50:43 +02:00
|
|
|
|
if (TYPE_UNSIGNED (type)
|
1996-10-11 22:08:01 +02:00
|
|
|
|
&& TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
|
1994-04-29 00:48:45 +02:00
|
|
|
|
type = unsigned_type_node;
|
|
|
|
|
else
|
|
|
|
|
type = integer_type_node;
|
|
|
|
|
}
|
|
|
|
|
else if (type == float_type_node)
|
|
|
|
|
type = double_type_node;
|
2005-06-14 22:01:59 +02:00
|
|
|
|
|
2003-07-06 05:30:57 +02:00
|
|
|
|
return type;
|
1994-04-29 00:48:45 +02:00
|
|
|
|
}
|
1998-01-19 23:41:40 +01:00
|
|
|
|
|
|
|
|
|
/* The routines below this point are carefully written to conform to
|
|
|
|
|
the standard. They use the same terminology, and follow the rules
|
|
|
|
|
closely. Although they are used only in pt.c at the moment, they
|
|
|
|
|
should presumably be used everywhere in the future. */
|
|
|
|
|
|
1998-01-27 21:47:56 +01:00
|
|
|
|
/* Attempt to perform qualification conversions on EXPR to convert it
|
|
|
|
|
to TYPE. Return the resulting expression, or error_mark_node if
|
|
|
|
|
the conversion was impossible. */
|
|
|
|
|
|
2005-06-14 22:01:59 +02:00
|
|
|
|
tree
|
Remove traditional C constructs 3/n.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference, warn_ref_binding, convert_to_reference,
convert_from_reference, convert_lvalue, cp_convert, ocp_convert,
convert_to_void, convert, convert_force, build_type_conversion,
build_expr_type_conversion, type_promotes_to,
perform_qualification_conversions): Use C90 prototyping style.
* decl2.c (grok_array_decl): Use boolean constant.
(delete_sanity): Likewise.
* typeck.c (build_unary_op): Likewise.
* semantics.c (finish_switch_cond): Likewise.
* parser.c (cp_parser_direct_new_declarator): Likewise.
* init.c (build_new): Likewise.
From-SVN: r60574
2002-12-28 15:38:38 +01:00
|
|
|
|
perform_qualification_conversions (tree type, tree expr)
|
1998-01-19 23:41:40 +01:00
|
|
|
|
{
|
2003-07-23 01:30:22 +02:00
|
|
|
|
tree expr_type;
|
|
|
|
|
|
|
|
|
|
expr_type = TREE_TYPE (expr);
|
|
|
|
|
|
2005-09-13 00:38:34 +02:00
|
|
|
|
if (same_type_p (type, expr_type))
|
|
|
|
|
return expr;
|
|
|
|
|
else if (TYPE_PTR_P (type) && TYPE_PTR_P (expr_type)
|
|
|
|
|
&& comp_ptr_ttypes (TREE_TYPE (type), TREE_TYPE (expr_type)))
|
2003-07-23 01:30:22 +02:00
|
|
|
|
return build_nop (type, expr);
|
|
|
|
|
else if (TYPE_PTR_TO_MEMBER_P (type)
|
|
|
|
|
&& TYPE_PTR_TO_MEMBER_P (expr_type)
|
|
|
|
|
&& same_type_p (TYPE_PTRMEM_CLASS_TYPE (type),
|
|
|
|
|
TYPE_PTRMEM_CLASS_TYPE (expr_type))
|
|
|
|
|
&& comp_ptr_ttypes (TYPE_PTRMEM_POINTED_TO_TYPE (type),
|
|
|
|
|
TYPE_PTRMEM_POINTED_TO_TYPE (expr_type)))
|
|
|
|
|
return build_nop (type, expr);
|
1998-01-27 21:47:56 +01:00
|
|
|
|
else
|
|
|
|
|
return error_mark_node;
|
1998-01-19 23:41:40 +01:00
|
|
|
|
}
|