1994-02-24 02:02:37 +01:00
|
|
|
|
/* Language-level data type conversion for GNU C++.
|
1999-08-07 03:01:54 +02:00
|
|
|
|
Copyright (C) 1987-1988, 1992-1999 Free Software Foundation, Inc.
|
1994-02-24 02:02:37 +01:00
|
|
|
|
Hacked by Michael Tiemann (tiemann@cygnus.com)
|
|
|
|
|
|
|
|
|
|
This file is part of GNU CC.
|
|
|
|
|
|
|
|
|
|
GNU CC is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
GNU CC is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with GNU CC; see the file COPYING. If not, write to
|
1995-06-15 14:29:51 +02:00
|
|
|
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This file contains the functions for converting C expressions
|
|
|
|
|
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"
|
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"
|
1996-07-11 03:13:25 +02:00
|
|
|
|
|
[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
|
|
|
|
static tree cp_convert_to_pointer PROTO((tree, tree));
|
|
|
|
|
static tree convert_to_pointer_force PROTO((tree, tree));
|
1998-09-25 11:00:04 +02:00
|
|
|
|
static tree build_up_reference PROTO((tree, tree, int));
|
[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),
|
|
|
|
|
and truthvalue_conversion.
|
|
|
|
|
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
|
|
|
|
|
else try C-style pointer conversion */
|
1996-07-11 03:13:25 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
static tree
|
|
|
|
|
cp_convert_to_pointer (type, expr)
|
|
|
|
|
tree type, expr;
|
|
|
|
|
{
|
|
|
|
|
register tree intype = TREE_TYPE (expr);
|
1995-03-29 22:32:43 +02:00
|
|
|
|
register enum tree_code form;
|
1998-02-19 11:05:22 +01:00
|
|
|
|
tree rval;
|
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);
|
|
|
|
|
if (TYPE_SIZE (intype) == NULL_TREE)
|
|
|
|
|
{
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("can't convert from incomplete type `%T' to `%T'",
|
1996-07-11 03:13:25 +02:00
|
|
|
|
intype, type);
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 01:01:48 +01:00
|
|
|
|
rval = build_type_conversion (type, expr, 1);
|
1996-07-11 03:13:25 +02:00
|
|
|
|
if (rval)
|
|
|
|
|
{
|
|
|
|
|
if (rval == error_mark_node)
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("conversion of `%E' from `%T' to `%T' is ambiguous",
|
1996-07-11 03:13:25 +02:00
|
|
|
|
expr, intype, type);
|
|
|
|
|
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
|
1996-12-18 02:44:21 +01:00
|
|
|
|
|| TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node))
|
1996-11-12 20:49:48 +01:00
|
|
|
|
{
|
|
|
|
|
/* Allow an implicit this pointer for pointer to member
|
|
|
|
|
functions. */
|
1996-12-18 02:44:21 +01:00
|
|
|
|
if (TYPE_PTRMEMFUNC_P (intype))
|
1996-11-12 20:49:48 +01:00
|
|
|
|
{
|
1996-12-18 02:44:21 +01:00
|
|
|
|
tree fntype = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (intype));
|
1998-10-19 22:08:23 +02:00
|
|
|
|
tree decl = maybe_dummy_object (TYPE_METHOD_BASETYPE (fntype), 0);
|
1996-11-12 20:49:48 +01:00
|
|
|
|
expr = build (OFFSET_REF, fntype, decl, expr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (expr) == OFFSET_REF
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE)
|
|
|
|
|
expr = resolve_offset_ref (expr);
|
|
|
|
|
if (TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE)
|
|
|
|
|
expr = build_addr_func (expr);
|
|
|
|
|
if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)
|
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (TREE_TYPE (TREE_TYPE (expr))) == METHOD_TYPE)
|
|
|
|
|
if (pedantic || warn_pmf2ptr)
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_pedwarn ("converting from `%T' to `%T'", TREE_TYPE (expr),
|
1996-11-12 20:49:48 +01:00
|
|
|
|
type);
|
|
|
|
|
return build1 (NOP_EXPR, type, expr);
|
|
|
|
|
}
|
|
|
|
|
intype = TREE_TYPE (expr);
|
|
|
|
|
}
|
|
|
|
|
|
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))
|
1998-08-07 11:56:06 +02:00
|
|
|
|
&& TREE_CODE (TREE_TYPE (intype)) == RECORD_TYPE
|
|
|
|
|
/* If EXPR is NULL, then we don't need to do any arithmetic
|
|
|
|
|
to convert it:
|
|
|
|
|
|
|
|
|
|
[conv.ptr]
|
|
|
|
|
|
|
|
|
|
The null pointer value is converted to the null pointer
|
|
|
|
|
value of the destination type. */
|
|
|
|
|
&& !integer_zerop (expr))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
|
|
|
|
enum tree_code code = PLUS_EXPR;
|
|
|
|
|
tree binfo = get_binfo (TREE_TYPE (type), TREE_TYPE (intype), 1);
|
|
|
|
|
if (binfo == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
if (binfo == NULL_TREE)
|
|
|
|
|
{
|
|
|
|
|
binfo = get_binfo (TREE_TYPE (intype), TREE_TYPE (type), 1);
|
|
|
|
|
if (binfo == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
code = MINUS_EXPR;
|
|
|
|
|
}
|
|
|
|
|
if (binfo)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_USES_VIRTUAL_BASECLASSES (TREE_TYPE (type))
|
|
|
|
|
|| TYPE_USES_VIRTUAL_BASECLASSES (TREE_TYPE (intype))
|
|
|
|
|
|| ! BINFO_OFFSET_ZEROP (binfo))
|
|
|
|
|
{
|
|
|
|
|
/* Need to get the path we took. */
|
|
|
|
|
tree path;
|
|
|
|
|
|
|
|
|
|
if (code == PLUS_EXPR)
|
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
|
|
|
|
get_base_distance (TREE_TYPE (type), TREE_TYPE (intype),
|
|
|
|
|
0, &path);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
else
|
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
|
|
|
|
get_base_distance (TREE_TYPE (intype), TREE_TYPE (type),
|
|
|
|
|
0, &path);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return build_vbase_path (code, type, expr, path, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 01:01:48 +01:00
|
|
|
|
if (TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))
|
1995-03-23 01:44:31 +01:00
|
|
|
|
{
|
1999-05-22 03:30:11 +02:00
|
|
|
|
tree b1;
|
|
|
|
|
tree b2;
|
|
|
|
|
tree binfo;
|
|
|
|
|
enum tree_code code;
|
|
|
|
|
|
|
|
|
|
b1 = TYPE_OFFSET_BASETYPE (TREE_TYPE (type));
|
|
|
|
|
b2 = TYPE_OFFSET_BASETYPE (TREE_TYPE (intype));
|
|
|
|
|
binfo = get_binfo (b2, b1, 1);
|
1997-12-15 08:24:29 +01:00
|
|
|
|
|
1995-03-23 01:44:31 +01:00
|
|
|
|
if (binfo == NULL_TREE)
|
1997-12-15 08:24:29 +01:00
|
|
|
|
{
|
|
|
|
|
binfo = get_binfo (b1, b2, 1);
|
|
|
|
|
code = MINUS_EXPR;
|
|
|
|
|
}
|
1999-05-22 03:30:11 +02:00
|
|
|
|
else
|
|
|
|
|
code = PLUS_EXPR;
|
1997-12-15 08:24:29 +01:00
|
|
|
|
|
1995-03-23 01:44:31 +01:00
|
|
|
|
if (binfo == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
1999-05-22 03:30:11 +02:00
|
|
|
|
|
1999-08-07 03:01:54 +02:00
|
|
|
|
if (binfo_from_vbase (binfo))
|
|
|
|
|
{
|
|
|
|
|
cp_error ("conversion to `%T' from pointer to member of virtual base `%T'",
|
|
|
|
|
type, intype);
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-22 03:30:11 +02:00
|
|
|
|
if (TREE_CODE (expr) == PTRMEM_CST)
|
|
|
|
|
expr = cplus_expand_constant (expr);
|
|
|
|
|
|
1997-12-15 08:24:29 +01:00
|
|
|
|
if (binfo && ! TREE_VIA_VIRTUAL (binfo))
|
|
|
|
|
expr = size_binop (code, expr, BINFO_OFFSET (binfo));
|
1995-03-23 01:44:31 +01:00
|
|
|
|
}
|
1998-12-14 16:35:40 +01:00
|
|
|
|
else if (TYPE_PTRMEMFUNC_P (type))
|
1995-10-12 03:33:51 +01:00
|
|
|
|
{
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("cannot convert `%E' from type `%T' to type `%T'",
|
1995-10-12 03:33:51 +01:00
|
|
|
|
expr, intype, type);
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
1998-02-19 11:05:22 +01:00
|
|
|
|
rval = build1 (NOP_EXPR, type, expr);
|
|
|
|
|
TREE_CONSTANT (rval) = TREE_CONSTANT (expr);
|
|
|
|
|
return rval;
|
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))
|
1999-08-07 03:01:54 +02:00
|
|
|
|
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0);
|
1998-12-14 16:35:40 +01:00
|
|
|
|
else if (TYPE_PTRMEMFUNC_P (intype))
|
|
|
|
|
{
|
|
|
|
|
cp_error ("cannot convert `%E' from type `%T' to type `%T'",
|
|
|
|
|
expr, intype, type);
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
my_friendly_assert (form != OFFSET_TYPE, 186);
|
|
|
|
|
|
|
|
|
|
if (integer_zerop (expr))
|
|
|
|
|
{
|
1998-12-14 16:35:40 +01:00
|
|
|
|
if (TYPE_PTRMEMFUNC_P (type))
|
1999-01-24 16:56:46 +01:00
|
|
|
|
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
expr = build_int_2 (0, 0);
|
|
|
|
|
TREE_TYPE (expr) = type;
|
|
|
|
|
return expr;
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
1997-05-29 01:20:02 +02:00
|
|
|
|
expr = cp_convert (type_for_size (POINTER_SIZE, 0), expr);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
/* Modes may be different but sizes should be the same. */
|
|
|
|
|
if (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr)))
|
|
|
|
|
!= GET_MODE_SIZE (TYPE_MODE (type)))
|
|
|
|
|
/* There is supposed to be some integral type
|
|
|
|
|
that is the same width as a pointer. */
|
|
|
|
|
abort ();
|
|
|
|
|
return convert_to_pointer (type, expr);
|
|
|
|
|
}
|
|
|
|
|
|
1998-10-27 23:33:40 +01:00
|
|
|
|
if (type_unknown_p (expr))
|
|
|
|
|
return instantiate_type (type, expr, 1);
|
|
|
|
|
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("cannot convert `%E' from type `%T' to type `%T'",
|
1994-02-24 02:02:37 +01:00
|
|
|
|
expr, intype, type);
|
|
|
|
|
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
|
|
|
|
|
convert_to_pointer_force (type, expr)
|
|
|
|
|
tree type, expr;
|
|
|
|
|
{
|
|
|
|
|
register tree intype = TREE_TYPE (expr);
|
|
|
|
|
register enum tree_code form = TREE_CODE (intype);
|
|
|
|
|
|
|
|
|
|
if (integer_zerop (expr))
|
|
|
|
|
{
|
|
|
|
|
expr = build_int_2 (0, 0);
|
|
|
|
|
TREE_TYPE (expr) = type;
|
|
|
|
|
return expr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
tree path;
|
|
|
|
|
int distance = get_base_distance (TREE_TYPE (type),
|
|
|
|
|
TREE_TYPE (intype), 0, &path);
|
|
|
|
|
if (distance == -2)
|
|
|
|
|
{
|
|
|
|
|
ambig:
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("type `%T' is ambiguous baseclass of `%s'",
|
1996-12-18 03:46:25 +01:00
|
|
|
|
TREE_TYPE (type),
|
|
|
|
|
TYPE_NAME_STRING (TREE_TYPE (intype)));
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
if (distance == -1)
|
|
|
|
|
{
|
|
|
|
|
distance = get_base_distance (TREE_TYPE (intype),
|
|
|
|
|
TREE_TYPE (type), 0, &path);
|
|
|
|
|
if (distance == -2)
|
|
|
|
|
goto ambig;
|
|
|
|
|
if (distance < 0)
|
|
|
|
|
/* Doesn't need any special help from us. */
|
|
|
|
|
return build1 (NOP_EXPR, type, expr);
|
|
|
|
|
|
|
|
|
|
code = MINUS_EXPR;
|
|
|
|
|
}
|
|
|
|
|
return build_vbase_path (code, type, expr, path, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cp_convert_to_pointer (type, expr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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.
|
1997-04-24 00:39:53 +02:00
|
|
|
|
DIRECT_BIND in FLAGS controls how any temporaries are generated. */
|
1996-07-11 03:13:25 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
static tree
|
1998-09-25 11:00:04 +02:00
|
|
|
|
build_up_reference (type, arg, flags)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree type, arg;
|
1998-09-25 11:00:04 +02:00
|
|
|
|
int flags;
|
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);
|
1999-08-30 20:54:20 +02:00
|
|
|
|
tree stmt_expr = NULL_TREE;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
my_friendly_assert (TREE_CODE (type) == REFERENCE_TYPE, 187);
|
|
|
|
|
|
1997-04-24 00:39:53 +02:00
|
|
|
|
if ((flags & DIRECT_BIND) && ! real_lvalue_p (arg))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
1999-08-30 20:54:20 +02:00
|
|
|
|
tree compound_stmt;
|
|
|
|
|
|
|
|
|
|
/* Create a new temporary variable. */
|
1997-04-24 00:39:53 +02:00
|
|
|
|
tree targ = arg;
|
1996-11-12 20:49:48 +01:00
|
|
|
|
if (toplevel_bindings_p ())
|
1997-04-24 00:39:53 +02:00
|
|
|
|
arg = get_temp_name (argtype, 1);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
1996-11-12 20:49:48 +01:00
|
|
|
|
arg = pushdecl (build_decl (VAR_DECL, NULL_TREE, argtype));
|
|
|
|
|
DECL_ARTIFICIAL (arg) = 1;
|
1999-08-30 20:54:20 +02:00
|
|
|
|
/* Generate code to initialize it. We wrap it in a
|
|
|
|
|
statement-expression so that when we are building a
|
|
|
|
|
statement-tree we will have a representation of this
|
|
|
|
|
declaration. */
|
|
|
|
|
begin_init_stmts (&stmt_expr, &compound_stmt);
|
1996-05-30 21:11:58 +02:00
|
|
|
|
}
|
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;
|
1998-11-25 01:28:51 +01:00
|
|
|
|
cp_finish_decl (arg, targ, NULL_TREE, 0,
|
|
|
|
|
LOOKUP_ONLYCONVERTING|DIRECT_BIND);
|
1999-08-30 20:54:20 +02:00
|
|
|
|
|
|
|
|
|
/* And wrap up the statement-expression, if necessary. */
|
|
|
|
|
if (!toplevel_bindings_p ())
|
|
|
|
|
{
|
|
|
|
|
if (building_stmt_tree ())
|
|
|
|
|
add_decl_stmt (arg);
|
|
|
|
|
stmt_expr = finish_init_stmts (stmt_expr, compound_stmt);
|
|
|
|
|
}
|
1996-05-30 21:11:58 +02:00
|
|
|
|
}
|
1997-04-24 00:39:53 +02:00
|
|
|
|
else if (!(flags & DIRECT_BIND) && ! lvalue_p (arg))
|
1996-05-30 21:11:58 +02:00
|
|
|
|
{
|
1996-11-12 20:49:48 +01:00
|
|
|
|
tree slot = build_decl (VAR_DECL, NULL_TREE, argtype);
|
1998-11-25 01:28:51 +01:00
|
|
|
|
DECL_ARTIFICIAL (slot) = 1;
|
1996-11-12 20:49:48 +01:00
|
|
|
|
arg = build (TARGET_EXPR, argtype, slot, arg, NULL_TREE, NULL_TREE);
|
1998-01-19 14:21:59 +01:00
|
|
|
|
TREE_SIDE_EFFECTS (arg) = 1;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
1996-05-30 21:11:58 +02:00
|
|
|
|
|
1996-12-18 03:46:25 +01:00
|
|
|
|
/* If we had a way to wrap this up, and say, if we ever needed it's
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
/* We go through get_binfo for the access control. */
|
|
|
|
|
tree binfo = get_binfo (target_type, argtype, 1);
|
|
|
|
|
if (binfo == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
if (binfo == NULL_TREE)
|
|
|
|
|
return error_not_base_type (target_type, argtype);
|
|
|
|
|
rval = convert_pointer_to_real (binfo, rval);
|
|
|
|
|
}
|
1997-04-24 00:39:53 +02:00
|
|
|
|
else
|
|
|
|
|
rval
|
|
|
|
|
= convert_to_pointer_force (build_pointer_type (target_type), rval);
|
1997-06-18 04:25:37 +02:00
|
|
|
|
rval = build1 (NOP_EXPR, type, rval);
|
1997-04-24 00:39:53 +02:00
|
|
|
|
TREE_CONSTANT (rval) = TREE_CONSTANT (TREE_OPERAND (rval, 0));
|
1999-08-30 20:54:20 +02:00
|
|
|
|
|
|
|
|
|
/* If we created and initialized a new temporary variable, add the
|
|
|
|
|
representation of that initialization to the RVAL. */
|
|
|
|
|
if (stmt_expr)
|
|
|
|
|
rval = build (COMPOUND_EXPR, TREE_TYPE (rval), stmt_expr, rval);
|
|
|
|
|
|
|
|
|
|
/* And return the result. */
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return rval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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
|
1994-05-13 04:46:07 +02:00
|
|
|
|
convert_to_reference (reftype, expr, convtype, flags, decl)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree reftype, expr;
|
1994-05-13 04:46:07 +02:00
|
|
|
|
int convtype, flags;
|
|
|
|
|
tree decl;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
|
|
|
|
register tree type = TYPE_MAIN_VARIANT (TREE_TYPE (reftype));
|
|
|
|
|
register tree intype = TREE_TYPE (expr);
|
|
|
|
|
tree rval = NULL_TREE;
|
1995-02-16 16:24:37 +01:00
|
|
|
|
tree rval_as_conversion = NULL_TREE;
|
|
|
|
|
int i;
|
|
|
|
|
|
1998-10-27 23:33:40 +01:00
|
|
|
|
if (TREE_CODE (type) == FUNCTION_TYPE && intype == unknown_type_node)
|
|
|
|
|
{
|
1998-12-09 17:20:05 +01:00
|
|
|
|
expr = instantiate_type (type, expr,
|
|
|
|
|
(flags & LOOKUP_COMPLAIN) != 0);
|
|
|
|
|
if (expr == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
|
1998-10-27 23:33:40 +01:00
|
|
|
|
intype = TREE_TYPE (expr);
|
|
|
|
|
}
|
|
|
|
|
|
1995-02-16 16:24:37 +01:00
|
|
|
|
if (TREE_CODE (intype) == REFERENCE_TYPE)
|
|
|
|
|
my_friendly_abort (364);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
intype = TYPE_MAIN_VARIANT (intype);
|
|
|
|
|
|
1995-02-16 16:24:37 +01:00
|
|
|
|
i = comp_target_types (type, intype, 0);
|
|
|
|
|
|
|
|
|
|
if (i <= 0 && (convtype & CONV_IMPLICIT) && IS_AGGR_TYPE (intype)
|
|
|
|
|
&& ! (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
|
1999-03-23 01:01:48 +01:00
|
|
|
|
= build_type_conversion (reftype, expr, 1);
|
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;
|
|
|
|
|
i = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (((convtype & CONV_STATIC) && i == -1)
|
|
|
|
|
|| ((convtype & CONV_IMPLICIT) && i == 1))
|
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
|
|
|
|
|
1998-10-04 13:36:26 +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. */
|
|
|
|
|
if (! real_lvalue_p (expr)
|
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
|
|
|
|
&& !CP_TYPE_CONST_NON_VOLATILE_P (ttl))
|
1994-04-29 00:48:45 +02:00
|
|
|
|
{
|
Warning fixes:
* call.c (op_error): Const-ify a char*.
(add_candidate, source_type, add_warning): Add static prototype.
(print_z_candidates): Const-ify a char*.
* class.c (resolve_address_of_overloaded_function,
fixed_type_or_null, build_vtable_entry_ref): Add static prototype.
(get_vtable_name, finish_struct_1): Const-ify a char*.
* cvt.c (convert_to_reference): Likewise.
* decl.c (redeclaration_error_message, record_builtin_type,
record_unknown_type, member_function_or_else, bad_specifiers):
Likewise.
(find_binding, select_decl, unqualified_namespace_lookup,
lookup_flags, qualify_lookup, record_builtin_java_type, tag_name):
Add static prototype.
(warn_extern_redeclared_static, duplicate_decls, pushdecl,
implicitly_declare, record_builtin_java_type, define_function,
grok_op_properties, tag_name): Const-ify a char*.
* cp-tree.h (FORMAT_VBASE_NAME): Allow parameter `BUF' to be const.
(define_function, finish_builtin_type): Const-ify a char*.
(cp_error, cp_error_at, cp_warning, cp_warning_at, cp_pedwarn,
cp_pedwarn_at, cp_compiler_error, cp_sprintf): Add prototype args.
(file_name_nondirectory): Const-ify a char*.
(init_filename_times): Don't prototype.
(compiler_error): Prototype.
(yyerror, init_repo): Const-ify a char*.
(build_srcloc): Don't prototype.
(build_x_indirect_ref, build_indirect_ref, build_component_addr):
Const-ify a char*.
(warn_for_assignment): Don't prototype.
(convert_for_initialization, readonly_error, check_for_new_type,
GNU_xref_begin, GNU_xref_file, GNU_xref_ref, GNU_xref_call):
Const-ify a char*.
* decl2.c (acceptable_java_type, output_vtable_inherit,
setup_initp, start_objects, finish_objects, do_dtors, do_ctors,
merge_functions, decl_namespace, validate_nonmember_using_decl,
do_nonmember_using_decl): Add static prototype.
(lang_f_options): Const-ify a char*.
(finish_builtin_type): Likewise.
(add_function, arg_assoc_namespace, arg_assoc_class): Add static
prototype.
* errfn.c: Include cp-tree.h.
(cp_thing): Add static prototype.
(compiler_error): Don't protoptype.
(cp_compiler_error): Cast `compiler_error' to `errorfn' before
passing it to `cp_thing'.
* error.c (interesting_scope_p): Add static prototype.
* except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify
a char*.
* init.c (compiler_error): Don't prototype.
(member_init_ok_or_else): Const-ify a char*.
(build_java_class_ref): Add static prototype.
* lex.c (compiler_error): Don't prototype.
(get_time_identifier, interface_strcmp, extend_token_buffer,
handle_cp_pragma): Const-ify a char*.
(is_global, init_filename_times): Add static prototype.
(file_name_nondirectory, cplus_tree_code_name): Const-ify a char*.
(compiler_error): Change from fixed args to variable args.
(yyerror): Const-ify a char*.
* parse.y (cond_stmt_keyword): Const-ify a char*.
(parse_decl): Add static prototype.
* pt.c (template_args_equal, print_template_context): Likewise.
(print_candidates, check_default_tmpl_args): Const-ify a char*.
(instantiate_class_template): Likewise.
* repo.c (get_base_filename, open_repo_file, init_repo): Likewise.
* rtti.c (call_void_fn, expand_generic_desc, expand_si_desc,
expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise.
* search.c (lookup_field_info, lookup_member): Likewise.
(lookup_member): Cast the first argument of `bzero' to a PTR.
* sig.c (compiler_error): Don't prototype.
(build_signature_pointer_or_reference_nam): Const-ify a char*.
(get_sigtable_name, build_member_function_pointer): Likewise.
* tree.c (compiler_error): Don't prototype.
(no_linkage_helper, build_srcloc): Add static prototype.
(build_vbase_pointer_fields): Const-ify a char*.
(__eprintf): Don't unnecessarily handle `const' when !__STDC__.
* typeck.c (compiler_error): Don't prototype.
(convert_for_assignment): Const-ify a char*.
(comp_cv_target_types): Add static prototype.
(build_x_indirect_ref, build_indirect_ref, convert_arguments,
build_component_addr, build_unary_op, convert_for_initialization):
Const-ify a char*.
* typeck2.c (ack): Add static prototype and change from fixed args
to variable args.
(readonly_error, check_for_new_type): Const-ify a char*.
* xref.c (_XREF_FILE, find_file, filename, fctname, declname,
fixname, open_xref_file, classname, GNU_xref_begin): Likewise.
(GNU_xref_file): Likewise. Also use `xmalloc' instead of `malloc'.
(GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call,
gen_assign, GNU_xref_member): Const-ify a char*.
From-SVN: r25994
1999-03-26 08:45:00 +01:00
|
|
|
|
const char *msg;
|
1998-10-04 13:36:26 +02:00
|
|
|
|
|
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
|
|
|
|
if (CP_TYPE_VOLATILE_P (ttl) && decl)
|
1998-10-04 13:36:26 +02:00
|
|
|
|
msg = "initialization of volatile reference type `%#T'";
|
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
|
|
|
|
else if (CP_TYPE_VOLATILE_P (ttl))
|
1998-10-04 13:36:26 +02:00
|
|
|
|
msg = "conversion to volatile reference type `%#T'";
|
|
|
|
|
else if (decl)
|
|
|
|
|
msg = "initialization of non-const reference type `%#T'";
|
1994-05-13 04:46:07 +02:00
|
|
|
|
else
|
1998-10-04 13:36:26 +02:00
|
|
|
|
msg = "conversion to non-const reference type `%#T'";
|
|
|
|
|
|
1998-12-07 13:27:47 +01:00
|
|
|
|
cp_pedwarn (msg, reftype);
|
|
|
|
|
cp_pedwarn ("from rvalue of type `%T'", intype);
|
1994-04-29 00:48:45 +02:00
|
|
|
|
}
|
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
|
|
|
|
else if (! (convtype & CONV_CONST)
|
|
|
|
|
&& !at_least_as_qualified_p (ttl, ttr))
|
1998-12-07 13:27:47 +01:00
|
|
|
|
cp_pedwarn ("conversion from `%T' to `%T' discards qualifiers",
|
|
|
|
|
ttr, reftype);
|
1994-04-08 08:08:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
1998-09-25 11:00:04 +02:00
|
|
|
|
return build_up_reference (reftype, expr, flags);
|
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
|
1994-04-15 03:44:15 +02:00
|
|
|
|
meant. */
|
1995-02-16 16:24:37 +01:00
|
|
|
|
if (TREE_CODE (intype) == POINTER_TYPE
|
1998-11-01 16:45:11 +01:00
|
|
|
|
&& (comptypes (TREE_TYPE (intype), type,
|
|
|
|
|
COMPARE_BASE | COMPARE_RELAXED )))
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_warning ("casting `%T' to `%T' does not dereference pointer",
|
1994-04-15 03:44:15 +02:00
|
|
|
|
intype, reftype);
|
|
|
|
|
|
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;
|
1998-09-25 11:00:04 +02:00
|
|
|
|
rval = build_up_reference (reftype, rval, flags);
|
1996-12-18 02:44:21 +01:00
|
|
|
|
|
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
|
|
|
|
if (rval && ! CP_TYPE_CONST_P (TREE_TYPE (reftype)))
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_pedwarn ("initializing non-const `%T' with `%T' will use a temporary",
|
1996-12-18 02:44:21 +01:00
|
|
|
|
reftype, intype);
|
|
|
|
|
}
|
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-02-16 16:24:37 +01:00
|
|
|
|
my_friendly_assert (TREE_CODE (intype) != OFFSET_TYPE, 189);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
1995-05-27 02:15:16 +02:00
|
|
|
|
if (flags & LOOKUP_COMPLAIN)
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("cannot convert type `%T' to type `%T'", intype, reftype);
|
1995-05-27 02:15:16 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
if (flags & LOOKUP_SPECULATIVELY)
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
convert_from_reference (val)
|
|
|
|
|
tree val;
|
|
|
|
|
{
|
|
|
|
|
tree type = TREE_TYPE (val);
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (type) == OFFSET_TYPE)
|
|
|
|
|
type = TREE_TYPE (type);
|
1995-05-10 04:58:06 +02:00
|
|
|
|
if (TREE_CODE (type) == REFERENCE_TYPE)
|
|
|
|
|
return build_indirect_ref (val, NULL_PTR);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Call this when we know (for any reason) that expr is not, in fact,
|
|
|
|
|
zero. This routine is like convert_pointer_to, but it pays
|
|
|
|
|
attention to which specific instance of what type we want to
|
|
|
|
|
convert to. This routine should eventually become
|
|
|
|
|
convert_to_pointer after all references to convert_to_pointer
|
|
|
|
|
are removed. */
|
1996-07-11 03:13:25 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree
|
|
|
|
|
convert_pointer_to_real (binfo, expr)
|
|
|
|
|
tree binfo, expr;
|
|
|
|
|
{
|
|
|
|
|
register tree intype = TREE_TYPE (expr);
|
|
|
|
|
tree ptr_type;
|
|
|
|
|
tree type, rval;
|
|
|
|
|
|
1998-07-12 03:30:11 +02:00
|
|
|
|
if (intype == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
if (TREE_CODE (binfo) == TREE_VEC)
|
|
|
|
|
type = BINFO_TYPE (binfo);
|
|
|
|
|
else if (IS_AGGR_TYPE (binfo))
|
|
|
|
|
{
|
|
|
|
|
type = binfo;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
type = binfo;
|
|
|
|
|
binfo = NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
ptr_type = cp_build_qualified_type (type,
|
|
|
|
|
CP_TYPE_QUALS (TREE_TYPE (intype)));
|
1996-03-21 20:46:11 +01:00
|
|
|
|
ptr_type = build_pointer_type (ptr_type);
|
1999-04-01 14:23:07 +02:00
|
|
|
|
if (same_type_p (ptr_type, TYPE_MAIN_VARIANT (intype)))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return expr;
|
|
|
|
|
|
|
|
|
|
my_friendly_assert (!integer_zerop (expr), 191);
|
|
|
|
|
|
1998-09-02 18:57:18 +02:00
|
|
|
|
intype = TYPE_MAIN_VARIANT (TREE_TYPE (intype));
|
1994-02-24 02:02:37 +01:00
|
|
|
|
if (TREE_CODE (type) == RECORD_TYPE
|
1998-09-02 18:57:18 +02:00
|
|
|
|
&& TREE_CODE (intype) == RECORD_TYPE
|
|
|
|
|
&& type != intype)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
|
|
|
|
tree path;
|
|
|
|
|
int distance
|
1998-09-02 18:57:18 +02:00
|
|
|
|
= get_base_distance (binfo, intype, 0, &path);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
/* This function shouldn't be called with unqualified arguments
|
|
|
|
|
but if it is, give them an error message that they can read. */
|
|
|
|
|
if (distance < 0)
|
|
|
|
|
{
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("cannot convert a pointer of type `%T' to a pointer of type `%T'",
|
1998-09-02 18:57:18 +02:00
|
|
|
|
intype, type);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
if (distance == -2)
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("because `%T' is an ambiguous base class", type);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return build_vbase_path (PLUS_EXPR, ptr_type, expr, path, 1);
|
|
|
|
|
}
|
|
|
|
|
rval = build1 (NOP_EXPR, ptr_type,
|
|
|
|
|
TREE_CODE (expr) == NOP_EXPR ? TREE_OPERAND (expr, 0) : expr);
|
|
|
|
|
TREE_CONSTANT (rval) = TREE_CONSTANT (expr);
|
|
|
|
|
return rval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Call this when we know (for any reason) that expr is
|
|
|
|
|
not, in fact, zero. This routine gets a type out of the first
|
|
|
|
|
argument and uses it to search for the type to convert to. If there
|
|
|
|
|
is more than one instance of that type in the expr, the conversion is
|
|
|
|
|
ambiguous. This routine should eventually go away, and all
|
|
|
|
|
callers should use convert_to_pointer_real. */
|
1996-07-11 03:13:25 +02:00
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree
|
|
|
|
|
convert_pointer_to (binfo, expr)
|
|
|
|
|
tree binfo, expr;
|
|
|
|
|
{
|
|
|
|
|
tree type;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (binfo) == TREE_VEC)
|
|
|
|
|
type = BINFO_TYPE (binfo);
|
|
|
|
|
else if (IS_AGGR_TYPE (binfo))
|
1999-07-28 00:58:58 +02:00
|
|
|
|
type = binfo;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
else
|
1999-07-28 00:58:58 +02:00
|
|
|
|
type = binfo;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return convert_pointer_to_real (type, expr);
|
|
|
|
|
}
|
|
|
|
|
|
1997-05-29 01:20:02 +02:00
|
|
|
|
/* C++ conversions, preference to static cast conversions. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
cp_convert (type, expr)
|
|
|
|
|
tree type, expr;
|
|
|
|
|
{
|
|
|
|
|
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
|
1997-05-29 01:20:02 +02:00
|
|
|
|
ocp_convert (type, expr, convtype, flags)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree type, expr;
|
1994-05-13 04:46:07 +02:00
|
|
|
|
int convtype, flags;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
|
|
|
|
register tree e = expr;
|
|
|
|
|
register enum tree_code code = TREE_CODE (type);
|
|
|
|
|
|
1997-04-02 05:58:33 +02:00
|
|
|
|
if (e == error_mark_node
|
|
|
|
|
|| TREE_TYPE (e) == error_mark_node)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return error_mark_node;
|
1994-05-13 04:46:07 +02:00
|
|
|
|
|
1998-02-04 00:55:27 +01:00
|
|
|
|
if (TREE_READONLY_DECL_P (e))
|
|
|
|
|
e = decl_constant_value (e);
|
|
|
|
|
|
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;
|
|
|
|
|
the comparsion 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;
|
1998-10-04 01:11:19 +02:00
|
|
|
|
else
|
1998-10-09 12:32:01 +02:00
|
|
|
|
return fold (build1 (NOP_EXPR, type, e));
|
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-02-27 00:37:04 +01:00
|
|
|
|
e = require_complete_type_in_void (e);
|
|
|
|
|
if (e != error_mark_node)
|
|
|
|
|
e = build1 (CONVERT_EXPR, void_type_node, e);
|
1998-11-16 06:05:20 +01:00
|
|
|
|
|
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-02-24 02:02:37 +01:00
|
|
|
|
#if 0
|
|
|
|
|
/* This is incorrect. A truncation can't be stripped this way.
|
|
|
|
|
Extensions will be stripped by the use of get_unwidened. */
|
1994-06-15 20:30:58 +02:00
|
|
|
|
if (TREE_CODE (e) == NOP_EXPR)
|
1997-05-29 01:20:02 +02:00
|
|
|
|
return cp_convert (type, TREE_OPERAND (e, 0));
|
1994-02-24 02:02:37 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Just convert to the type of the member. */
|
|
|
|
|
if (code == OFFSET_TYPE)
|
|
|
|
|
{
|
|
|
|
|
type = TREE_TYPE (type);
|
|
|
|
|
code = TREE_CODE (type);
|
|
|
|
|
}
|
|
|
|
|
|
1995-02-16 16:24:37 +01:00
|
|
|
|
#if 0
|
1994-02-24 02:02:37 +01:00
|
|
|
|
if (code == REFERENCE_TYPE)
|
1994-05-13 04:46:07 +02:00
|
|
|
|
return fold (convert_to_reference (type, e, convtype, flags, NULL_TREE));
|
1994-02-24 02:02:37 +01:00
|
|
|
|
else if (TREE_CODE (TREE_TYPE (e)) == REFERENCE_TYPE)
|
|
|
|
|
e = convert_from_reference (e);
|
1995-02-16 16:24:37 +01:00
|
|
|
|
#endif
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
1994-08-05 22:25:20 +02:00
|
|
|
|
if (TREE_CODE (e) == OFFSET_REF)
|
|
|
|
|
e = resolve_offset_ref (e);
|
|
|
|
|
|
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
|
|
|
|
|
errors. */
|
1998-08-31 14:54:18 +02:00
|
|
|
|
if (TREE_CODE (type) == ENUMERAL_TYPE
|
1997-02-04 03:31:49 +01:00
|
|
|
|
&& ((ARITHMETIC_TYPE_P (intype) && ! (convtype & CONV_STATIC))
|
|
|
|
|
|| (TREE_CODE (intype) == POINTER_TYPE)))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_pedwarn ("conversion from `%#T' to `%#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;
|
1999-03-23 01:01:48 +01:00
|
|
|
|
rval = build_type_conversion (type, e, 1);
|
1994-08-18 22:50:43 +02:00
|
|
|
|
if (rval)
|
|
|
|
|
return rval;
|
1995-05-27 02:15:16 +02:00
|
|
|
|
if (flags & LOOKUP_COMPLAIN)
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("`%#T' used where a `%T' was expected", intype, type);
|
1995-05-27 02:15:16 +02:00
|
|
|
|
if (flags & LOOKUP_SPECULATIVELY)
|
|
|
|
|
return NULL_TREE;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
1994-05-19 22:19:03 +02:00
|
|
|
|
if (code == BOOLEAN_TYPE)
|
1996-03-08 01:38:10 +01:00
|
|
|
|
{
|
|
|
|
|
/* Common Ada/Pascal programmer's mistake. We always warn
|
|
|
|
|
about this since it is so bad. */
|
|
|
|
|
if (TREE_CODE (expr) == FUNCTION_DECL)
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_warning ("the address of `%D', will always be `true'", expr);
|
1996-03-08 01:38:10 +01:00
|
|
|
|
return truthvalue_conversion (e);
|
|
|
|
|
}
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return fold (convert_to_integer (type, e));
|
|
|
|
|
}
|
1995-03-29 22:32:43 +02:00
|
|
|
|
if (code == POINTER_TYPE || code == REFERENCE_TYPE
|
|
|
|
|
|| TYPE_PTRMEMFUNC_P (type))
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return fold (cp_convert_to_pointer (type, e));
|
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;
|
1999-03-23 01:01:48 +01:00
|
|
|
|
rval = build_type_conversion (type, e, 1);
|
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)
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("`%#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)
|
|
|
|
|
return fold (convert_to_real (type, e));
|
|
|
|
|
else if (code == COMPLEX_TYPE)
|
|
|
|
|
return fold (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);
|
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)
|
|
|
|
|
ctor = build_method_call (NULL_TREE, ctor_identifier,
|
|
|
|
|
build_expr_list (NULL_TREE, ctor),
|
|
|
|
|
TYPE_BINFO (type), flags);
|
|
|
|
|
if (ctor)
|
|
|
|
|
return build_cplus_new (type, ctor);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
1994-06-15 20:30:58 +02:00
|
|
|
|
/* If TYPE or TREE_TYPE (E) is not on the permanent_obstack,
|
1998-02-04 00:55:27 +01:00
|
|
|
|
then it won't be hashed and hence compare as not equal,
|
1994-02-24 02:02:37 +01:00
|
|
|
|
even when it is. */
|
|
|
|
|
if (code == ARRAY_TYPE
|
1994-06-15 20:30:58 +02:00
|
|
|
|
&& TREE_TYPE (TREE_TYPE (e)) == TREE_TYPE (type)
|
|
|
|
|
&& index_type_equal (TYPE_DOMAIN (TREE_TYPE (e)), TYPE_DOMAIN (type)))
|
|
|
|
|
return e;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
1995-05-27 02:15:16 +02:00
|
|
|
|
if (flags & LOOKUP_COMPLAIN)
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("conversion from `%T' to non-scalar type `%T' requested",
|
1995-05-27 02:15:16 +02:00
|
|
|
|
TREE_TYPE (expr), type);
|
|
|
|
|
if (flags & LOOKUP_SPECULATIVELY)
|
|
|
|
|
return NULL_TREE;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
return error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
on subtrees of already build trees after it has ripped them apart.
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
convert (type, expr)
|
|
|
|
|
tree type, expr;
|
|
|
|
|
{
|
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))
|
1997-05-29 01:20:02 +02:00
|
|
|
|
{
|
|
|
|
|
if (TREE_READONLY_DECL_P (expr))
|
|
|
|
|
expr = decl_constant_value (expr);
|
|
|
|
|
return fold (build1 (NOP_EXPR, type, expr));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
1994-12-16 03:07:31 +01:00
|
|
|
|
convert_force (type, expr, convtype)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree type;
|
|
|
|
|
tree expr;
|
1994-12-16 03:07:31 +01:00
|
|
|
|
int convtype;
|
1994-02-24 02:02:37 +01:00
|
|
|
|
{
|
|
|
|
|
register tree e = expr;
|
|
|
|
|
register enum tree_code code = TREE_CODE (type);
|
|
|
|
|
|
|
|
|
|
if (code == REFERENCE_TYPE)
|
1994-05-13 04:46:07 +02:00
|
|
|
|
return fold (convert_to_reference (type, e, CONV_C_CAST, LOOKUP_COMPLAIN,
|
|
|
|
|
NULL_TREE));
|
1994-02-24 02:02:37 +01:00
|
|
|
|
else if (TREE_CODE (TREE_TYPE (e)) == REFERENCE_TYPE)
|
|
|
|
|
e = convert_from_reference (e);
|
|
|
|
|
|
|
|
|
|
if (code == POINTER_TYPE)
|
|
|
|
|
return fold (convert_to_pointer_force (type, e));
|
|
|
|
|
|
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))
|
|
|
|
|
{
|
1996-07-11 03:13:25 +02:00
|
|
|
|
/* compatible pointer to member functions. */
|
1994-03-24 00:33:53 +01:00
|
|
|
|
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), e, 1);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
}
|
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.
|
|
|
|
|
|
|
|
|
|
If (FOR_SURE & 1) is non-zero, then we allow this type conversion
|
|
|
|
|
to take place immediately. Otherwise, we build a SAVE_EXPR
|
1995-10-12 03:33:51 +01:00
|
|
|
|
which can be evaluated if the results are ever needed.
|
|
|
|
|
|
|
|
|
|
Changes to this functions should be mirrored in user_harshness.
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
tree
|
1999-03-23 01:01:48 +01:00
|
|
|
|
build_type_conversion (xtype, expr, for_sure)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
tree xtype, expr;
|
|
|
|
|
int for_sure;
|
|
|
|
|
{
|
|
|
|
|
/* C++: check to see if we can convert this aggregate type
|
1995-01-24 09:19:58 +01:00
|
|
|
|
into the required type. */
|
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
|
|
|
|
return build_user_type_conversion
|
|
|
|
|
(xtype, expr, for_sure ? LOOKUP_NORMAL : 0);
|
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.)
|
|
|
|
|
which indicates which types are suitable. If COMPLAIN is 1, complain
|
|
|
|
|
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
|
|
|
|
|
build_expr_type_conversion (desires, expr, complain)
|
|
|
|
|
int desires;
|
|
|
|
|
tree expr;
|
|
|
|
|
int 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
|
|
|
|
|
1998-08-23 14:47:24 +02:00
|
|
|
|
if (expr == null_node
|
|
|
|
|
&& (desires & WANT_INT)
|
|
|
|
|
&& !(desires & WANT_NULL))
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_warning ("converting NULL to non-pointer type");
|
1998-08-23 14:47:24 +02:00
|
|
|
|
|
1999-05-10 14:12:58 +02:00
|
|
|
|
if (TREE_CODE (expr) == OFFSET_REF)
|
1995-10-12 03:33:51 +01:00
|
|
|
|
expr = resolve_offset_ref (expr);
|
|
|
|
|
expr = convert_from_reference (expr);
|
|
|
|
|
basetype = TREE_TYPE (expr);
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
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;
|
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
|
|
|
|
|
1998-06-10 05:13:19 +02:00
|
|
|
|
case FUNCTION_TYPE:
|
|
|
|
|
case ARRAY_TYPE:
|
|
|
|
|
return (desires & WANT_POINTER) ? default_conversion (expr)
|
|
|
|
|
: NULL_TREE;
|
|
|
|
|
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. */
|
|
|
|
|
|
|
|
|
|
if (! TYPE_HAS_CONVERSION (basetype))
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
candidate = TREE_TYPE (TREE_TYPE (cand));
|
|
|
|
|
if (TREE_CODE (candidate) == REFERENCE_TYPE)
|
|
|
|
|
candidate = TREE_TYPE (candidate);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (win)
|
|
|
|
|
{
|
|
|
|
|
if (winner)
|
|
|
|
|
{
|
|
|
|
|
if (complain)
|
|
|
|
|
{
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error ("ambiguous default type conversion from `%T'",
|
1998-06-10 05:13:19 +02:00
|
|
|
|
basetype);
|
1998-09-07 16:25:35 +02:00
|
|
|
|
cp_error (" candidate conversions include `%D' and `%D'",
|
1998-06-10 05:13:19 +02:00
|
|
|
|
winner, cand);
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
tree type = TREE_TYPE (TREE_TYPE (winner));
|
|
|
|
|
if (TREE_CODE (type) == REFERENCE_TYPE)
|
|
|
|
|
type = TREE_TYPE (type);
|
|
|
|
|
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
|
|
|
|
|
type_promotes_to (type)
|
|
|
|
|
tree type;
|
|
|
|
|
{
|
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
|
|
|
|
int type_quals;
|
1995-10-12 03:33:51 +01:00
|
|
|
|
|
|
|
|
|
if (type == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
|
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
|
|
|
|
type_quals = CP_TYPE_QUALS (type);
|
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));
|
|
|
|
|
tree totype = type_for_size (precision, 0);
|
|
|
|
|
if (TREE_UNSIGNED (type)
|
|
|
|
|
&& ! int_fits_type_p (TYPE_MAX_VALUE (type), totype))
|
|
|
|
|
type = type_for_size (precision, 1);
|
|
|
|
|
else
|
|
|
|
|
type = totype;
|
|
|
|
|
}
|
1994-04-29 00:48:45 +02:00
|
|
|
|
else if (C_PROMOTING_INTEGER_TYPE_P (type))
|
|
|
|
|
{
|
1996-10-11 22:08:01 +02:00
|
|
|
|
/* Retain unsignedness if really not getting bigger. */
|
1994-04-29 00:48:45 +02:00
|
|
|
|
if (TREE_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;
|
|
|
|
|
|
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
|
|
|
|
return cp_build_qualified_type (type, type_quals);
|
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. */
|
|
|
|
|
|
1998-01-19 23:41:40 +01:00
|
|
|
|
tree
|
|
|
|
|
perform_qualification_conversions (type, expr)
|
|
|
|
|
tree type;
|
|
|
|
|
tree expr;
|
|
|
|
|
{
|
1998-08-25 19:17:51 +02:00
|
|
|
|
if (TREE_CODE (type) == POINTER_TYPE
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE
|
|
|
|
|
&& comp_ptr_ttypes (TREE_TYPE (type), TREE_TYPE (TREE_TYPE (expr))))
|
1998-01-27 21:47:56 +01:00
|
|
|
|
return build1 (NOP_EXPR, type, expr);
|
|
|
|
|
else
|
|
|
|
|
return error_mark_node;
|
1998-01-19 23:41:40 +01:00
|
|
|
|
}
|