OSDN Git Service

* error.c: Fix comment formatting.
[pf3gnuchains/gcc-fork.git] / gcc / cp / expr.c
1 /* Convert language-specific tree expression to rtl instructions,
2    for GNU compiler.
3    Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4    2000, 2001 Free Software Foundation, Inc.
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23
24 #include "config.h"
25 #include "system.h"
26 #include "rtl.h"
27 #include "tree.h"
28 #include "flags.h"
29 #include "expr.h"
30 #include "cp-tree.h"
31 #include "toplev.h"
32 #include "except.h"
33 #include "tm_p.h"
34
35 /* Hook used by output_constant to expand language-specific
36    constants.  */
37
38 tree
39 cplus_expand_constant (cst)
40      tree cst;
41 {
42   switch (TREE_CODE (cst))
43     {
44     case PTRMEM_CST:
45       {
46         tree type = TREE_TYPE (cst);
47         tree member;
48       
49         /* Find the member.  */
50         member = PTRMEM_CST_MEMBER (cst);
51
52         if (TREE_CODE (member) == FIELD_DECL) 
53           {
54             /* Find the offset for the field.  */
55             tree offset = byte_position (member);
56             cst = fold (build1 (NOP_EXPR, type, offset));
57           }
58         else
59           {
60             tree delta;
61             tree pfn;
62
63             expand_ptrmemfunc_cst (cst, &delta, &pfn);
64             cst = build_ptrmemfunc1 (type, delta, pfn);
65           }
66       }
67       break;
68
69     default:
70       /* There's nothing to do.  */
71       break;
72     }
73
74   return cst;
75 }
76
77 /* Hook used by expand_expr to expand language-specific tree codes.  */
78
79 rtx
80 cxx_expand_expr (exp, target, tmode, modifier)
81      tree exp;
82      rtx target;
83      enum machine_mode tmode;
84      int modifier;  /* Actually an enum expand_modifier.  */
85 {
86   tree type = TREE_TYPE (exp);
87   register enum machine_mode mode = TYPE_MODE (type);
88   register enum tree_code code = TREE_CODE (exp);
89   rtx ret;
90
91   /* No sense saving up arithmetic to be done
92      if it's all in the wrong mode to form part of an address.
93      And force_operand won't know whether to sign-extend or zero-extend.  */
94
95   if (mode != Pmode && modifier == EXPAND_SUM)
96     modifier = EXPAND_NORMAL;
97
98   switch (code)
99     {
100     case PTRMEM_CST:
101       return expand_expr (cplus_expand_constant (exp),
102                           target, tmode, modifier);
103
104     case OFFSET_REF:
105       /* Offset refs should not make it through to here.  */
106       abort ();
107       return const0_rtx;
108       
109     case THROW_EXPR:
110       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
111       return NULL;
112
113     case MUST_NOT_THROW_EXPR:
114       expand_eh_region_start ();
115       ret = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
116       expand_eh_region_end_must_not_throw (build_call (terminate_node, 0));
117       return ret;
118
119     case EMPTY_CLASS_EXPR:
120       /* We don't need to generate any code for an empty class.  */
121       return const0_rtx;
122
123     default:
124       return c_expand_expr (exp, target, tmode, modifier);
125     }
126   abort ();
127   /* NOTREACHED */
128   return NULL;
129 }
130
131 int
132 extract_init (decl, init)
133      tree decl ATTRIBUTE_UNUSED, init ATTRIBUTE_UNUSED;
134 {
135   return 0;
136 }
137