summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2001-01-12 09:47:23 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2001-01-12 09:47:23 +0000
commit1c7b00756ef3b0e7ec1056f8ac508911bf78e0fb (patch)
tree56369d2fb59c7704a269bb4e343988f82dce1b9f /gcc/cp
parent80de50c470384031c4f9a9678eb2caa2934a8267 (diff)
downloadgcc-1c7b00756ef3b0e7ec1056f8ac508911bf78e0fb.tar.gz
cp:
* typeck.c (build_c_cast): Do template processing earlier. Always pedwarn on array casts. testsuite: * g++.old-deja/g++.pt/cast2.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38941 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck.c19
2 files changed, 14 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1297b2f5107..fd6caefbe81 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2001-01-12 Nathan Sidwell <nathan@codesourcery.com>
+ * typeck.c (build_c_cast): Do template processing earlier.
+ Always pedwarn on array casts.
+
+2001-01-12 Nathan Sidwell <nathan@codesourcery.com>
+
* friend.c (make_friend_class): Make sure a templated class is
actually a template.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index a10f1d4cafa..6a05ef9dd65 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5349,6 +5349,13 @@ build_c_cast (type, expr)
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
@@ -5365,13 +5372,12 @@ build_c_cast (type, expr)
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");
+ cp_pedwarn ("ISO C++ forbids casting to an array type `%T'", type);
type = build_pointer_type (TREE_TYPE (type));
}
else
{
- error ("ISO C++ forbids casting to an array type");
+ cp_error ("ISO C++ forbids casting to an array type `%T'", type);
return error_mark_node;
}
}
@@ -5383,13 +5389,6 @@ build_c_cast (type, expr)
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)
{
/* Conversion to void does not cause any of the normal function to