typeck.c (build_const_cast): Tweak last change to handle templates correctly.
* typeck.c (build_const_cast): Tweak last change to handle templates correctly. From-SVN: r26712
This commit is contained in:
parent
b694131f21
commit
3fd91cbd4f
@ -1,5 +1,8 @@
|
|||||||
1999-04-30 Mark Mitchell <mark@codesourcery.com>
|
1999-04-30 Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
|
* typeck.c (build_const_cast): Tweak last change to handle
|
||||||
|
templates correctly.
|
||||||
|
|
||||||
* typeck.c (build_const_cast): Disallow use of const_cast to
|
* typeck.c (build_const_cast): Disallow use of const_cast to
|
||||||
anything but a pointer or reference type.
|
anything but a pointer or reference type.
|
||||||
|
|
||||||
|
@ -5633,14 +5633,6 @@ build_const_cast (type, expr)
|
|||||||
if (type == error_mark_node || expr == error_mark_node)
|
if (type == error_mark_node || expr == error_mark_node)
|
||||||
return error_mark_node;
|
return error_mark_node;
|
||||||
|
|
||||||
if (!POINTER_TYPE_P (type) && !TYPE_PTRMEMFUNC_P (type))
|
|
||||||
{
|
|
||||||
cp_error ("`%T' is not a pointer, reference, or pointer-to-member type",
|
|
||||||
type);
|
|
||||||
cp_error ("as required by const_cast");
|
|
||||||
return error_mark_node;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TREE_CODE (expr) == OFFSET_REF)
|
if (TREE_CODE (expr) == OFFSET_REF)
|
||||||
expr = resolve_offset_ref (expr);
|
expr = resolve_offset_ref (expr);
|
||||||
|
|
||||||
@ -5651,6 +5643,14 @@ build_const_cast (type, expr)
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!POINTER_TYPE_P (type) && !TYPE_PTRMEMFUNC_P (type))
|
||||||
|
{
|
||||||
|
cp_error ("`%T' is not a pointer, reference, or pointer-to-member type",
|
||||||
|
type);
|
||||||
|
cp_error ("as required by const_cast");
|
||||||
|
return error_mark_node;
|
||||||
|
}
|
||||||
|
|
||||||
if (TREE_CODE (type) != REFERENCE_TYPE)
|
if (TREE_CODE (type) != REFERENCE_TYPE)
|
||||||
{
|
{
|
||||||
expr = decay_conversion (expr);
|
expr = decay_conversion (expr);
|
||||||
|
7
gcc/testsuite/g++.old-deja/g++.pt/cast1.C
Normal file
7
gcc/testsuite/g++.old-deja/g++.pt/cast1.C
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Build don't link:
|
||||||
|
// Origin: Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void f (T t) {
|
||||||
|
const_cast<T>(t);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user