This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: functional cast
- To: egcs-patches at egcs dot cygnus dot com
- Subject: C++ PATCH: functional cast
- From: Nathan Sidwell <nathan at acm dot org>
- Date: Fri, 17 Sep 1999 09:50:49 +0100
- Reply-To: nathan at compsci dot bristol dot ac dot uk
Hi,
attached is a patch to parse.y dealing with the `const (3)' extension to
functional style cast. We accept that under the implicit int rule, but
currently do not issue a diagnostic. This patch uses groktypename so it
goes through the correct logic. Also we accept `const (3,4)' even though
there is no two operand int constructor. We take that as a comma
expression, but again do not issue a diagnostic. The patch uses
build_functional_cast, to make the logic consistent with other function
style casts. There's no need to look for error_mark_node here, as
build_functional_cast does that anyway -- why optimize for failure :-)
Ok?
NB. The comma expression extension in `int (x,y)' is undocumented -- can
we remove it?
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
I have seen the death of PhotoShop -- it is called GIMP
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk
1999-09-17 Nathan Sidwell <nathan@acm.org>
* parse.y (primary): Use build_functional_cast for CV_QUALIFIER.
Index: cp/parse.y
===================================================================
RCS file: /cvs/egcs/egcs/gcc/cp/parse.y,v
retrieving revision 1.145
diff -c -3 -p -r1.145 parse.y
*** parse.y 1999/09/10 01:09:05 1.145
--- parse.y 1999/09/17 08:20:04
*************** primary:
*** 1477,1491 ****
`const (3)' is equivalent to `const int (3)'. */
tree type;
! if ($3 == error_mark_node)
! {
! $$ = error_mark_node;
! break;
! }
!
! type = cp_build_qualified_type (integer_type_node,
! cp_type_qual_from_rid ($1));
! $$ = build_c_cast (type, build_compound_expr ($3));
}
| functional_cast
| DYNAMIC_CAST '<' type_id '>' '(' expr ')'
--- 1477,1485 ----
`const (3)' is equivalent to `const int (3)'. */
tree type;
! type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
! type = groktypename (build_decl_list (type, NULL_TREE));
! $$ = build_functional_cast (type, $3);
}
| functional_cast
| DYNAMIC_CAST '<' type_id '>' '(' expr ')'