This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: Fix bug 1588
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH]: Fix bug 1588
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Fri, 12 Jan 2001 09:50:42 +0000
- Organization: Codesourcery LLC
Hi,
I've installed this patch for bug 1588 where we ICE'd due to not
doing template processing early enough. I also took the opportunity
of unconditionally pedwarning about a Cfront extension.
built & tested on i686-pc-linux-gnu, approved by Mark.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-01-11 Nathan Sidwell <nathan@codesourcery.com>
* typeck.c (build_c_cast): Do template processing earlier.
Always pedwarn on array casts.
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/typeck.c,v
retrieving revision 1.332
diff -c -3 -p -r1.332 typeck.c
*** typeck.c 2001/01/03 03:28:50 1.332
--- typeck.c 2001/01/11 09:10:31
*************** build_c_cast (type, expr)
*** 5349,5354 ****
--- 5349,5361 ----
if (type == error_mark_node || expr == error_mark_node)
return error_mark_node;
+ if (processing_template_decl)
+ {
+ tree t = build_min (CAST_EXPR, type,
+ tree_cons (NULL_TREE, value, NULL_TREE));
+ return t;
+ }
+
/* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */
if (TREE_CODE (type) != REFERENCE_TYPE
*************** build_c_cast (type, expr)
*** 5365,5377 ****
NIHCL uses it. It is not valid ISO C++ however. */
if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)
{
! if (pedantic)
! pedwarn ("ISO C++ forbids casting to an array type");
type = build_pointer_type (TREE_TYPE (type));
}
else
{
! error ("ISO C++ forbids casting to an array type");
return error_mark_node;
}
}
--- 5372,5383 ----
NIHCL uses it. It is not valid ISO C++ however. */
if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)
{
! cp_pedwarn ("ISO C++ forbids casting to an array type `%T'", type);
type = build_pointer_type (TREE_TYPE (type));
}
else
{
! cp_error ("ISO C++ forbids casting to an array type `%T'", type);
return error_mark_node;
}
}
*************** build_c_cast (type, expr)
*** 5381,5393 ****
{
cp_error ("invalid cast to function type `%T'", type);
return error_mark_node;
- }
-
- if (processing_template_decl)
- {
- tree t = build_min (CAST_EXPR, type,
- tree_cons (NULL_TREE, value, NULL_TREE));
- return t;
}
if (TREE_CODE (type) == VOID_TYPE)
--- 5387,5392 ----
// Build don't link:
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 10 Jan 2001 <nathan@codesourcery.com>
// Bug 1588. We ICE'd on reparsing an absdcl as a cast inside a template
// function.
class A {
public:
template <class T> void f(void *CLUTp);
};
template <class T> void A::f(void *CLUTp)
{
void *CLUT;
CLUT = (unsigned char [3][256])CLUTp; // ERROR - cast to array
return;
}
int main()
{
A myobj;
unsigned char t[3][256];
myobj.f<unsigned char>(t);
return 0;
}