1996-09-18 05:35:50 +00:00
|
|
|
|
/* Language-dependent node constructors for parse phase of GNU compiler.
|
2002-02-01 18:16:02 +00:00
|
|
|
|
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
2005-06-03 03:28:44 +00:00
|
|
|
|
1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
1996-09-18 05:35:50 +00:00
|
|
|
|
Hacked by Michael Tiemann (tiemann@cygnus.com)
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
This file is part of GCC.
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
GCC is free software; you can redistribute it and/or modify
|
1996-09-18 05:35:50 +00:00
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
GCC is distributed in the hope that it will be useful,
|
1996-09-18 05:35:50 +00:00
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2004-07-28 03:11:36 +00:00
|
|
|
|
along with GCC; see the file COPYING. If not, write to
|
2007-05-19 01:19:51 +00:00
|
|
|
|
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
#include "config.h"
|
1999-08-26 09:30:50 +00:00
|
|
|
|
#include "system.h"
|
2004-07-28 03:11:36 +00:00
|
|
|
|
#include "coretypes.h"
|
|
|
|
|
#include "tm.h"
|
1996-09-18 05:35:50 +00:00
|
|
|
|
#include "tree.h"
|
|
|
|
|
#include "cp-tree.h"
|
|
|
|
|
#include "flags.h"
|
2003-07-11 03:40:53 +00:00
|
|
|
|
#include "real.h"
|
1996-09-18 05:35:50 +00:00
|
|
|
|
#include "rtl.h"
|
1999-08-26 09:30:50 +00:00
|
|
|
|
#include "toplev.h"
|
2002-02-01 18:16:02 +00:00
|
|
|
|
#include "insn-config.h"
|
|
|
|
|
#include "integrate.h"
|
|
|
|
|
#include "tree-inline.h"
|
2007-05-19 01:19:51 +00:00
|
|
|
|
#include "debug.h"
|
2003-07-11 03:40:53 +00:00
|
|
|
|
#include "target.h"
|
2007-05-19 01:19:51 +00:00
|
|
|
|
#include "convert.h"
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
static tree bot_manip (tree *, int *, void *);
|
|
|
|
|
static tree bot_replace (tree *, int *, void *);
|
|
|
|
|
static tree build_cplus_array_type_1 (tree, tree);
|
|
|
|
|
static int list_hash_eq (const void *, const void *);
|
|
|
|
|
static hashval_t list_hash_pieces (tree, tree, tree);
|
|
|
|
|
static hashval_t list_hash (const void *);
|
|
|
|
|
static cp_lvalue_kind lvalue_p_1 (tree, int);
|
|
|
|
|
static tree build_target_expr (tree, tree);
|
|
|
|
|
static tree count_trees_r (tree *, int *, void *);
|
|
|
|
|
static tree verify_stmt_tree_r (tree *, int *, void *);
|
|
|
|
|
static tree build_local_temp (tree);
|
|
|
|
|
|
|
|
|
|
static tree handle_java_interface_attribute (tree *, tree, tree, int, bool *);
|
|
|
|
|
static tree handle_com_interface_attribute (tree *, tree, tree, int, bool *);
|
|
|
|
|
static tree handle_init_priority_attribute (tree *, tree, tree, int, bool *);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
/* If REF is an lvalue, returns the kind of lvalue that REF is.
|
|
|
|
|
Otherwise, returns clk_none. If TREAT_CLASS_RVALUES_AS_LVALUES is
|
2003-07-11 03:40:53 +00:00
|
|
|
|
nonzero, rvalues of class type are considered lvalues. */
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
static cp_lvalue_kind
|
2007-05-19 01:19:51 +00:00
|
|
|
|
lvalue_p_1 (tree ref,
|
|
|
|
|
int treat_class_rvalues_as_lvalues)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
cp_lvalue_kind op1_lvalue_kind = clk_none;
|
|
|
|
|
cp_lvalue_kind op2_lvalue_kind = clk_none;
|
|
|
|
|
|
2013-12-20 16:01:02 +00:00
|
|
|
|
/* Expressions of reference type are sometimes wrapped in
|
|
|
|
|
INDIRECT_REFs. INDIRECT_REFs are just internal compiler
|
|
|
|
|
representation, not part of the language, so we have to look
|
|
|
|
|
through them. */
|
|
|
|
|
if (TREE_CODE (ref) == INDIRECT_REF
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 0)))
|
|
|
|
|
== REFERENCE_TYPE)
|
|
|
|
|
return lvalue_p_1 (TREE_OPERAND (ref, 0),
|
|
|
|
|
treat_class_rvalues_as_lvalues);
|
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
if (TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE)
|
2013-12-20 16:01:02 +00:00
|
|
|
|
{
|
|
|
|
|
/* unnamed rvalue references are rvalues */
|
|
|
|
|
if (TYPE_REF_IS_RVALUE (TREE_TYPE (ref))
|
|
|
|
|
&& TREE_CODE (ref) != PARM_DECL
|
|
|
|
|
&& TREE_CODE (ref) != VAR_DECL
|
|
|
|
|
&& TREE_CODE (ref) != COMPONENT_REF)
|
|
|
|
|
return clk_none;
|
|
|
|
|
|
|
|
|
|
/* lvalue references and named rvalue refences are lvalues */
|
|
|
|
|
return clk_ordinary;
|
|
|
|
|
}
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (ref == current_class_ptr)
|
|
|
|
|
return clk_none;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
switch (TREE_CODE (ref))
|
|
|
|
|
{
|
|
|
|
|
/* preincrements and predecrements are valid lvals, provided
|
1999-08-26 09:30:50 +00:00
|
|
|
|
what they refer to are valid lvals. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
case PREINCREMENT_EXPR:
|
|
|
|
|
case PREDECREMENT_EXPR:
|
|
|
|
|
case SAVE_EXPR:
|
1999-08-26 09:30:50 +00:00
|
|
|
|
case TRY_CATCH_EXPR:
|
|
|
|
|
case WITH_CLEANUP_EXPR:
|
1999-10-16 06:09:09 +00:00
|
|
|
|
case REALPART_EXPR:
|
|
|
|
|
case IMAGPART_EXPR:
|
|
|
|
|
return lvalue_p_1 (TREE_OPERAND (ref, 0),
|
2004-07-28 03:11:36 +00:00
|
|
|
|
treat_class_rvalues_as_lvalues);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
case COMPONENT_REF:
|
|
|
|
|
op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 0),
|
2004-07-28 03:11:36 +00:00
|
|
|
|
treat_class_rvalues_as_lvalues);
|
|
|
|
|
/* Look at the member designator. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (!op1_lvalue_kind
|
|
|
|
|
/* The "field" can be a FUNCTION_DECL or an OVERLOAD in some
|
|
|
|
|
situations. */
|
|
|
|
|
|| TREE_CODE (TREE_OPERAND (ref, 1)) != FIELD_DECL)
|
|
|
|
|
;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
else if (DECL_C_BIT_FIELD (TREE_OPERAND (ref, 1)))
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
/* Clear the ordinary bit. If this object was a class
|
|
|
|
|
rvalue we want to preserve that information. */
|
|
|
|
|
op1_lvalue_kind &= ~clk_ordinary;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
/* The lvalue is for a bitfield. */
|
2002-02-01 18:16:02 +00:00
|
|
|
|
op1_lvalue_kind |= clk_bitfield;
|
|
|
|
|
}
|
2004-07-28 03:11:36 +00:00
|
|
|
|
else if (DECL_PACKED (TREE_OPERAND (ref, 1)))
|
|
|
|
|
op1_lvalue_kind |= clk_packed;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return op1_lvalue_kind;
|
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
case STRING_CST:
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return clk_ordinary;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
case CONST_DECL:
|
1996-09-18 05:35:50 +00:00
|
|
|
|
case VAR_DECL:
|
|
|
|
|
if (TREE_READONLY (ref) && ! TREE_STATIC (ref)
|
|
|
|
|
&& DECL_LANG_SPECIFIC (ref)
|
|
|
|
|
&& DECL_IN_AGGR_P (ref))
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return clk_none;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
case INDIRECT_REF:
|
|
|
|
|
case ARRAY_REF:
|
|
|
|
|
case PARM_DECL:
|
|
|
|
|
case RESULT_DECL:
|
1999-10-16 06:09:09 +00:00
|
|
|
|
if (TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return clk_ordinary;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* A currently unresolved scope ref. */
|
|
|
|
|
case SCOPE_REF:
|
2007-05-19 01:19:51 +00:00
|
|
|
|
gcc_unreachable ();
|
2002-02-01 18:16:02 +00:00
|
|
|
|
case MAX_EXPR:
|
|
|
|
|
case MIN_EXPR:
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Disallow <? and >? as lvalues if either argument side-effects. */
|
|
|
|
|
if (TREE_SIDE_EFFECTS (TREE_OPERAND (ref, 0))
|
|
|
|
|
|| TREE_SIDE_EFFECTS (TREE_OPERAND (ref, 1)))
|
|
|
|
|
return clk_none;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 0),
|
2004-07-28 03:11:36 +00:00
|
|
|
|
treat_class_rvalues_as_lvalues);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
op2_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1),
|
2004-07-28 03:11:36 +00:00
|
|
|
|
treat_class_rvalues_as_lvalues);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case COND_EXPR:
|
2002-02-01 18:16:02 +00:00
|
|
|
|
op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1),
|
2004-07-28 03:11:36 +00:00
|
|
|
|
treat_class_rvalues_as_lvalues);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
op2_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 2),
|
2004-07-28 03:11:36 +00:00
|
|
|
|
treat_class_rvalues_as_lvalues);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
break;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
case MODIFY_EXPR:
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return clk_ordinary;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
case COMPOUND_EXPR:
|
1999-10-16 06:09:09 +00:00
|
|
|
|
return lvalue_p_1 (TREE_OPERAND (ref, 1),
|
2004-07-28 03:11:36 +00:00
|
|
|
|
treat_class_rvalues_as_lvalues);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
case TARGET_EXPR:
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return treat_class_rvalues_as_lvalues ? clk_class : clk_none;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
case VA_ARG_EXPR:
|
2007-05-19 01:19:51 +00:00
|
|
|
|
return (treat_class_rvalues_as_lvalues
|
|
|
|
|
&& CLASS_TYPE_P (TREE_TYPE (ref))
|
|
|
|
|
? clk_class : clk_none);
|
|
|
|
|
|
|
|
|
|
case CALL_EXPR:
|
2004-07-28 03:11:36 +00:00
|
|
|
|
/* Any class-valued call would be wrapped in a TARGET_EXPR. */
|
|
|
|
|
return clk_none;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
case FUNCTION_DECL:
|
|
|
|
|
/* All functions (except non-static-member functions) are
|
|
|
|
|
lvalues. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
return (DECL_NONSTATIC_MEMBER_FUNCTION_P (ref)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
? clk_none : clk_ordinary);
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
case NON_DEPENDENT_EXPR:
|
|
|
|
|
/* We must consider NON_DEPENDENT_EXPRs to be lvalues so that
|
|
|
|
|
things like "&E" where "E" is an expression with a
|
|
|
|
|
non-dependent type work. It is safe to be lenient because an
|
|
|
|
|
error will be issued when the template is instantiated if "E"
|
|
|
|
|
is not an lvalue. */
|
|
|
|
|
return clk_ordinary;
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* If one operand is not an lvalue at all, then this expression is
|
|
|
|
|
not an lvalue. */
|
|
|
|
|
if (!op1_lvalue_kind || !op2_lvalue_kind)
|
|
|
|
|
return clk_none;
|
|
|
|
|
|
|
|
|
|
/* Otherwise, it's an lvalue, and it has all the odd properties
|
|
|
|
|
contributed by either operand. */
|
|
|
|
|
op1_lvalue_kind = op1_lvalue_kind | op2_lvalue_kind;
|
|
|
|
|
/* It's not an ordinary lvalue if it involves either a bit-field or
|
|
|
|
|
a class rvalue. */
|
|
|
|
|
if ((op1_lvalue_kind & ~clk_ordinary) != clk_none)
|
|
|
|
|
op1_lvalue_kind &= ~clk_ordinary;
|
|
|
|
|
return op1_lvalue_kind;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 03:40:53 +00:00
|
|
|
|
/* Returns the kind of lvalue that REF is, in the sense of
|
|
|
|
|
[basic.lval]. This function should really be named lvalue_p; it
|
|
|
|
|
computes the C++ definition of lvalue. */
|
|
|
|
|
|
|
|
|
|
cp_lvalue_kind
|
2004-07-28 03:11:36 +00:00
|
|
|
|
real_lvalue_p (tree ref)
|
2003-07-11 03:40:53 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
return lvalue_p_1 (ref,
|
2004-07-28 03:11:36 +00:00
|
|
|
|
/*treat_class_rvalues_as_lvalues=*/0);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* This differs from real_lvalue_p in that class rvalues are
|
|
|
|
|
considered lvalues. */
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
lvalue_p (tree ref)
|
2003-07-11 03:40:53 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
return
|
2004-07-28 03:11:36 +00:00
|
|
|
|
(lvalue_p_1 (ref, /*class rvalue ok*/ 1) != clk_none);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Test whether DECL is a builtin that may appear in a
|
|
|
|
|
constant-expression. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
bool
|
|
|
|
|
builtin_valid_in_constant_expr_p (tree decl)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* At present BUILT_IN_CONSTANT_P is the only builtin we're allowing
|
|
|
|
|
in constant-expressions. We may want to add other builtins later. */
|
|
|
|
|
return DECL_IS_BUILTIN_CONSTANT_P (decl);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Build a TARGET_EXPR, initializing the DECL with the VALUE. */
|
|
|
|
|
|
|
|
|
|
static tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
build_target_expr (tree decl, tree value)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
tree t;
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
t = build4 (TARGET_EXPR, TREE_TYPE (decl), decl, value,
|
|
|
|
|
cxx_maybe_build_cleanup (decl), NULL_TREE);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* We always set TREE_SIDE_EFFECTS so that expand_expr does not
|
|
|
|
|
ignore the TARGET_EXPR. If there really turn out to be no
|
|
|
|
|
side-effects, then the optimizer should be able to get rid of
|
|
|
|
|
whatever code is generated anyhow. */
|
|
|
|
|
TREE_SIDE_EFFECTS (t) = 1;
|
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
/* Return an undeclared local temporary of type TYPE for use in building a
|
|
|
|
|
TARGET_EXPR. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
build_local_temp (tree type)
|
|
|
|
|
{
|
|
|
|
|
tree slot = build_decl (VAR_DECL, NULL_TREE, type);
|
|
|
|
|
DECL_ARTIFICIAL (slot) = 1;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
DECL_IGNORED_P (slot) = 1;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
DECL_CONTEXT (slot) = current_function_decl;
|
|
|
|
|
layout_decl (slot, 0);
|
|
|
|
|
return slot;
|
|
|
|
|
}
|
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
/* INIT is a CALL_EXPR which needs info about its target.
|
|
|
|
|
TYPE is the type that this initialization should appear to have.
|
|
|
|
|
|
|
|
|
|
Build an encapsulation of the initialization to perform
|
|
|
|
|
and return it so that it can be processed by language-independent
|
1999-08-26 09:30:50 +00:00
|
|
|
|
and language-specific expression expanders. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
build_cplus_new (tree type, tree init)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
tree fn;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
tree slot;
|
|
|
|
|
tree rval;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
int is_ctor;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Make sure that we're not trying to create an instance of an
|
|
|
|
|
abstract class. */
|
|
|
|
|
abstract_virtuals_error (NULL_TREE, type);
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
if (TREE_CODE (init) != CALL_EXPR && TREE_CODE (init) != AGGR_INIT_EXPR)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
return convert (type, init);
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
fn = TREE_OPERAND (init, 0);
|
|
|
|
|
is_ctor = (TREE_CODE (fn) == ADDR_EXPR
|
|
|
|
|
&& TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL
|
|
|
|
|
&& DECL_CONSTRUCTOR_P (TREE_OPERAND (fn, 0)));
|
|
|
|
|
|
|
|
|
|
slot = build_local_temp (type);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
/* We split the CALL_EXPR into its function and its arguments here.
|
|
|
|
|
Then, in expand_expr, we put them back together. The reason for
|
|
|
|
|
this is that this expression might be a default argument
|
|
|
|
|
expression. In that case, we need a new temporary every time the
|
|
|
|
|
expression is used. That's what break_out_target_exprs does; it
|
|
|
|
|
replaces every AGGR_INIT_EXPR with a copy that uses a fresh
|
|
|
|
|
temporary slot. Then, expand_expr builds up a call-expression
|
|
|
|
|
using the new slot. */
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
|
|
|
|
/* If we don't need to use a constructor to create an object of this
|
|
|
|
|
type, don't mess with AGGR_INIT_EXPR. */
|
|
|
|
|
if (is_ctor || TREE_ADDRESSABLE (type))
|
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
rval = build3 (AGGR_INIT_EXPR, void_type_node, fn,
|
|
|
|
|
TREE_OPERAND (init, 1), slot);
|
2004-07-28 03:11:36 +00:00
|
|
|
|
TREE_SIDE_EFFECTS (rval) = 1;
|
|
|
|
|
AGGR_INIT_VIA_CTOR_P (rval) = is_ctor;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
rval = init;
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
rval = build_target_expr (slot, rval);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
TARGET_EXPR_IMPLICIT_P (rval) = 1;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 03:40:53 +00:00
|
|
|
|
/* Build a TARGET_EXPR using INIT to initialize a new temporary of the
|
2002-02-01 18:16:02 +00:00
|
|
|
|
indicated TYPE. */
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
build_target_expr_with_type (tree init, tree type)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
gcc_assert (!VOID_TYPE_P (type));
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (TREE_CODE (init) == TARGET_EXPR)
|
|
|
|
|
return init;
|
2003-11-07 02:43:04 +00:00
|
|
|
|
else if (CLASS_TYPE_P (type) && !TYPE_HAS_TRIVIAL_INIT_REF (type)
|
|
|
|
|
&& TREE_CODE (init) != COND_EXPR
|
2004-07-28 03:11:36 +00:00
|
|
|
|
&& TREE_CODE (init) != CONSTRUCTOR
|
|
|
|
|
&& TREE_CODE (init) != VA_ARG_EXPR)
|
2003-11-07 02:43:04 +00:00
|
|
|
|
/* We need to build up a copy constructor call. COND_EXPR is a special
|
|
|
|
|
case because we already have copies on the arms and we don't want
|
|
|
|
|
another one here. A CONSTRUCTOR is aggregate initialization, which
|
2004-07-28 03:11:36 +00:00
|
|
|
|
is handled separately. A VA_ARG_EXPR is magic creation of an
|
|
|
|
|
aggregate; there's no additional work to be done. */
|
2003-11-07 02:43:04 +00:00
|
|
|
|
return force_rvalue (init);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
return force_target_expr (type, init);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
/* Like the above function, but without the checking. This function should
|
|
|
|
|
only be used by code which is deliberately trying to subvert the type
|
|
|
|
|
system, such as call_builtin_trap. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
force_target_expr (tree type, tree init)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
tree slot;
|
|
|
|
|
|
|
|
|
|
gcc_assert (!VOID_TYPE_P (type));
|
|
|
|
|
|
|
|
|
|
slot = build_local_temp (type);
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return build_target_expr (slot, init);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
|
|
|
|
/* Like build_target_expr_with_type, but use the type of INIT. */
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
get_target_expr (tree init)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return build_target_expr_with_type (init, TREE_TYPE (init));
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* If EXPR is a bitfield reference, convert it to the declared type of
|
|
|
|
|
the bitfield, and return the resulting expression. Otherwise,
|
|
|
|
|
return EXPR itself. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
convert_bitfield_to_declared_type (tree expr)
|
|
|
|
|
{
|
|
|
|
|
tree bitfield_type;
|
|
|
|
|
|
|
|
|
|
bitfield_type = is_bitfield_expr_with_lowered_type (expr);
|
|
|
|
|
if (bitfield_type)
|
|
|
|
|
expr = convert_to_integer (TYPE_MAIN_VARIANT (bitfield_type),
|
|
|
|
|
expr);
|
|
|
|
|
return expr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* EXPR is being used in an rvalue context. Return a version of EXPR
|
|
|
|
|
that is marked as an rvalue. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
rvalue (tree expr)
|
|
|
|
|
{
|
|
|
|
|
tree type;
|
|
|
|
|
|
|
|
|
|
if (error_operand_p (expr))
|
|
|
|
|
return expr;
|
|
|
|
|
|
|
|
|
|
/* [basic.lval]
|
|
|
|
|
|
|
|
|
|
Non-class rvalues always have cv-unqualified types. */
|
|
|
|
|
type = TREE_TYPE (expr);
|
|
|
|
|
if (!CLASS_TYPE_P (type) && cp_type_quals (type))
|
|
|
|
|
type = TYPE_MAIN_VARIANT (type);
|
|
|
|
|
|
|
|
|
|
if (!processing_template_decl && real_lvalue_p (expr))
|
|
|
|
|
expr = build1 (NON_LVALUE_EXPR, type, expr);
|
|
|
|
|
else if (type != TREE_TYPE (expr))
|
|
|
|
|
expr = build_nop (type, expr);
|
|
|
|
|
|
|
|
|
|
return expr;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
static tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
build_cplus_array_type_1 (tree elt_type, tree index_type)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
|
|
|
|
tree t;
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (elt_type == error_mark_node || index_type == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (dependent_type_p (elt_type)
|
|
|
|
|
|| (index_type
|
|
|
|
|
&& value_dependent_expression_p (TYPE_MAX_VALUE (index_type))))
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
|
|
|
|
t = make_node (ARRAY_TYPE);
|
|
|
|
|
TREE_TYPE (t) = elt_type;
|
|
|
|
|
TYPE_DOMAIN (t) = index_type;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
t = build_array_type (elt_type, index_type);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
/* Push these needs up so that initialization takes place
|
|
|
|
|
more easily. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
TYPE_NEEDS_CONSTRUCTING (t)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
= TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (elt_type));
|
2007-05-19 01:19:51 +00:00
|
|
|
|
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TYPE_MAIN_VARIANT (elt_type));
|
1996-09-18 05:35:50 +00:00
|
|
|
|
return t;
|
|
|
|
|
}
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
build_cplus_array_type (tree elt_type, tree index_type)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
|
|
|
|
tree t;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
int type_quals = cp_type_quals (elt_type);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (type_quals != TYPE_UNQUALIFIED)
|
|
|
|
|
elt_type = cp_build_qualified_type (elt_type, TYPE_UNQUALIFIED);
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
t = build_cplus_array_type_1 (elt_type, index_type);
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (type_quals != TYPE_UNQUALIFIED)
|
|
|
|
|
t = cp_build_qualified_type (t, type_quals);
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
}
|
2013-12-20 16:01:02 +00:00
|
|
|
|
|
|
|
|
|
/* Return a reference type node referring to TO_TYPE. If RVAL is
|
|
|
|
|
true, return an rvalue reference type, otherwise return an lvalue
|
|
|
|
|
reference type. If a type node exists, reuse it, otherwise create
|
|
|
|
|
a new one. */
|
|
|
|
|
tree
|
|
|
|
|
cp_build_reference_type (tree to_type, bool rval)
|
|
|
|
|
{
|
|
|
|
|
tree lvalue_ref, t;
|
|
|
|
|
lvalue_ref = build_reference_type (to_type);
|
|
|
|
|
if (!rval)
|
|
|
|
|
return lvalue_ref;
|
|
|
|
|
|
|
|
|
|
/* This code to create rvalue reference types is based on and tied
|
|
|
|
|
to the code creating lvalue reference types in the middle-end
|
|
|
|
|
functions build_reference_type_for_mode and build_reference_type.
|
|
|
|
|
|
|
|
|
|
It works by putting the rvalue reference type nodes after the
|
|
|
|
|
lvalue reference nodes in the TYPE_NEXT_REF_TO linked list, so
|
|
|
|
|
they will effectively be ignored by the middle end. */
|
|
|
|
|
|
|
|
|
|
for (t = lvalue_ref; (t = TYPE_NEXT_REF_TO (t)); )
|
|
|
|
|
if (TYPE_REF_IS_RVALUE (t))
|
|
|
|
|
return t;
|
|
|
|
|
|
|
|
|
|
t = copy_node (lvalue_ref);
|
|
|
|
|
|
|
|
|
|
TYPE_REF_IS_RVALUE (t) = true;
|
|
|
|
|
TYPE_NEXT_REF_TO (t) = TYPE_NEXT_REF_TO (lvalue_ref);
|
|
|
|
|
TYPE_NEXT_REF_TO (lvalue_ref) = t;
|
|
|
|
|
TYPE_MAIN_VARIANT (t) = t;
|
|
|
|
|
|
|
|
|
|
if (TYPE_STRUCTURAL_EQUALITY_P (to_type))
|
|
|
|
|
SET_TYPE_STRUCTURAL_EQUALITY (t);
|
|
|
|
|
else if (TYPE_CANONICAL (to_type) != to_type)
|
|
|
|
|
TYPE_CANONICAL (t)
|
|
|
|
|
= cp_build_reference_type (TYPE_CANONICAL (to_type), rval);
|
|
|
|
|
else
|
|
|
|
|
TYPE_CANONICAL (t) = t;
|
|
|
|
|
|
|
|
|
|
layout_type (t);
|
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Make a variant of TYPE, qualified with the TYPE_QUALS. Handles
|
|
|
|
|
arrays correctly. In particular, if TYPE is an array of T's, and
|
2002-05-09 20:02:13 +00:00
|
|
|
|
TYPE_QUALS is non-empty, returns an array of qualified T's.
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2002-05-09 20:02:13 +00:00
|
|
|
|
FLAGS determines how to deal with illformed qualifications. If
|
|
|
|
|
tf_ignore_bad_quals is set, then bad qualifications are dropped
|
|
|
|
|
(this is permitted if TYPE was introduced via a typedef or template
|
|
|
|
|
type parameter). If bad qualifications are dropped and tf_warning
|
|
|
|
|
is set, then a warning is issued for non-const qualifications. If
|
|
|
|
|
tf_ignore_bad_quals is not set and tf_error is not set, we
|
|
|
|
|
return error_mark_node. Otherwise, we issue an error, and ignore
|
|
|
|
|
the qualifications.
|
|
|
|
|
|
|
|
|
|
Qualification of a reference type is valid when the reference came
|
|
|
|
|
via a typedef or template type argument. [dcl.ref] No such
|
|
|
|
|
dispensation is provided for qualifying a function type. [dcl.fct]
|
|
|
|
|
DR 295 queries this and the proposed resolution brings it into line
|
2004-07-28 03:11:36 +00:00
|
|
|
|
with qualifying a reference. We implement the DR. We also behave
|
2002-05-09 20:02:13 +00:00
|
|
|
|
in a similar manner for restricting non-pointer types. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
tree
|
2007-05-19 01:19:51 +00:00
|
|
|
|
cp_build_qualified_type_real (tree type,
|
|
|
|
|
int type_quals,
|
|
|
|
|
tsubst_flags_t complain)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
tree result;
|
2002-05-09 20:02:13 +00:00
|
|
|
|
int bad_quals = TYPE_UNQUALIFIED;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
if (type == error_mark_node)
|
|
|
|
|
return type;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
if (type_quals == cp_type_quals (type))
|
|
|
|
|
return type;
|
|
|
|
|
|
2002-05-09 20:02:13 +00:00
|
|
|
|
if (TREE_CODE (type) == ARRAY_TYPE)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* In C++, the qualification really applies to the array element
|
|
|
|
|
type. Obtain the appropriately qualified element type. */
|
|
|
|
|
tree t;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
tree element_type
|
|
|
|
|
= cp_build_qualified_type_real (TREE_TYPE (type),
|
2002-02-01 18:16:02 +00:00
|
|
|
|
type_quals,
|
|
|
|
|
complain);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (element_type == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* See if we already have an identically qualified type. */
|
2003-07-11 03:40:53 +00:00
|
|
|
|
for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (cp_type_quals (t) == type_quals
|
2003-07-11 03:40:53 +00:00
|
|
|
|
&& TYPE_NAME (t) == TYPE_NAME (type)
|
|
|
|
|
&& TYPE_CONTEXT (t) == TYPE_CONTEXT (type))
|
|
|
|
|
break;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (!t)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Make a new array type, just like the old one, but with the
|
|
|
|
|
appropriately qualified element type. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
t = build_variant_type_copy (type);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
TREE_TYPE (t) = element_type;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Even if we already had this variant, we update
|
|
|
|
|
TYPE_NEEDS_CONSTRUCTING and TYPE_HAS_NONTRIVIAL_DESTRUCTOR in case
|
2007-05-19 01:19:51 +00:00
|
|
|
|
they changed since the variant was originally created.
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
This seems hokey; if there is some way to use a previous
|
|
|
|
|
variant *without* coming through here,
|
|
|
|
|
TYPE_NEEDS_CONSTRUCTING will never be updated. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
TYPE_NEEDS_CONSTRUCTING (t)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
= TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (element_type));
|
2007-05-19 01:19:51 +00:00
|
|
|
|
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TYPE_MAIN_VARIANT (element_type));
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
else if (TYPE_PTRMEMFUNC_P (type))
|
|
|
|
|
{
|
|
|
|
|
/* For a pointer-to-member type, we can't just return a
|
|
|
|
|
cv-qualified version of the RECORD_TYPE. If we do, we
|
2002-05-09 20:02:13 +00:00
|
|
|
|
haven't changed the field that contains the actual pointer to
|
2002-02-01 18:16:02 +00:00
|
|
|
|
a method, and so TYPE_PTRMEMFUNC_FN_TYPE will be wrong. */
|
|
|
|
|
tree t;
|
|
|
|
|
|
|
|
|
|
t = TYPE_PTRMEMFUNC_FN_TYPE (type);
|
|
|
|
|
t = cp_build_qualified_type_real (t, type_quals, complain);
|
|
|
|
|
return build_ptrmemfunc_type (t);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
|
|
|
|
/* A reference or method type shall not be cv qualified.
|
2004-07-28 03:11:36 +00:00
|
|
|
|
[dcl.ref], [dct.fct] */
|
|
|
|
|
if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)
|
|
|
|
|
&& (TREE_CODE (type) == REFERENCE_TYPE
|
|
|
|
|
|| TREE_CODE (type) == METHOD_TYPE))
|
|
|
|
|
{
|
|
|
|
|
bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
|
|
|
|
|
type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
|
|
|
|
|
}
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
/* A restrict-qualified type must be a pointer (or reference)
|
2007-05-19 01:19:51 +00:00
|
|
|
|
to object or incomplete type, or a function type. */
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if ((type_quals & TYPE_QUAL_RESTRICT)
|
|
|
|
|
&& TREE_CODE (type) != TEMPLATE_TYPE_PARM
|
|
|
|
|
&& TREE_CODE (type) != TYPENAME_TYPE
|
2007-05-19 01:19:51 +00:00
|
|
|
|
&& TREE_CODE (type) != FUNCTION_TYPE
|
2004-07-28 03:11:36 +00:00
|
|
|
|
&& !POINTER_TYPE_P (type))
|
|
|
|
|
{
|
|
|
|
|
bad_quals |= TYPE_QUAL_RESTRICT;
|
|
|
|
|
type_quals &= ~TYPE_QUAL_RESTRICT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bad_quals == TYPE_UNQUALIFIED)
|
|
|
|
|
/*OK*/;
|
|
|
|
|
else if (!(complain & (tf_error | tf_ignore_bad_quals)))
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (complain & tf_ignore_bad_quals)
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* We're not going to warn about constifying things that can't
|
|
|
|
|
be constified. */
|
|
|
|
|
bad_quals &= ~TYPE_QUAL_CONST;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (bad_quals)
|
2007-05-19 01:19:51 +00:00
|
|
|
|
{
|
|
|
|
|
tree bad_type = build_qualified_type (ptr_type_node, bad_quals);
|
|
|
|
|
|
|
|
|
|
if (!(complain & tf_ignore_bad_quals))
|
|
|
|
|
error ("%qV qualifiers cannot be applied to %qT",
|
2004-07-28 03:11:36 +00:00
|
|
|
|
bad_type, type);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
}
|
2004-07-28 03:11:36 +00:00
|
|
|
|
}
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Retrieve (or create) the appropriately qualified variant. */
|
|
|
|
|
result = build_qualified_type (type, type_quals);
|
|
|
|
|
|
|
|
|
|
/* If this was a pointer-to-method type, and we just made a copy,
|
2003-07-11 03:40:53 +00:00
|
|
|
|
then we need to unshare the record that holds the cached
|
|
|
|
|
pointer-to-member-function type, because these will be distinct
|
|
|
|
|
between the unqualified and qualified types. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (result != type
|
2002-02-01 18:16:02 +00:00
|
|
|
|
&& TREE_CODE (type) == POINTER_TYPE
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE)
|
2003-07-11 03:40:53 +00:00
|
|
|
|
TYPE_LANG_SPECIFIC (result) = NULL;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
/* Returns the canonical version of TYPE. In other words, if TYPE is
|
|
|
|
|
a typedef, returns the underlying type. The cv-qualification of
|
|
|
|
|
the type returned matches the type input; they will always be
|
|
|
|
|
compatible types. */
|
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
canonical_type_variant (tree t)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return cp_build_qualified_type (TYPE_MAIN_VARIANT (t), cp_type_quals (t));
|
1999-08-26 09:30:50 +00:00
|
|
|
|
}
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Makes a copy of BINFO and TYPE, which is to be inherited into a
|
|
|
|
|
graph dominated by T. If BINFO is NULL, TYPE is a dependent base,
|
|
|
|
|
and we do a shallow copy. If BINFO is non-NULL, we do a deep copy.
|
|
|
|
|
VIRT indicates whether TYPE is inherited virtually or not.
|
|
|
|
|
IGO_PREV points at the previous binfo of the inheritance graph
|
|
|
|
|
order chain. The newly copied binfo's TREE_CHAIN forms this
|
|
|
|
|
ordering.
|
|
|
|
|
|
|
|
|
|
The CLASSTYPE_VBASECLASSES vector of T is constructed in the
|
|
|
|
|
correct order. That is in the order the bases themselves should be
|
|
|
|
|
constructed in.
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
|
|
|
|
The BINFO_INHERITANCE of a virtual base class points to the binfo
|
2007-05-19 01:19:51 +00:00
|
|
|
|
of the most derived type. ??? We could probably change this so that
|
|
|
|
|
BINFO_INHERITANCE becomes synonymous with BINFO_PRIMARY, and hence
|
|
|
|
|
remove a field. They currently can only differ for primary virtual
|
|
|
|
|
virtual bases. */
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
|
|
|
|
tree
|
2007-05-19 01:19:51 +00:00
|
|
|
|
copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt)
|
|
|
|
|
{
|
|
|
|
|
tree new_binfo;
|
|
|
|
|
|
|
|
|
|
if (virt)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* See if we've already made this virtual base. */
|
|
|
|
|
new_binfo = binfo_for_vbase (type, t);
|
|
|
|
|
if (new_binfo)
|
|
|
|
|
return new_binfo;
|
|
|
|
|
}
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
new_binfo = make_tree_binfo (binfo ? BINFO_N_BASE_BINFOS (binfo) : 0);
|
|
|
|
|
BINFO_TYPE (new_binfo) = type;
|
|
|
|
|
|
|
|
|
|
/* Chain it into the inheritance graph. */
|
|
|
|
|
TREE_CHAIN (*igo_prev) = new_binfo;
|
|
|
|
|
*igo_prev = new_binfo;
|
|
|
|
|
|
|
|
|
|
if (binfo)
|
|
|
|
|
{
|
|
|
|
|
int ix;
|
|
|
|
|
tree base_binfo;
|
|
|
|
|
|
|
|
|
|
gcc_assert (!BINFO_DEPENDENT_BASE_P (binfo));
|
|
|
|
|
gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), type));
|
|
|
|
|
|
|
|
|
|
BINFO_OFFSET (new_binfo) = BINFO_OFFSET (binfo);
|
|
|
|
|
BINFO_VIRTUALS (new_binfo) = BINFO_VIRTUALS (binfo);
|
|
|
|
|
|
|
|
|
|
/* We do not need to copy the accesses, as they are read only. */
|
|
|
|
|
BINFO_BASE_ACCESSES (new_binfo) = BINFO_BASE_ACCESSES (binfo);
|
|
|
|
|
|
|
|
|
|
/* Recursively copy base binfos of BINFO. */
|
|
|
|
|
for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
|
2004-07-28 03:11:36 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
tree new_base_binfo;
|
|
|
|
|
|
|
|
|
|
gcc_assert (!BINFO_DEPENDENT_BASE_P (base_binfo));
|
|
|
|
|
new_base_binfo = copy_binfo (base_binfo, BINFO_TYPE (base_binfo),
|
|
|
|
|
t, igo_prev,
|
|
|
|
|
BINFO_VIRTUAL_P (base_binfo));
|
|
|
|
|
|
|
|
|
|
if (!BINFO_INHERITANCE_CHAIN (new_base_binfo))
|
|
|
|
|
BINFO_INHERITANCE_CHAIN (new_base_binfo) = new_binfo;
|
|
|
|
|
BINFO_BASE_APPEND (new_binfo, new_base_binfo);
|
2004-07-28 03:11:36 +00:00
|
|
|
|
}
|
1999-08-26 09:30:50 +00:00
|
|
|
|
}
|
2007-05-19 01:19:51 +00:00
|
|
|
|
else
|
|
|
|
|
BINFO_DEPENDENT_BASE_P (new_binfo) = 1;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (virt)
|
|
|
|
|
{
|
|
|
|
|
/* Push it onto the list after any virtual bases it contains
|
|
|
|
|
will have been pushed. */
|
|
|
|
|
VEC_quick_push (tree, CLASSTYPE_VBASECLASSES (t), new_binfo);
|
|
|
|
|
BINFO_VIRTUAL_P (new_binfo) = 1;
|
|
|
|
|
BINFO_INHERITANCE_CHAIN (new_binfo) = TYPE_BINFO (t);
|
|
|
|
|
}
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
return new_binfo;
|
|
|
|
|
}
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
/* Hashing of lists so that we don't make duplicates.
|
|
|
|
|
The entry point is `list_hash_canon'. */
|
|
|
|
|
|
|
|
|
|
/* Now here is the hash table. When recording a list, it is added
|
|
|
|
|
to the slot whose index is the hash code mod the table size.
|
|
|
|
|
Note that the hash table is used for several kinds of lists.
|
|
|
|
|
While all these live in the same table, they are completely independent,
|
|
|
|
|
and the hash code is computed differently for each of these. */
|
|
|
|
|
|
2003-07-11 03:40:53 +00:00
|
|
|
|
static GTY ((param_is (union tree_node))) htab_t list_hash_table;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
struct list_proxy
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
tree purpose;
|
|
|
|
|
tree value;
|
|
|
|
|
tree chain;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Compare ENTRY (an entry in the hash table) with DATA (a list_proxy
|
|
|
|
|
for a node we are thinking about adding). */
|
|
|
|
|
|
|
|
|
|
static int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
list_hash_eq (const void* entry, const void* data)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
tree t = (tree) entry;
|
|
|
|
|
struct list_proxy *proxy = (struct list_proxy *) data;
|
|
|
|
|
|
|
|
|
|
return (TREE_VALUE (t) == proxy->value
|
|
|
|
|
&& TREE_PURPOSE (t) == proxy->purpose
|
|
|
|
|
&& TREE_CHAIN (t) == proxy->chain);
|
|
|
|
|
}
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
/* Compute a hash code for a list (chain of TREE_LIST nodes
|
|
|
|
|
with goodies in the TREE_PURPOSE, TREE_VALUE, and bits of the
|
|
|
|
|
TREE_COMMON slots), by adding the hash codes of the individual entries. */
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
static hashval_t
|
2004-07-28 03:11:36 +00:00
|
|
|
|
list_hash_pieces (tree purpose, tree value, tree chain)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
hashval_t hashcode = 0;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
if (chain)
|
2007-05-19 01:19:51 +00:00
|
|
|
|
hashcode += TREE_HASH (chain);
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
if (value)
|
2007-05-19 01:19:51 +00:00
|
|
|
|
hashcode += TREE_HASH (value);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
else
|
|
|
|
|
hashcode += 1007;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
if (purpose)
|
2007-05-19 01:19:51 +00:00
|
|
|
|
hashcode += TREE_HASH (purpose);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
else
|
|
|
|
|
hashcode += 1009;
|
|
|
|
|
return hashcode;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Hash an already existing TREE_LIST. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
static hashval_t
|
2004-07-28 03:11:36 +00:00
|
|
|
|
list_hash (const void* p)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
tree t = (tree) p;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
return list_hash_pieces (TREE_PURPOSE (t),
|
|
|
|
|
TREE_VALUE (t),
|
2002-02-01 18:16:02 +00:00
|
|
|
|
TREE_CHAIN (t));
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-16 06:09:09 +00:00
|
|
|
|
/* Given list components PURPOSE, VALUE, AND CHAIN, return the canonical
|
|
|
|
|
object for an identical list if one already exists. Otherwise, build a
|
|
|
|
|
new one, and record it as the canonical object. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
hash_tree_cons (tree purpose, tree value, tree chain)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
1999-08-26 09:30:50 +00:00
|
|
|
|
int hashcode = 0;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
void **slot;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
struct list_proxy proxy;
|
|
|
|
|
|
|
|
|
|
/* Hash the list node. */
|
|
|
|
|
hashcode = list_hash_pieces (purpose, value, chain);
|
|
|
|
|
/* Create a proxy for the TREE_LIST we would like to create. We
|
|
|
|
|
don't actually create it so as to avoid creating garbage. */
|
|
|
|
|
proxy.purpose = purpose;
|
|
|
|
|
proxy.value = value;
|
|
|
|
|
proxy.chain = chain;
|
|
|
|
|
/* See if it is already in the table. */
|
|
|
|
|
slot = htab_find_slot_with_hash (list_hash_table, &proxy, hashcode,
|
|
|
|
|
INSERT);
|
|
|
|
|
/* If not, create a new node. */
|
|
|
|
|
if (!*slot)
|
2004-07-28 03:11:36 +00:00
|
|
|
|
*slot = tree_cons (purpose, value, chain);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
return (tree) *slot;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Constructor for hashed lists. */
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
hash_tree_chain (tree value, tree chain)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
1999-10-16 06:09:09 +00:00
|
|
|
|
return hash_tree_cons (NULL_TREE, value, chain);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2004-07-28 03:11:36 +00:00
|
|
|
|
debug_binfo (tree elem)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
HOST_WIDE_INT n;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
tree virtuals;
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
fprintf (stderr, "type \"%s\", offset = " HOST_WIDE_INT_PRINT_DEC
|
|
|
|
|
"\nvtable type:\n",
|
|
|
|
|
TYPE_NAME_STRING (BINFO_TYPE (elem)),
|
2002-02-01 18:16:02 +00:00
|
|
|
|
TREE_INT_CST_LOW (BINFO_OFFSET (elem)));
|
1996-09-18 05:35:50 +00:00
|
|
|
|
debug_tree (BINFO_TYPE (elem));
|
|
|
|
|
if (BINFO_VTABLE (elem))
|
2002-02-01 18:16:02 +00:00
|
|
|
|
fprintf (stderr, "vtable decl \"%s\"\n",
|
|
|
|
|
IDENTIFIER_POINTER (DECL_NAME (get_vtbl_decl_for_binfo (elem))));
|
1996-09-18 05:35:50 +00:00
|
|
|
|
else
|
|
|
|
|
fprintf (stderr, "no vtable decl yet\n");
|
|
|
|
|
fprintf (stderr, "virtuals:\n");
|
|
|
|
|
virtuals = BINFO_VIRTUALS (elem);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
n = 0;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
while (virtuals)
|
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
tree fndecl = TREE_VALUE (virtuals);
|
1999-08-26 09:30:50 +00:00
|
|
|
|
fprintf (stderr, "%s [%ld =? %ld]\n",
|
1996-09-18 05:35:50 +00:00
|
|
|
|
IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl)),
|
1999-08-26 09:30:50 +00:00
|
|
|
|
(long) n, (long) TREE_INT_CST_LOW (DECL_VINDEX (fndecl)));
|
1996-09-18 05:35:50 +00:00
|
|
|
|
++n;
|
|
|
|
|
virtuals = TREE_CHAIN (virtuals);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Build a representation for the qualified name SCOPE::NAME. TYPE is
|
|
|
|
|
the type of the result expression, if known, or NULL_TREE if the
|
|
|
|
|
resulting expression is type-dependent. If TEMPLATE_P is true,
|
|
|
|
|
NAME is known to be a template because the user explicitly used the
|
|
|
|
|
"template" keyword after the "::".
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
All SCOPE_REFs should be built by use of this function. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
build_qualified_name (tree type, tree scope, tree name, bool template_p)
|
|
|
|
|
{
|
|
|
|
|
tree t;
|
|
|
|
|
if (type == error_mark_node
|
|
|
|
|
|| scope == error_mark_node
|
|
|
|
|
|| name == error_mark_node)
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
t = build2 (SCOPE_REF, type, scope, name);
|
|
|
|
|
QUALIFIED_NAME_IS_TEMPLATE (t) = template_p;
|
|
|
|
|
return t;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Returns non-zero if X is an expression for a (possibly overloaded)
|
|
|
|
|
function. If "f" is a function or function template, "f", "c->f",
|
|
|
|
|
"c.f", "C::f", and "f<int>" will all be considered possibly
|
|
|
|
|
overloaded functions. Returns 2 if the function is actually
|
|
|
|
|
overloaded, i.e., if it is impossible to know the the type of the
|
|
|
|
|
function without performing overload resolution. */
|
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
is_overloaded_fn (tree x)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
1999-10-16 06:09:09 +00:00
|
|
|
|
/* A baselink is also considered an overloaded function. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (TREE_CODE (x) == OFFSET_REF
|
|
|
|
|
|| TREE_CODE (x) == COMPONENT_REF)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
x = TREE_OPERAND (x, 1);
|
|
|
|
|
if (BASELINK_P (x))
|
2003-07-11 03:40:53 +00:00
|
|
|
|
x = BASELINK_FUNCTIONS (x);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (TREE_CODE (x) == TEMPLATE_ID_EXPR
|
|
|
|
|
|| DECL_FUNCTION_TEMPLATE_P (OVL_CURRENT (x))
|
|
|
|
|
|| (TREE_CODE (x) == OVERLOAD && OVL_CHAIN (x)))
|
|
|
|
|
return 2;
|
|
|
|
|
return (TREE_CODE (x) == FUNCTION_DECL
|
|
|
|
|
|| TREE_CODE (x) == OVERLOAD);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Returns true iff X is an expression for an overloaded function
|
|
|
|
|
whose type cannot be known without performing overload
|
|
|
|
|
resolution. */
|
|
|
|
|
|
|
|
|
|
bool
|
2004-07-28 03:11:36 +00:00
|
|
|
|
really_overloaded_fn (tree x)
|
2007-05-19 01:19:51 +00:00
|
|
|
|
{
|
|
|
|
|
return is_overloaded_fn (x) == 2;
|
2003-07-11 03:40:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
get_first_fn (tree from)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
gcc_assert (is_overloaded_fn (from));
|
2003-07-11 03:40:53 +00:00
|
|
|
|
/* A baselink is also considered an overloaded function. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (TREE_CODE (from) == COMPONENT_REF)
|
|
|
|
|
from = TREE_OPERAND (from, 1);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
if (BASELINK_P (from))
|
2003-07-11 03:40:53 +00:00
|
|
|
|
from = BASELINK_FUNCTIONS (from);
|
1999-08-26 09:30:50 +00:00
|
|
|
|
return OVL_CURRENT (from);
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 03:40:53 +00:00
|
|
|
|
/* Return a new OVL node, concatenating it with the old one. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
ovl_cons (tree decl, tree chain)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
|
|
|
|
tree result = make_node (OVERLOAD);
|
|
|
|
|
TREE_TYPE (result) = unknown_type_node;
|
|
|
|
|
OVL_FUNCTION (result) = decl;
|
|
|
|
|
TREE_CHAIN (result) = chain;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
return result;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
/* Build a new overloaded function. If this is the first one,
|
|
|
|
|
just return it; otherwise, ovl_cons the _DECLs */
|
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
build_overload (tree decl, tree chain)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
1999-10-16 06:09:09 +00:00
|
|
|
|
if (! chain && TREE_CODE (decl) != TEMPLATE_DECL)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
return decl;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
if (chain && TREE_CODE (chain) != OVERLOAD)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
chain = ovl_cons (chain, NULL_TREE);
|
|
|
|
|
return ovl_cons (decl, chain);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define PRINT_RING_SIZE 4
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
const char *
|
2004-07-28 03:11:36 +00:00
|
|
|
|
cxx_printable_name (tree decl, int v)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
|
|
|
|
static tree decl_ring[PRINT_RING_SIZE];
|
|
|
|
|
static char *print_ring[PRINT_RING_SIZE];
|
|
|
|
|
static int ring_counter;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* Only cache functions. */
|
1999-08-26 09:30:50 +00:00
|
|
|
|
if (v < 2
|
|
|
|
|
|| TREE_CODE (decl) != FUNCTION_DECL
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|| DECL_LANG_SPECIFIC (decl) == 0)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
return lang_decl_name (decl, v);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
/* See if this print name is lying around. */
|
|
|
|
|
for (i = 0; i < PRINT_RING_SIZE; i++)
|
|
|
|
|
if (decl_ring[i] == decl)
|
|
|
|
|
/* yes, so return it. */
|
|
|
|
|
return print_ring[i];
|
|
|
|
|
|
|
|
|
|
if (++ring_counter == PRINT_RING_SIZE)
|
|
|
|
|
ring_counter = 0;
|
|
|
|
|
|
|
|
|
|
if (current_function_decl != NULL_TREE)
|
|
|
|
|
{
|
|
|
|
|
if (decl_ring[ring_counter] == current_function_decl)
|
|
|
|
|
ring_counter += 1;
|
|
|
|
|
if (ring_counter == PRINT_RING_SIZE)
|
|
|
|
|
ring_counter = 0;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
gcc_assert (decl_ring[ring_counter] != current_function_decl);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (print_ring[ring_counter])
|
|
|
|
|
free (print_ring[ring_counter]);
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
print_ring[ring_counter] = xstrdup (lang_decl_name (decl, v));
|
|
|
|
|
decl_ring[ring_counter] = decl;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
return print_ring[ring_counter];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Build the FUNCTION_TYPE or METHOD_TYPE which may throw exceptions
|
|
|
|
|
listed in RAISES. */
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
build_exception_variant (tree type, tree raises)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
|
|
|
|
tree v = TYPE_MAIN_VARIANT (type);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
int type_quals = TYPE_QUALS (type);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
for (; v; v = TYPE_NEXT_VARIANT (v))
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (check_qualified_type (v, type, type_quals)
|
|
|
|
|
&& comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (v), 1))
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return v;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
/* Need to build a new variant. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
v = build_variant_type_copy (type);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
TYPE_RAISES_EXCEPTIONS (v) = raises;
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Given a TEMPLATE_TEMPLATE_PARM node T, create a new
|
|
|
|
|
BOUND_TEMPLATE_TEMPLATE_PARM bound with NEWARGS as its template
|
|
|
|
|
arguments. */
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
bind_template_template_parm (tree t, tree newargs)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
tree decl = TYPE_NAME (t);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
tree t2;
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
t2 = make_aggr_type (BOUND_TEMPLATE_TEMPLATE_PARM);
|
|
|
|
|
decl = build_decl (TYPE_DECL, DECL_NAME (decl), NULL_TREE);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* These nodes have to be created to reflect new TYPE_DECL and template
|
|
|
|
|
arguments. */
|
|
|
|
|
TEMPLATE_TYPE_PARM_INDEX (t2) = copy_node (TEMPLATE_TYPE_PARM_INDEX (t));
|
|
|
|
|
TEMPLATE_PARM_DECL (TEMPLATE_TYPE_PARM_INDEX (t2)) = decl;
|
|
|
|
|
TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (t2)
|
2007-05-19 01:19:51 +00:00
|
|
|
|
= tree_cons (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t),
|
2002-02-01 18:16:02 +00:00
|
|
|
|
newargs, NULL_TREE);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
TREE_TYPE (decl) = t2;
|
|
|
|
|
TYPE_NAME (t2) = decl;
|
|
|
|
|
TYPE_STUB_DECL (t2) = decl;
|
|
|
|
|
TYPE_SIZE (t2) = 0;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
return t2;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Called from count_trees via walk_tree. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
static tree
|
2007-05-19 01:19:51 +00:00
|
|
|
|
count_trees_r (tree *tp, int *walk_subtrees, void *data)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
++*((int *) data);
|
|
|
|
|
|
|
|
|
|
if (TYPE_P (*tp))
|
|
|
|
|
*walk_subtrees = 0;
|
|
|
|
|
|
1999-10-16 06:09:09 +00:00
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Debugging function for measuring the rough complexity of a tree
|
|
|
|
|
representation. */
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
count_trees (tree t)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
int n_trees = 0;
|
|
|
|
|
walk_tree_without_duplicates (&t, count_trees_r, &n_trees);
|
|
|
|
|
return n_trees;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
}
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Called from verify_stmt_tree via walk_tree. */
|
|
|
|
|
|
|
|
|
|
static tree
|
2007-05-19 01:19:51 +00:00
|
|
|
|
verify_stmt_tree_r (tree* tp,
|
|
|
|
|
int* walk_subtrees ATTRIBUTE_UNUSED ,
|
|
|
|
|
void* data)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
tree t = *tp;
|
|
|
|
|
htab_t *statements = (htab_t *) data;
|
|
|
|
|
void **slot;
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (!STATEMENT_CODE_P (TREE_CODE (t)))
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return NULL_TREE;
|
|
|
|
|
|
|
|
|
|
/* If this statement is already present in the hash table, then
|
|
|
|
|
there is a circularity in the statement tree. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
gcc_assert (!htab_find (*statements, t));
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
slot = htab_find_slot (*statements, t, INSERT);
|
|
|
|
|
*slot = t;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Debugging function to check that the statement T has not been
|
|
|
|
|
corrupted. For now, this function simply checks that T contains no
|
|
|
|
|
circularities. */
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
void
|
2004-07-28 03:11:36 +00:00
|
|
|
|
verify_stmt_tree (tree t)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
htab_t statements;
|
|
|
|
|
statements = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
|
|
|
|
|
walk_tree (&t, verify_stmt_tree_r, &statements, NULL);
|
|
|
|
|
htab_delete (statements);
|
|
|
|
|
}
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Check if the type T depends on a type with no linkage and if so, return
|
2007-05-19 01:19:51 +00:00
|
|
|
|
it. If RELAXED_P then do not consider a class type declared within
|
|
|
|
|
a TREE_PUBLIC function to have no linkage. */
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
tree
|
2007-05-19 01:19:51 +00:00
|
|
|
|
no_linkage_check (tree t, bool relaxed_p)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
tree r;
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* There's no point in checking linkage on template functions; we
|
|
|
|
|
can't know their complete types. */
|
|
|
|
|
if (processing_template_decl)
|
|
|
|
|
return NULL_TREE;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
switch (TREE_CODE (t))
|
|
|
|
|
{
|
|
|
|
|
tree fn;
|
|
|
|
|
|
|
|
|
|
case RECORD_TYPE:
|
|
|
|
|
if (TYPE_PTRMEMFUNC_P (t))
|
|
|
|
|
goto ptrmem;
|
|
|
|
|
/* Fall through. */
|
|
|
|
|
case UNION_TYPE:
|
|
|
|
|
if (!CLASS_TYPE_P (t))
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
/* Fall through. */
|
|
|
|
|
case ENUMERAL_TYPE:
|
|
|
|
|
if (TYPE_ANONYMOUS_P (t))
|
|
|
|
|
return t;
|
|
|
|
|
fn = decl_function_context (TYPE_MAIN_DECL (t));
|
|
|
|
|
if (fn && (!relaxed_p || !TREE_PUBLIC (fn)))
|
|
|
|
|
return t;
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
|
|
|
|
|
case ARRAY_TYPE:
|
|
|
|
|
case POINTER_TYPE:
|
|
|
|
|
case REFERENCE_TYPE:
|
|
|
|
|
return no_linkage_check (TREE_TYPE (t), relaxed_p);
|
|
|
|
|
|
|
|
|
|
case OFFSET_TYPE:
|
|
|
|
|
ptrmem:
|
|
|
|
|
r = no_linkage_check (TYPE_PTRMEM_POINTED_TO_TYPE (t),
|
|
|
|
|
relaxed_p);
|
|
|
|
|
if (r)
|
|
|
|
|
return r;
|
|
|
|
|
return no_linkage_check (TYPE_PTRMEM_CLASS_TYPE (t), relaxed_p);
|
|
|
|
|
|
|
|
|
|
case METHOD_TYPE:
|
|
|
|
|
r = no_linkage_check (TYPE_METHOD_BASETYPE (t), relaxed_p);
|
|
|
|
|
if (r)
|
|
|
|
|
return r;
|
|
|
|
|
/* Fall through. */
|
|
|
|
|
case FUNCTION_TYPE:
|
|
|
|
|
{
|
|
|
|
|
tree parm;
|
|
|
|
|
for (parm = TYPE_ARG_TYPES (t);
|
|
|
|
|
parm && parm != void_list_node;
|
|
|
|
|
parm = TREE_CHAIN (parm))
|
|
|
|
|
{
|
|
|
|
|
r = no_linkage_check (TREE_VALUE (parm), relaxed_p);
|
|
|
|
|
if (r)
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
return no_linkage_check (TREE_TYPE (t), relaxed_p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
#ifdef GATHER_STATISTICS
|
|
|
|
|
extern int depth_reached;
|
|
|
|
|
#endif
|
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
void
|
2004-07-28 03:11:36 +00:00
|
|
|
|
cxx_print_statistics (void)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
|
|
|
|
print_search_statistics ();
|
|
|
|
|
print_class_statistics ();
|
1999-08-26 09:30:50 +00:00
|
|
|
|
#ifdef GATHER_STATISTICS
|
|
|
|
|
fprintf (stderr, "maximum template instantiation depth reached: %d\n",
|
|
|
|
|
depth_reached);
|
|
|
|
|
#endif
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
/* Return, as an INTEGER_CST node, the number of elements for TYPE
|
|
|
|
|
(which is an ARRAY_TYPE). This counts only elements of the top
|
|
|
|
|
array. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
array_type_nelts_top (tree type)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
return fold_build2 (PLUS_EXPR, sizetype,
|
1996-09-18 05:35:50 +00:00
|
|
|
|
array_type_nelts (type),
|
2007-05-19 01:19:51 +00:00
|
|
|
|
integer_one_node);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
/* Return, as an INTEGER_CST node, the number of elements for TYPE
|
|
|
|
|
(which is an ARRAY_TYPE). This one is a recursive count of all
|
|
|
|
|
ARRAY_TYPEs that are clumped together. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
array_type_nelts_total (tree type)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
|
|
|
|
tree sz = array_type_nelts_top (type);
|
|
|
|
|
type = TREE_TYPE (type);
|
|
|
|
|
while (TREE_CODE (type) == ARRAY_TYPE)
|
|
|
|
|
{
|
|
|
|
|
tree n = array_type_nelts_top (type);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
sz = fold_build2 (MULT_EXPR, sizetype, sz, n);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
type = TREE_TYPE (type);
|
|
|
|
|
}
|
|
|
|
|
return sz;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Called from break_out_target_exprs via mapcar. */
|
|
|
|
|
|
|
|
|
|
static tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
bot_manip (tree* tp, int* walk_subtrees, void* data)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
splay_tree target_remap = ((splay_tree) data);
|
|
|
|
|
tree t = *tp;
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (!TYPE_P (t) && TREE_CONSTANT (t))
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* There can't be any TARGET_EXPRs or their slot variables below
|
2007-05-19 01:19:51 +00:00
|
|
|
|
this point. We used to check !TREE_SIDE_EFFECTS, but then we
|
|
|
|
|
failed to copy an ADDR_EXPR of the slot VAR_DECL. */
|
2002-02-01 18:16:02 +00:00
|
|
|
|
*walk_subtrees = 0;
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
if (TREE_CODE (t) == TARGET_EXPR)
|
|
|
|
|
{
|
|
|
|
|
tree u;
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
if (TREE_CODE (TREE_OPERAND (t, 1)) == AGGR_INIT_EXPR)
|
2007-05-19 01:19:51 +00:00
|
|
|
|
u = build_cplus_new
|
|
|
|
|
(TREE_TYPE (t), break_out_target_exprs (TREE_OPERAND (t, 1)));
|
|
|
|
|
else
|
|
|
|
|
u = build_target_expr_with_type
|
|
|
|
|
(break_out_target_exprs (TREE_OPERAND (t, 1)), TREE_TYPE (t));
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
/* Map the old variable to the new one. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
splay_tree_insert (target_remap,
|
|
|
|
|
(splay_tree_key) TREE_OPERAND (t, 0),
|
2002-02-01 18:16:02 +00:00
|
|
|
|
(splay_tree_value) TREE_OPERAND (u, 0));
|
|
|
|
|
|
|
|
|
|
/* Replace the old expression with the new version. */
|
|
|
|
|
*tp = u;
|
|
|
|
|
/* We don't have to go below this point; the recursive call to
|
|
|
|
|
break_out_target_exprs will have handled anything below this
|
|
|
|
|
point. */
|
|
|
|
|
*walk_subtrees = 0;
|
|
|
|
|
return NULL_TREE;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Make a copy of this node. */
|
|
|
|
|
return copy_tree_r (tp, walk_subtrees, NULL);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Replace all remapped VAR_DECLs in T with their new equivalents.
|
|
|
|
|
DATA is really a splay-tree mapping old variables to new
|
|
|
|
|
variables. */
|
|
|
|
|
|
|
|
|
|
static tree
|
2007-05-19 01:19:51 +00:00
|
|
|
|
bot_replace (tree* t,
|
|
|
|
|
int* walk_subtrees ATTRIBUTE_UNUSED ,
|
|
|
|
|
void* data)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
splay_tree target_remap = ((splay_tree) data);
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (*t) == VAR_DECL)
|
|
|
|
|
{
|
|
|
|
|
splay_tree_node n = splay_tree_lookup (target_remap,
|
|
|
|
|
(splay_tree_key) *t);
|
|
|
|
|
if (n)
|
|
|
|
|
*t = (tree) n->value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* When we parse a default argument expression, we may create
|
|
|
|
|
temporary variables via TARGET_EXPRs. When we actually use the
|
|
|
|
|
default-argument expression, we make a copy of the expression, but
|
|
|
|
|
we must replace the temporaries with appropriate local versions. */
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
break_out_target_exprs (tree t)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
static int target_remap_count;
|
|
|
|
|
static splay_tree target_remap;
|
|
|
|
|
|
|
|
|
|
if (!target_remap_count++)
|
2007-05-19 01:19:51 +00:00
|
|
|
|
target_remap = splay_tree_new (splay_tree_compare_pointers,
|
|
|
|
|
/*splay_tree_delete_key_fn=*/NULL,
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/*splay_tree_delete_value_fn=*/NULL);
|
|
|
|
|
walk_tree (&t, bot_manip, target_remap, NULL);
|
|
|
|
|
walk_tree (&t, bot_replace, target_remap, NULL);
|
|
|
|
|
|
|
|
|
|
if (!--target_remap_count)
|
|
|
|
|
{
|
|
|
|
|
splay_tree_delete (target_remap);
|
|
|
|
|
target_remap = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return t;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
/* Similar to `build_nt', but for template definitions of dependent
|
|
|
|
|
expressions */
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
build_min_nt (enum tree_code code, ...)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2004-07-28 03:11:36 +00:00
|
|
|
|
tree t;
|
|
|
|
|
int length;
|
|
|
|
|
int i;
|
|
|
|
|
va_list p;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
va_start (p, code);
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
t = make_node (code);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
length = TREE_CODE_LENGTH (code);
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
|
{
|
|
|
|
|
tree x = va_arg (p, tree);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
TREE_OPERAND (t, i) = x;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
va_end (p);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
/* Similar to `build', but for template definitions. */
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
build_min (enum tree_code code, tree tt, ...)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2004-07-28 03:11:36 +00:00
|
|
|
|
tree t;
|
|
|
|
|
int length;
|
|
|
|
|
int i;
|
|
|
|
|
va_list p;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
va_start (p, tt);
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
t = make_node (code);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
length = TREE_CODE_LENGTH (code);
|
|
|
|
|
TREE_TYPE (t) = tt;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
|
{
|
|
|
|
|
tree x = va_arg (p, tree);
|
|
|
|
|
TREE_OPERAND (t, i) = x;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (x && !TYPE_P (x) && TREE_SIDE_EFFECTS (x))
|
2004-07-28 03:11:36 +00:00
|
|
|
|
TREE_SIDE_EFFECTS (t) = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
va_end (p);
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Similar to `build', but for template definitions of non-dependent
|
|
|
|
|
expressions. NON_DEP is the non-dependent expression that has been
|
|
|
|
|
built. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
build_min_non_dep (enum tree_code code, tree non_dep, ...)
|
|
|
|
|
{
|
|
|
|
|
tree t;
|
|
|
|
|
int length;
|
|
|
|
|
int i;
|
|
|
|
|
va_list p;
|
|
|
|
|
|
|
|
|
|
va_start (p, non_dep);
|
|
|
|
|
|
|
|
|
|
t = make_node (code);
|
|
|
|
|
length = TREE_CODE_LENGTH (code);
|
|
|
|
|
TREE_TYPE (t) = TREE_TYPE (non_dep);
|
|
|
|
|
TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (non_dep);
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
1999-08-26 09:30:50 +00:00
|
|
|
|
tree x = va_arg (p, tree);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
TREE_OPERAND (t, i) = x;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (code == COMPOUND_EXPR && TREE_CODE (non_dep) != COMPOUND_EXPR)
|
|
|
|
|
/* This should not be considered a COMPOUND_EXPR, because it
|
|
|
|
|
resolves to an overload. */
|
|
|
|
|
COMPOUND_EXPR_OVERLOADED (t) = 1;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
va_end (p);
|
1999-08-26 09:30:50 +00:00
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
get_type_decl (tree t)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (TREE_CODE (t) == TYPE_DECL)
|
|
|
|
|
return t;
|
|
|
|
|
if (TYPE_P (t))
|
|
|
|
|
return TYPE_STUB_DECL (t);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
gcc_assert (t == error_mark_node);
|
|
|
|
|
return t;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-16 06:09:09 +00:00
|
|
|
|
/* Returns the namespace that contains DECL, whether directly or
|
|
|
|
|
indirectly. */
|
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
decl_namespace_context (tree decl)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (decl) == NAMESPACE_DECL)
|
|
|
|
|
return decl;
|
|
|
|
|
else if (TYPE_P (decl))
|
|
|
|
|
decl = CP_DECL_CONTEXT (TYPE_MAIN_DECL (decl));
|
|
|
|
|
else
|
|
|
|
|
decl = CP_DECL_CONTEXT (decl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Returns true if decl is within an anonymous namespace, however deeply
|
|
|
|
|
nested, or false otherwise. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
decl_anon_ns_mem_p (tree decl)
|
|
|
|
|
{
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
if (decl == NULL_TREE || decl == error_mark_node)
|
|
|
|
|
return false;
|
|
|
|
|
if (TREE_CODE (decl) == NAMESPACE_DECL
|
|
|
|
|
&& DECL_NAME (decl) == NULL_TREE)
|
|
|
|
|
return true;
|
|
|
|
|
/* Classes and namespaces inside anonymous namespaces have
|
|
|
|
|
TREE_PUBLIC == 0, so we can shortcut the search. */
|
|
|
|
|
else if (TYPE_P (decl))
|
|
|
|
|
return (TREE_PUBLIC (TYPE_NAME (decl)) == 0);
|
|
|
|
|
else if (TREE_CODE (decl) == NAMESPACE_DECL)
|
|
|
|
|
return (TREE_PUBLIC (decl) == 0);
|
|
|
|
|
else
|
|
|
|
|
decl = DECL_CONTEXT (decl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
/* Return truthvalue of whether T1 is the same tree structure as T2.
|
2004-07-28 03:11:36 +00:00
|
|
|
|
Return 1 if they are the same. Return 0 if they are different. */
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
bool
|
|
|
|
|
cp_tree_equal (tree t1, tree t2)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
2004-07-28 03:11:36 +00:00
|
|
|
|
enum tree_code code1, code2;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
if (t1 == t2)
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return true;
|
|
|
|
|
if (!t1 || !t2)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
for (code1 = TREE_CODE (t1);
|
|
|
|
|
code1 == NOP_EXPR || code1 == CONVERT_EXPR
|
|
|
|
|
|| code1 == NON_LVALUE_EXPR;
|
|
|
|
|
code1 = TREE_CODE (t1))
|
|
|
|
|
t1 = TREE_OPERAND (t1, 0);
|
|
|
|
|
for (code2 = TREE_CODE (t2);
|
|
|
|
|
code2 == NOP_EXPR || code2 == CONVERT_EXPR
|
|
|
|
|
|| code1 == NON_LVALUE_EXPR;
|
|
|
|
|
code2 = TREE_CODE (t2))
|
|
|
|
|
t2 = TREE_OPERAND (t2, 0);
|
|
|
|
|
|
|
|
|
|
/* They might have become equal now. */
|
|
|
|
|
if (t1 == t2)
|
|
|
|
|
return true;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
if (code1 != code2)
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return false;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
switch (code1)
|
|
|
|
|
{
|
|
|
|
|
case INTEGER_CST:
|
|
|
|
|
return TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2)
|
|
|
|
|
&& TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2);
|
|
|
|
|
|
|
|
|
|
case REAL_CST:
|
|
|
|
|
return REAL_VALUES_EQUAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2));
|
|
|
|
|
|
|
|
|
|
case STRING_CST:
|
|
|
|
|
return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
&& !memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
|
2004-07-28 03:11:36 +00:00
|
|
|
|
TREE_STRING_LENGTH (t1));
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
case COMPLEX_CST:
|
|
|
|
|
return cp_tree_equal (TREE_REALPART (t1), TREE_REALPART (t2))
|
|
|
|
|
&& cp_tree_equal (TREE_IMAGPART (t1), TREE_IMAGPART (t2));
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
case CONSTRUCTOR:
|
|
|
|
|
/* We need to do this when determining whether or not two
|
|
|
|
|
non-type pointer to member function template arguments
|
|
|
|
|
are the same. */
|
1999-10-16 06:09:09 +00:00
|
|
|
|
if (!(same_type_p (TREE_TYPE (t1), TREE_TYPE (t2))
|
1999-08-26 09:30:50 +00:00
|
|
|
|
/* The first operand is RTL. */
|
|
|
|
|
&& TREE_OPERAND (t1, 0) == TREE_OPERAND (t2, 0)))
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return false;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
|
|
|
|
|
|
|
|
|
|
case TREE_LIST:
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (!cp_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)))
|
|
|
|
|
return false;
|
|
|
|
|
if (!cp_tree_equal (TREE_VALUE (t1), TREE_VALUE (t2)))
|
|
|
|
|
return false;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
return cp_tree_equal (TREE_CHAIN (t1), TREE_CHAIN (t2));
|
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
case SAVE_EXPR:
|
1999-08-26 09:30:50 +00:00
|
|
|
|
return cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
|
|
|
|
|
|
|
|
|
|
case CALL_EXPR:
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (!cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)))
|
|
|
|
|
return false;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
case TARGET_EXPR:
|
|
|
|
|
{
|
|
|
|
|
tree o1 = TREE_OPERAND (t1, 0);
|
|
|
|
|
tree o2 = TREE_OPERAND (t2, 0);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
/* Special case: if either target is an unallocated VAR_DECL,
|
|
|
|
|
it means that it's going to be unified with whatever the
|
|
|
|
|
TARGET_EXPR is really supposed to initialize, so treat it
|
|
|
|
|
as being equivalent to anything. */
|
|
|
|
|
if (TREE_CODE (o1) == VAR_DECL && DECL_NAME (o1) == NULL_TREE
|
|
|
|
|
&& !DECL_RTL_SET_P (o1))
|
|
|
|
|
/*Nop*/;
|
|
|
|
|
else if (TREE_CODE (o2) == VAR_DECL && DECL_NAME (o2) == NULL_TREE
|
|
|
|
|
&& !DECL_RTL_SET_P (o2))
|
|
|
|
|
/*Nop*/;
|
|
|
|
|
else if (!cp_tree_equal (o1, o2))
|
|
|
|
|
return false;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
|
|
|
|
|
}
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
case WITH_CLEANUP_EXPR:
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (!cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)))
|
|
|
|
|
return false;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t1, 1));
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
case COMPONENT_REF:
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (TREE_OPERAND (t1, 1) != TREE_OPERAND (t2, 1))
|
|
|
|
|
return false;
|
|
|
|
|
return cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
|
|
|
|
case VAR_DECL:
|
|
|
|
|
case PARM_DECL:
|
|
|
|
|
case CONST_DECL:
|
|
|
|
|
case FUNCTION_DECL:
|
2004-07-28 03:11:36 +00:00
|
|
|
|
case TEMPLATE_DECL:
|
|
|
|
|
case IDENTIFIER_NODE:
|
2007-05-19 01:19:51 +00:00
|
|
|
|
case SSA_NAME:
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return false;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
2005-06-03 03:28:44 +00:00
|
|
|
|
case BASELINK:
|
|
|
|
|
return (BASELINK_BINFO (t1) == BASELINK_BINFO (t2)
|
|
|
|
|
&& BASELINK_ACCESS_BINFO (t1) == BASELINK_ACCESS_BINFO (t2)
|
|
|
|
|
&& cp_tree_equal (BASELINK_FUNCTIONS (t1),
|
|
|
|
|
BASELINK_FUNCTIONS (t2)));
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
case TEMPLATE_PARM_INDEX:
|
2003-07-11 03:40:53 +00:00
|
|
|
|
return (TEMPLATE_PARM_IDX (t1) == TEMPLATE_PARM_IDX (t2)
|
|
|
|
|
&& TEMPLATE_PARM_LEVEL (t1) == TEMPLATE_PARM_LEVEL (t2)
|
|
|
|
|
&& same_type_p (TREE_TYPE (TEMPLATE_PARM_DECL (t1)),
|
|
|
|
|
TREE_TYPE (TEMPLATE_PARM_DECL (t2))));
|
1999-08-26 09:30:50 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
case TEMPLATE_ID_EXPR:
|
|
|
|
|
{
|
|
|
|
|
unsigned ix;
|
|
|
|
|
tree vec1, vec2;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (!cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)))
|
|
|
|
|
return false;
|
|
|
|
|
vec1 = TREE_OPERAND (t1, 1);
|
|
|
|
|
vec2 = TREE_OPERAND (t2, 1);
|
|
|
|
|
|
|
|
|
|
if (!vec1 || !vec2)
|
|
|
|
|
return !vec1 && !vec2;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (TREE_VEC_LENGTH (vec1) != TREE_VEC_LENGTH (vec2))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
for (ix = TREE_VEC_LENGTH (vec1); ix--;)
|
|
|
|
|
if (!cp_tree_equal (TREE_VEC_ELT (vec1, ix),
|
|
|
|
|
TREE_VEC_ELT (vec2, ix)))
|
|
|
|
|
return false;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
case SIZEOF_EXPR:
|
|
|
|
|
case ALIGNOF_EXPR:
|
2004-07-28 03:11:36 +00:00
|
|
|
|
{
|
|
|
|
|
tree o1 = TREE_OPERAND (t1, 0);
|
|
|
|
|
tree o2 = TREE_OPERAND (t2, 0);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (TREE_CODE (o1) != TREE_CODE (o2))
|
|
|
|
|
return false;
|
|
|
|
|
if (TYPE_P (o1))
|
|
|
|
|
return same_type_p (o1, o2);
|
|
|
|
|
else
|
|
|
|
|
return cp_tree_equal (o1, o2);
|
|
|
|
|
}
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
1999-10-16 06:09:09 +00:00
|
|
|
|
case PTRMEM_CST:
|
|
|
|
|
/* Two pointer-to-members are the same if they point to the same
|
|
|
|
|
field or function in the same class. */
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (PTRMEM_CST_MEMBER (t1) != PTRMEM_CST_MEMBER (t2))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return same_type_p (PTRMEM_CST_CLASS (t1), PTRMEM_CST_CLASS (t2));
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2005-06-03 03:28:44 +00:00
|
|
|
|
case OVERLOAD:
|
|
|
|
|
if (OVL_FUNCTION (t1) != OVL_FUNCTION (t2))
|
|
|
|
|
return false;
|
|
|
|
|
return cp_tree_equal (OVL_CHAIN (t1), OVL_CHAIN (t2));
|
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
default:
|
1996-09-18 05:35:50 +00:00
|
|
|
|
break;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
}
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
switch (TREE_CODE_CLASS (code1))
|
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
case tcc_unary:
|
|
|
|
|
case tcc_binary:
|
|
|
|
|
case tcc_comparison:
|
|
|
|
|
case tcc_expression:
|
|
|
|
|
case tcc_reference:
|
|
|
|
|
case tcc_statement:
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
for (i = 0; i < TREE_CODE_LENGTH (code1); ++i)
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (!cp_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i)))
|
|
|
|
|
return false;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return true;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
}
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
|
|
|
|
case tcc_type:
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return same_type_p (t1, t2);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
default:
|
|
|
|
|
gcc_unreachable ();
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* We can get here with --disable-checking. */
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return false;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
}
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
/* The type of ARG when used as an lvalue. */
|
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
lvalue_type (tree arg)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
|
|
|
|
tree type = TREE_TYPE (arg);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
return type;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The type of ARG for printing error messages; denote lvalues with
|
|
|
|
|
reference types. */
|
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
error_type (tree arg)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
|
|
|
|
tree type = TREE_TYPE (arg);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
1999-08-26 09:30:50 +00:00
|
|
|
|
if (TREE_CODE (type) == ARRAY_TYPE)
|
|
|
|
|
;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
else if (TREE_CODE (type) == ERROR_MARK)
|
|
|
|
|
;
|
1999-08-26 09:30:50 +00:00
|
|
|
|
else if (real_lvalue_p (arg))
|
|
|
|
|
type = build_reference_type (lvalue_type (arg));
|
|
|
|
|
else if (IS_AGGR_TYPE (type))
|
|
|
|
|
type = lvalue_type (arg);
|
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Does FUNCTION use a variable-length argument list? */
|
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
|
int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
varargs_function_p (tree function)
|
1999-08-26 09:30:50 +00:00
|
|
|
|
{
|
|
|
|
|
tree parm = TYPE_ARG_TYPES (TREE_TYPE (function));
|
|
|
|
|
for (; parm; parm = TREE_CHAIN (parm))
|
|
|
|
|
if (TREE_VALUE (parm) == void_type_node)
|
|
|
|
|
return 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns 1 if decl is a member of a class. */
|
|
|
|
|
|
|
|
|
|
int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
member_p (tree decl)
|
1996-09-18 05:35:50 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
const tree ctx = DECL_CONTEXT (decl);
|
|
|
|
|
return (ctx && TYPE_P (ctx));
|
1996-09-18 05:35:50 +00:00
|
|
|
|
}
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
/* Create a placeholder for member access where we don't actually have an
|
|
|
|
|
object that the access is against. */
|
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
build_dummy_object (tree type)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
tree decl = build1 (NOP_EXPR, build_pointer_type (type), void_zero_node);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return build_indirect_ref (decl, NULL);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We've gotten a reference to a member of TYPE. Return *this if appropriate,
|
|
|
|
|
or a dummy object otherwise. If BINFOP is non-0, it is filled with the
|
|
|
|
|
binfo path from current_class_type to TYPE, or 0. */
|
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
maybe_dummy_object (tree type, tree* binfop)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
tree decl, context;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
tree binfo;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
1999-10-16 06:09:09 +00:00
|
|
|
|
if (current_class_type
|
2002-02-01 18:16:02 +00:00
|
|
|
|
&& (binfo = lookup_base (current_class_type, type,
|
2007-05-19 01:19:51 +00:00
|
|
|
|
ba_unique | ba_quiet, NULL)))
|
1999-10-16 06:09:09 +00:00
|
|
|
|
context = current_class_type;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Reference from a nested class member function. */
|
|
|
|
|
context = type;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
binfo = TYPE_BINFO (type);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (binfop)
|
|
|
|
|
*binfop = binfo;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2003-07-11 03:40:53 +00:00
|
|
|
|
if (current_class_ref && context == current_class_type
|
|
|
|
|
/* Kludge: Make sure that current_class_type is actually
|
2007-05-19 01:19:51 +00:00
|
|
|
|
correct. It might not be if we're in the middle of
|
|
|
|
|
tsubst_default_argument. */
|
2003-07-11 03:40:53 +00:00
|
|
|
|
&& same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (current_class_ref)),
|
|
|
|
|
current_class_type))
|
1999-10-16 06:09:09 +00:00
|
|
|
|
decl = current_class_ref;
|
|
|
|
|
else
|
|
|
|
|
decl = build_dummy_object (context);
|
|
|
|
|
|
|
|
|
|
return decl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns 1 if OB is a placeholder object, or a pointer to one. */
|
|
|
|
|
|
|
|
|
|
int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
is_dummy_object (tree ob)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (ob) == INDIRECT_REF)
|
|
|
|
|
ob = TREE_OPERAND (ob, 0);
|
|
|
|
|
return (TREE_CODE (ob) == NOP_EXPR
|
|
|
|
|
&& TREE_OPERAND (ob, 0) == void_zero_node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns 1 iff type T is a POD type, as defined in [basic.types]. */
|
|
|
|
|
|
|
|
|
|
int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
pod_type_p (tree t)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
t = strip_array_types (t);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2003-07-11 03:40:53 +00:00
|
|
|
|
if (t == error_mark_node)
|
|
|
|
|
return 1;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (INTEGRAL_TYPE_P (t))
|
|
|
|
|
return 1; /* integral, character or enumeral type */
|
|
|
|
|
if (FLOAT_TYPE_P (t))
|
1999-10-16 06:09:09 +00:00
|
|
|
|
return 1;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (TYPE_PTR_P (t))
|
|
|
|
|
return 1; /* pointer to non-member */
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (TYPE_PTR_TO_MEMBER_P (t))
|
|
|
|
|
return 1; /* pointer to member */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2005-06-03 03:28:44 +00:00
|
|
|
|
if (TREE_CODE (t) == VECTOR_TYPE)
|
|
|
|
|
return 1; /* vectors are (small) arrays of scalars */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (! CLASS_TYPE_P (t))
|
|
|
|
|
return 0; /* other non-class type (reference or function) */
|
|
|
|
|
if (CLASSTYPE_NON_POD_P (t))
|
1999-10-16 06:09:09 +00:00
|
|
|
|
return 0;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2013-11-16 01:16:24 +00:00
|
|
|
|
/* Nonzero iff type T is a class template implicit specialization. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
class_tmpl_impl_spec_p (tree t)
|
|
|
|
|
{
|
|
|
|
|
return CLASS_TYPE_P (t) && CLASSTYPE_TEMPLATE_INSTANTIATION (t);
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-01 20:38:57 +00:00
|
|
|
|
/* Returns 1 iff zero initialization of type T means actually storing
|
|
|
|
|
zeros in it. */
|
|
|
|
|
|
|
|
|
|
int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
zero_init_p (tree t)
|
2002-09-01 20:38:57 +00:00
|
|
|
|
{
|
2003-07-11 03:40:53 +00:00
|
|
|
|
t = strip_array_types (t);
|
|
|
|
|
|
|
|
|
|
if (t == error_mark_node)
|
|
|
|
|
return 1;
|
2002-09-01 20:38:57 +00:00
|
|
|
|
|
2003-07-11 03:40:53 +00:00
|
|
|
|
/* NULL pointers to data members are initialized with -1. */
|
|
|
|
|
if (TYPE_PTRMEM_P (t))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* Classes that contain types that can't be zero-initialized, cannot
|
|
|
|
|
be zero-initialized themselves. */
|
|
|
|
|
if (CLASS_TYPE_P (t) && CLASSTYPE_NON_ZERO_INIT_P (t))
|
|
|
|
|
return 0;
|
2002-09-01 20:38:57 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Table of valid C++ attributes. */
|
2003-07-11 03:40:53 +00:00
|
|
|
|
const struct attribute_spec cxx_attribute_table[] =
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
/* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
|
|
|
|
|
{ "java_interface", 0, 0, false, false, false, handle_java_interface_attribute },
|
|
|
|
|
{ "com_interface", 0, 0, false, false, false, handle_com_interface_attribute },
|
|
|
|
|
{ "init_priority", 1, 1, true, false, false, handle_init_priority_attribute },
|
2007-05-19 01:19:51 +00:00
|
|
|
|
{ NULL, 0, 0, false, false, false, NULL }
|
2002-02-01 18:16:02 +00:00
|
|
|
|
};
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Handle a "java_interface" attribute; arguments as in
|
|
|
|
|
struct attribute_spec.handler. */
|
|
|
|
|
static tree
|
2007-05-19 01:19:51 +00:00
|
|
|
|
handle_java_interface_attribute (tree* node,
|
|
|
|
|
tree name,
|
|
|
|
|
tree args ATTRIBUTE_UNUSED ,
|
|
|
|
|
int flags,
|
|
|
|
|
bool* no_add_attrs)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
if (DECL_P (*node)
|
|
|
|
|
|| !CLASS_TYPE_P (*node)
|
|
|
|
|
|| !TYPE_FOR_JAVA (*node))
|
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
error ("%qE attribute can only be applied to Java class definitions",
|
|
|
|
|
name);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
*no_add_attrs = true;
|
|
|
|
|
return NULL_TREE;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
}
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
|
2007-05-19 01:19:51 +00:00
|
|
|
|
*node = build_variant_type_copy (*node);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
TYPE_JAVA_INTERFACE (*node) = 1;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return NULL_TREE;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Handle a "com_interface" attribute; arguments as in
|
|
|
|
|
struct attribute_spec.handler. */
|
|
|
|
|
static tree
|
2007-05-19 01:19:51 +00:00
|
|
|
|
handle_com_interface_attribute (tree* node,
|
|
|
|
|
tree name,
|
|
|
|
|
tree args ATTRIBUTE_UNUSED ,
|
|
|
|
|
int flags ATTRIBUTE_UNUSED ,
|
|
|
|
|
bool* no_add_attrs)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
static int warned;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
*no_add_attrs = true;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (DECL_P (*node)
|
|
|
|
|
|| !CLASS_TYPE_P (*node)
|
|
|
|
|
|| *node != TYPE_MAIN_VARIANT (*node))
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
warning (OPT_Wattributes, "%qE attribute can only be applied "
|
|
|
|
|
"to class definitions", name);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (!warned++)
|
2007-05-19 01:19:51 +00:00
|
|
|
|
warning (0, "%qE is obsolete; g++ vtables are now COM-compatible by default",
|
|
|
|
|
name);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handle an "init_priority" attribute; arguments as in
|
|
|
|
|
struct attribute_spec.handler. */
|
|
|
|
|
static tree
|
2007-05-19 01:19:51 +00:00
|
|
|
|
handle_init_priority_attribute (tree* node,
|
|
|
|
|
tree name,
|
|
|
|
|
tree args,
|
|
|
|
|
int flags ATTRIBUTE_UNUSED ,
|
|
|
|
|
bool* no_add_attrs)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
tree initp_expr = TREE_VALUE (args);
|
|
|
|
|
tree decl = *node;
|
|
|
|
|
tree type = TREE_TYPE (decl);
|
|
|
|
|
int pri;
|
|
|
|
|
|
|
|
|
|
STRIP_NOPS (initp_expr);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (!initp_expr || TREE_CODE (initp_expr) != INTEGER_CST)
|
|
|
|
|
{
|
|
|
|
|
error ("requested init_priority is not an integer constant");
|
|
|
|
|
*no_add_attrs = true;
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
pri = TREE_INT_CST_LOW (initp_expr);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
type = strip_array_types (type);
|
|
|
|
|
|
|
|
|
|
if (decl == NULL_TREE
|
|
|
|
|
|| TREE_CODE (decl) != VAR_DECL
|
|
|
|
|
|| !TREE_STATIC (decl)
|
|
|
|
|
|| DECL_EXTERNAL (decl)
|
|
|
|
|
|| (TREE_CODE (type) != RECORD_TYPE
|
|
|
|
|
&& TREE_CODE (type) != UNION_TYPE)
|
|
|
|
|
/* Static objects in functions are initialized the
|
|
|
|
|
first time control passes through that
|
|
|
|
|
function. This is not precise enough to pin down an
|
2003-07-11 03:40:53 +00:00
|
|
|
|
init_priority value, so don't allow it. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|| current_function_decl)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
error ("can only use %qE attribute on file-scope definitions "
|
|
|
|
|
"of objects of class type", name);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
*no_add_attrs = true;
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (pri > MAX_INIT_PRIORITY || pri <= 0)
|
|
|
|
|
{
|
|
|
|
|
error ("requested init_priority is out of range");
|
|
|
|
|
*no_add_attrs = true;
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Check for init_priorities that are reserved for
|
|
|
|
|
language and runtime support implementations.*/
|
|
|
|
|
if (pri <= MAX_RESERVED_INIT_PRIORITY)
|
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
warning
|
|
|
|
|
(0, "requested init_priority is reserved for internal use");
|
2002-02-01 18:16:02 +00:00
|
|
|
|
}
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (SUPPORTS_INIT_PRIORITY)
|
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
SET_DECL_INIT_PRIORITY (decl, pri);
|
|
|
|
|
DECL_HAS_INIT_PRIORITY_P (decl) = 1;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
error ("%qE attribute is not supported on this platform", name);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
*no_add_attrs = true;
|
|
|
|
|
return NULL_TREE;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return a new PTRMEM_CST of the indicated TYPE. The MEMBER is the
|
|
|
|
|
thing pointed to by the constant. */
|
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
make_ptrmem_cst (tree type, tree member)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
tree ptrmem_cst = make_node (PTRMEM_CST);
|
|
|
|
|
TREE_TYPE (ptrmem_cst) = type;
|
|
|
|
|
PTRMEM_CST_MEMBER (ptrmem_cst) = member;
|
|
|
|
|
return ptrmem_cst;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
/* Build a variant of TYPE that has the indicated ATTRIBUTES. May
|
|
|
|
|
return an existing type of an appropriate type already exists. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
cp_build_type_attribute_variant (tree type, tree attributes)
|
|
|
|
|
{
|
|
|
|
|
tree new_type;
|
|
|
|
|
|
|
|
|
|
new_type = build_type_attribute_variant (type, attributes);
|
|
|
|
|
if (TREE_CODE (new_type) == FUNCTION_TYPE
|
2007-05-19 01:19:51 +00:00
|
|
|
|
&& (TYPE_RAISES_EXCEPTIONS (new_type)
|
2004-07-28 03:11:36 +00:00
|
|
|
|
!= TYPE_RAISES_EXCEPTIONS (type)))
|
|
|
|
|
new_type = build_exception_variant (new_type,
|
|
|
|
|
TYPE_RAISES_EXCEPTIONS (type));
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
|
|
|
|
/* Making a new main variant of a class type is broken. */
|
|
|
|
|
gcc_assert (!CLASS_TYPE_P (type) || new_type == type);
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
return new_type;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Apply FUNC to all language-specific sub-trees of TP in a pre-order
|
2007-05-19 01:19:51 +00:00
|
|
|
|
traversal. Called from walk_tree. */
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
tree
|
|
|
|
|
cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func,
|
|
|
|
|
void *data, struct pointer_set_t *pset)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
enum tree_code code = TREE_CODE (*tp);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
location_t save_locus;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
tree result;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
#define WALK_SUBTREE(NODE) \
|
|
|
|
|
do \
|
|
|
|
|
{ \
|
2007-05-19 01:19:51 +00:00
|
|
|
|
result = walk_tree (&(NODE), func, data, pset); \
|
|
|
|
|
if (result) goto out; \
|
2002-02-01 18:16:02 +00:00
|
|
|
|
} \
|
|
|
|
|
while (0)
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Set input_location here so we get the right instantiation context
|
|
|
|
|
if we call instantiate_decl from inlinable_function_p. */
|
|
|
|
|
save_locus = input_location;
|
|
|
|
|
if (EXPR_HAS_LOCATION (*tp))
|
|
|
|
|
input_location = EXPR_LOCATION (*tp);
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Not one of the easy cases. We must explicitly go through the
|
|
|
|
|
children. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
result = NULL_TREE;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
switch (code)
|
|
|
|
|
{
|
|
|
|
|
case DEFAULT_ARG:
|
|
|
|
|
case TEMPLATE_TEMPLATE_PARM:
|
|
|
|
|
case BOUND_TEMPLATE_TEMPLATE_PARM:
|
|
|
|
|
case UNBOUND_CLASS_TEMPLATE:
|
|
|
|
|
case TEMPLATE_PARM_INDEX:
|
|
|
|
|
case TEMPLATE_TYPE_PARM:
|
|
|
|
|
case TYPENAME_TYPE:
|
|
|
|
|
case TYPEOF_TYPE:
|
2004-07-28 03:11:36 +00:00
|
|
|
|
case BASELINK:
|
|
|
|
|
/* None of these have subtrees other than those already walked
|
2007-05-19 01:19:51 +00:00
|
|
|
|
above. */
|
|
|
|
|
*walk_subtrees_p = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TINST_LEVEL:
|
|
|
|
|
WALK_SUBTREE (TINST_DECL (*tp));
|
2002-02-01 18:16:02 +00:00
|
|
|
|
*walk_subtrees_p = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PTRMEM_CST:
|
|
|
|
|
WALK_SUBTREE (TREE_TYPE (*tp));
|
|
|
|
|
*walk_subtrees_p = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TREE_LIST:
|
2004-07-28 03:11:36 +00:00
|
|
|
|
WALK_SUBTREE (TREE_PURPOSE (*tp));
|
2002-02-01 18:16:02 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OVERLOAD:
|
|
|
|
|
WALK_SUBTREE (OVL_FUNCTION (*tp));
|
|
|
|
|
WALK_SUBTREE (OVL_CHAIN (*tp));
|
|
|
|
|
*walk_subtrees_p = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case RECORD_TYPE:
|
|
|
|
|
if (TYPE_PTRMEMFUNC_P (*tp))
|
|
|
|
|
WALK_SUBTREE (TYPE_PTRMEMFUNC_FN_TYPE (*tp));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2007-05-19 01:19:51 +00:00
|
|
|
|
input_location = save_locus;
|
|
|
|
|
return NULL_TREE;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We didn't find what we were looking for. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
out:
|
|
|
|
|
input_location = save_locus;
|
|
|
|
|
return result;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
#undef WALK_SUBTREE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Decide whether there are language-specific reasons to not inline a
|
|
|
|
|
function as a tree. */
|
|
|
|
|
|
|
|
|
|
int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
cp_cannot_inline_tree_fn (tree* fnp)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
tree fn = *fnp;
|
|
|
|
|
|
|
|
|
|
/* We can inline a template instantiation only if it's fully
|
|
|
|
|
instantiated. */
|
|
|
|
|
if (DECL_TEMPLATE_INFO (fn)
|
|
|
|
|
&& TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn)))
|
|
|
|
|
{
|
2004-07-28 03:11:36 +00:00
|
|
|
|
/* Don't instantiate functions that are not going to be
|
|
|
|
|
inlined. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (!DECL_INLINE (DECL_TEMPLATE_RESULT
|
2004-07-28 03:11:36 +00:00
|
|
|
|
(template_for_substitution (fn))))
|
|
|
|
|
return 1;
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
fn = *fnp = instantiate_decl (fn, /*defer_ok=*/0, /*undefined_ok=*/0);
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
2002-09-01 20:38:57 +00:00
|
|
|
|
if (TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn)))
|
|
|
|
|
return 1;
|
2002-02-01 18:16:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (flag_really_no_inline
|
|
|
|
|
&& lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
|
|
|
|
|
return 1;
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Don't auto-inline functions that might be replaced at link-time
|
|
|
|
|
with an alternative definition. */
|
|
|
|
|
if (!DECL_DECLARED_INLINE_P (fn) && DECL_REPLACEABLE_P (fn))
|
2003-07-11 03:40:53 +00:00
|
|
|
|
{
|
|
|
|
|
DECL_UNINLINABLE (fn) = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
if (varargs_function_p (fn))
|
|
|
|
|
{
|
|
|
|
|
DECL_UNINLINABLE (fn) = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! function_attribute_inlinable_p (fn))
|
|
|
|
|
{
|
|
|
|
|
DECL_UNINLINABLE (fn) = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add any pending functions other than the current function (already
|
|
|
|
|
handled by the caller), that thus cannot be inlined, to FNS_P, then
|
|
|
|
|
return the latest function added to the array, PREV_FN. */
|
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
cp_add_pending_fn_decls (void* fns_p, tree prev_fn)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
varray_type *fnsp = (varray_type *)fns_p;
|
|
|
|
|
struct saved_scope *s;
|
|
|
|
|
|
|
|
|
|
for (s = scope_chain; s; s = s->prev)
|
|
|
|
|
if (s->function_decl && s->function_decl != prev_fn)
|
|
|
|
|
{
|
|
|
|
|
VARRAY_PUSH_TREE (*fnsp, s->function_decl);
|
|
|
|
|
prev_fn = s->function_decl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return prev_fn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Determine whether VAR is a declaration of an automatic variable in
|
|
|
|
|
function FN. */
|
|
|
|
|
|
|
|
|
|
int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
cp_auto_var_in_fn_p (tree var, tree fn)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
return (DECL_P (var) && DECL_CONTEXT (var) == fn
|
|
|
|
|
&& nonstatic_local_decl_p (var));
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Like save_expr, but for C++. */
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
tree
|
2007-05-19 01:19:51 +00:00
|
|
|
|
cp_save_expr (tree expr)
|
|
|
|
|
{
|
|
|
|
|
/* There is no reason to create a SAVE_EXPR within a template; if
|
|
|
|
|
needed, we can create the SAVE_EXPR when instantiating the
|
|
|
|
|
template. Furthermore, the middle-end cannot handle C++-specific
|
|
|
|
|
tree codes. */
|
|
|
|
|
if (processing_template_decl)
|
|
|
|
|
return expr;
|
|
|
|
|
return save_expr (expr);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Initialize tree.c. */
|
|
|
|
|
|
|
|
|
|
void
|
2004-07-28 03:11:36 +00:00
|
|
|
|
init_tree (void)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
2003-07-11 03:40:53 +00:00
|
|
|
|
list_hash_table = htab_create_ggc (31, list_hash, list_hash_eq, NULL);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns the kind of special function that DECL (a FUNCTION_DECL)
|
2003-07-11 03:40:53 +00:00
|
|
|
|
is. Note that sfk_none is zero, so this function can be used as a
|
|
|
|
|
predicate to test whether or not DECL is a special function. */
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
special_function_kind
|
2004-07-28 03:11:36 +00:00
|
|
|
|
special_function_p (tree decl)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
/* Rather than doing all this stuff with magic names, we should
|
|
|
|
|
probably have a field of type `special_function_kind' in
|
|
|
|
|
DECL_LANG_SPECIFIC. */
|
|
|
|
|
if (DECL_COPY_CONSTRUCTOR_P (decl))
|
|
|
|
|
return sfk_copy_constructor;
|
|
|
|
|
if (DECL_CONSTRUCTOR_P (decl))
|
|
|
|
|
return sfk_constructor;
|
|
|
|
|
if (DECL_OVERLOADED_OPERATOR_P (decl) == NOP_EXPR)
|
|
|
|
|
return sfk_assignment_operator;
|
|
|
|
|
if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl))
|
|
|
|
|
return sfk_destructor;
|
|
|
|
|
if (DECL_COMPLETE_DESTRUCTOR_P (decl))
|
|
|
|
|
return sfk_complete_destructor;
|
|
|
|
|
if (DECL_BASE_DESTRUCTOR_P (decl))
|
|
|
|
|
return sfk_base_destructor;
|
|
|
|
|
if (DECL_DELETING_DESTRUCTOR_P (decl))
|
|
|
|
|
return sfk_deleting_destructor;
|
|
|
|
|
if (DECL_CONV_FN_P (decl))
|
|
|
|
|
return sfk_conversion;
|
|
|
|
|
|
|
|
|
|
return sfk_none;
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 03:40:53 +00:00
|
|
|
|
/* Returns nonzero if TYPE is a character type, including wchar_t. */
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
int
|
2004-07-28 03:11:36 +00:00
|
|
|
|
char_type_p (tree type)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
return (same_type_p (type, char_type_node)
|
|
|
|
|
|| same_type_p (type, unsigned_char_type_node)
|
|
|
|
|
|| same_type_p (type, signed_char_type_node)
|
|
|
|
|
|| same_type_p (type, wchar_type_node));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns the kind of linkage associated with the indicated DECL. Th
|
|
|
|
|
value returned is as specified by the language standard; it is
|
|
|
|
|
independent of implementation details regarding template
|
|
|
|
|
instantiation, etc. For example, it is possible that a declaration
|
|
|
|
|
to which this function assigns external linkage would not show up
|
|
|
|
|
as a global symbol when you run `nm' on the resulting object file. */
|
|
|
|
|
|
|
|
|
|
linkage_kind
|
2004-07-28 03:11:36 +00:00
|
|
|
|
decl_linkage (tree decl)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
{
|
|
|
|
|
/* This function doesn't attempt to calculate the linkage from first
|
|
|
|
|
principles as given in [basic.link]. Instead, it makes use of
|
|
|
|
|
the fact that we have already set TREE_PUBLIC appropriately, and
|
|
|
|
|
then handles a few special cases. Ideally, we would calculate
|
|
|
|
|
linkage first, and then transform that into a concrete
|
|
|
|
|
implementation. */
|
|
|
|
|
|
|
|
|
|
/* Things that don't have names have no linkage. */
|
|
|
|
|
if (!DECL_NAME (decl))
|
|
|
|
|
return lk_none;
|
|
|
|
|
|
|
|
|
|
/* Things that are TREE_PUBLIC have external linkage. */
|
|
|
|
|
if (TREE_PUBLIC (decl))
|
|
|
|
|
return lk_external;
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (TREE_CODE (decl) == NAMESPACE_DECL)
|
|
|
|
|
return lk_external;
|
|
|
|
|
|
|
|
|
|
/* Linkage of a CONST_DECL depends on the linkage of the enumeration
|
|
|
|
|
type. */
|
|
|
|
|
if (TREE_CODE (decl) == CONST_DECL)
|
|
|
|
|
return decl_linkage (TYPE_NAME (TREE_TYPE (decl)));
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Some things that are not TREE_PUBLIC have external linkage, too.
|
|
|
|
|
For example, on targets that don't have weak symbols, we make all
|
|
|
|
|
template instantiations have internal linkage (in the object
|
|
|
|
|
file), but the symbols should still be treated as having external
|
|
|
|
|
linkage from the point of view of the language. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (TREE_CODE (decl) != TYPE_DECL && DECL_LANG_SPECIFIC (decl)
|
|
|
|
|
&& DECL_COMDAT (decl))
|
2002-02-01 18:16:02 +00:00
|
|
|
|
return lk_external;
|
|
|
|
|
|
|
|
|
|
/* Things in local scope do not have linkage, if they don't have
|
|
|
|
|
TREE_PUBLIC set. */
|
|
|
|
|
if (decl_function_context (decl))
|
|
|
|
|
return lk_none;
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Members of the anonymous namespace also have TREE_PUBLIC unset, but
|
|
|
|
|
are considered to have external linkage for language purposes. DECLs
|
|
|
|
|
really meant to have internal linkage have DECL_THIS_STATIC set. */
|
|
|
|
|
if (TREE_CODE (decl) == TYPE_DECL
|
|
|
|
|
|| ((TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
|
|
|
|
|
&& !DECL_THIS_STATIC (decl)))
|
|
|
|
|
return lk_external;
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* Everything else has internal linkage. */
|
|
|
|
|
return lk_internal;
|
|
|
|
|
}
|
2003-07-11 03:40:53 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* EXP is an expression that we want to pre-evaluate. Returns (in
|
|
|
|
|
*INITP) an expression that will perform the pre-evaluation. The
|
|
|
|
|
value returned by this function is a side-effect free expression
|
|
|
|
|
equivalent to the pre-evaluated expression. Callers must ensure
|
|
|
|
|
that *INITP is evaluated before EXP. */
|
2003-07-11 03:40:53 +00:00
|
|
|
|
|
|
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
|
stabilize_expr (tree exp, tree* initp)
|
2003-07-11 03:40:53 +00:00
|
|
|
|
{
|
|
|
|
|
tree init_expr;
|
|
|
|
|
|
|
|
|
|
if (!TREE_SIDE_EFFECTS (exp))
|
2007-05-19 01:19:51 +00:00
|
|
|
|
init_expr = NULL_TREE;
|
2003-07-11 03:40:53 +00:00
|
|
|
|
else if (!real_lvalue_p (exp)
|
|
|
|
|
|| !TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (exp)))
|
|
|
|
|
{
|
|
|
|
|
init_expr = get_target_expr (exp);
|
|
|
|
|
exp = TARGET_EXPR_SLOT (init_expr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
exp = build_unary_op (ADDR_EXPR, exp, 1);
|
|
|
|
|
init_expr = get_target_expr (exp);
|
|
|
|
|
exp = TARGET_EXPR_SLOT (init_expr);
|
|
|
|
|
exp = build_indirect_ref (exp, 0);
|
|
|
|
|
}
|
|
|
|
|
*initp = init_expr;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|
|
|
|
|
gcc_assert (!TREE_SIDE_EFFECTS (exp));
|
2003-07-11 03:40:53 +00:00
|
|
|
|
return exp;
|
|
|
|
|
}
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Add NEW, an expression whose value we don't care about, after the
|
|
|
|
|
similar expression ORIG. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
add_stmt_to_compound (tree orig, tree new)
|
|
|
|
|
{
|
|
|
|
|
if (!new || !TREE_SIDE_EFFECTS (new))
|
|
|
|
|
return orig;
|
|
|
|
|
if (!orig || !TREE_SIDE_EFFECTS (orig))
|
|
|
|
|
return new;
|
|
|
|
|
return build2 (COMPOUND_EXPR, void_type_node, orig, new);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Like stabilize_expr, but for a call whose arguments we want to
|
|
|
|
|
pre-evaluate. CALL is modified in place to use the pre-evaluated
|
|
|
|
|
arguments, while, upon return, *INITP contains an expression to
|
|
|
|
|
compute the arguments. */
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
stabilize_call (tree call, tree *initp)
|
|
|
|
|
{
|
|
|
|
|
tree inits = NULL_TREE;
|
|
|
|
|
tree t;
|
|
|
|
|
|
|
|
|
|
if (call == error_mark_node)
|
|
|
|
|
return;
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
gcc_assert (TREE_CODE (call) == CALL_EXPR
|
|
|
|
|
|| TREE_CODE (call) == AGGR_INIT_EXPR);
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
|
|
|
|
for (t = TREE_OPERAND (call, 1); t; t = TREE_CHAIN (t))
|
|
|
|
|
if (TREE_SIDE_EFFECTS (TREE_VALUE (t)))
|
|
|
|
|
{
|
|
|
|
|
tree init;
|
|
|
|
|
TREE_VALUE (t) = stabilize_expr (TREE_VALUE (t), &init);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
inits = add_stmt_to_compound (inits, init);
|
2004-07-28 03:11:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*initp = inits;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* Like stabilize_expr, but for an initialization.
|
|
|
|
|
|
|
|
|
|
If the initialization is for an object of class type, this function
|
|
|
|
|
takes care not to introduce additional temporaries.
|
|
|
|
|
|
|
|
|
|
Returns TRUE iff the expression was successfully pre-evaluated,
|
|
|
|
|
i.e., if INIT is now side-effect free, except for, possible, a
|
|
|
|
|
single call to a constructor. */
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
stabilize_init (tree init, tree *initp)
|
|
|
|
|
{
|
|
|
|
|
tree t = init;
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
*initp = NULL_TREE;
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (t == error_mark_node)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (t) == INIT_EXPR
|
|
|
|
|
&& TREE_CODE (TREE_OPERAND (t, 1)) != TARGET_EXPR)
|
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
TREE_OPERAND (t, 1) = stabilize_expr (TREE_OPERAND (t, 1), initp);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (TREE_CODE (t) == INIT_EXPR)
|
|
|
|
|
t = TREE_OPERAND (t, 1);
|
|
|
|
|
if (TREE_CODE (t) == TARGET_EXPR)
|
|
|
|
|
t = TARGET_EXPR_INITIAL (t);
|
|
|
|
|
if (TREE_CODE (t) == COMPOUND_EXPR)
|
|
|
|
|
t = expr_last (t);
|
|
|
|
|
if (TREE_CODE (t) == CONSTRUCTOR
|
|
|
|
|
&& EMPTY_CONSTRUCTOR_P (t))
|
|
|
|
|
/* Default-initialization. */
|
|
|
|
|
return true;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* If the initializer is a COND_EXPR, we can't preevaluate
|
|
|
|
|
anything. */
|
|
|
|
|
if (TREE_CODE (t) == COND_EXPR)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (t) == CALL_EXPR
|
|
|
|
|
|| TREE_CODE (t) == AGGR_INIT_EXPR)
|
|
|
|
|
{
|
|
|
|
|
stabilize_call (t, initp);
|
|
|
|
|
return true;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
/* The initialization is being performed via a bitwise copy -- and
|
|
|
|
|
the item copied may have side effects. */
|
|
|
|
|
return TREE_SIDE_EFFECTS (init);
|
2004-07-28 03:11:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-06-03 03:28:44 +00:00
|
|
|
|
/* Like "fold", but should be used whenever we might be processing the
|
|
|
|
|
body of a template. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
fold_if_not_in_template (tree expr)
|
|
|
|
|
{
|
|
|
|
|
/* In the body of a template, there is never any need to call
|
|
|
|
|
"fold". We will call fold later when actually instantiating the
|
|
|
|
|
template. Integral constant expressions in templates will be
|
|
|
|
|
evaluated via fold_non_dependent_expr, as necessary. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (processing_template_decl)
|
|
|
|
|
return expr;
|
|
|
|
|
|
|
|
|
|
/* Fold C++ front-end specific tree codes. */
|
|
|
|
|
if (TREE_CODE (expr) == UNARY_PLUS_EXPR)
|
|
|
|
|
return fold_convert (TREE_TYPE (expr), TREE_OPERAND (expr, 0));
|
|
|
|
|
|
|
|
|
|
return fold (expr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns true if a cast to TYPE may appear in an integral constant
|
|
|
|
|
expression. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
cast_valid_in_integral_constant_expression_p (tree type)
|
|
|
|
|
{
|
|
|
|
|
return (INTEGRAL_OR_ENUMERATION_TYPE_P (type)
|
|
|
|
|
|| dependent_type_p (type)
|
|
|
|
|
|| type == error_mark_node);
|
2005-06-03 03:28:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 03:40:53 +00:00
|
|
|
|
|
|
|
|
|
#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
|
|
|
|
|
/* Complain that some language-specific thing hanging off a tree
|
|
|
|
|
node has been accessed improperly. */
|
|
|
|
|
|
|
|
|
|
void
|
2004-07-28 03:11:36 +00:00
|
|
|
|
lang_check_failed (const char* file, int line, const char* function)
|
2003-07-11 03:40:53 +00:00
|
|
|
|
{
|
|
|
|
|
internal_error ("lang_* check: failed in %s, at %s:%d",
|
|
|
|
|
function, trim_filename (file), line);
|
|
|
|
|
}
|
|
|
|
|
#endif /* ENABLE_TREE_CHECKING */
|
|
|
|
|
|
|
|
|
|
#include "gt-cp-tree.h"
|