mirror of
https://gcc.gnu.org/git/gcc.git
synced 2025-01-10 13:03:40 +08:00
re PR c++/56438 (ICE in value_dependent_expression_p, at cp/pt.c:19551)
PR c++/56438 * semantics.c (potential_constant_expression_1): In C++98, a cast to non-integral type can't be a constant expression. From-SVN: r196274
This commit is contained in:
parent
d2b512dc5d
commit
70e9ab23f4
@ -1,3 +1,9 @@
|
|||||||
|
2013-02-25 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/56438
|
||||||
|
* semantics.c (potential_constant_expression_1): In C++98, a cast
|
||||||
|
to non-integral type can't be a constant expression.
|
||||||
|
|
||||||
2013-02-24 Jakub Jelinek <jakub@redhat.com>
|
2013-02-24 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR c++/56403
|
PR c++/56403
|
||||||
|
@ -8607,6 +8607,18 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
|
|||||||
case STATIC_CAST_EXPR:
|
case STATIC_CAST_EXPR:
|
||||||
case REINTERPRET_CAST_EXPR:
|
case REINTERPRET_CAST_EXPR:
|
||||||
case IMPLICIT_CONV_EXPR:
|
case IMPLICIT_CONV_EXPR:
|
||||||
|
if (cxx_dialect < cxx0x
|
||||||
|
&& !dependent_type_p (TREE_TYPE (t))
|
||||||
|
&& !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (t)))
|
||||||
|
/* In C++98, a conversion to non-integral type can't be part of a
|
||||||
|
constant expression. */
|
||||||
|
{
|
||||||
|
if (flags & tf_error)
|
||||||
|
error ("cast to non-integral type %qT in a constant expression",
|
||||||
|
TREE_TYPE (t));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return (potential_constant_expression_1
|
return (potential_constant_expression_1
|
||||||
(TREE_OPERAND (t, 0),
|
(TREE_OPERAND (t, 0),
|
||||||
TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE, flags));
|
TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE, flags));
|
||||||
|
22
gcc/testsuite/g++.dg/template/cast3.C
Normal file
22
gcc/testsuite/g++.dg/template/cast3.C
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// PR c++/56438
|
||||||
|
|
||||||
|
struct A { };
|
||||||
|
A& operator<<(A&, const char*);
|
||||||
|
|
||||||
|
struct B {
|
||||||
|
int size();
|
||||||
|
};
|
||||||
|
|
||||||
|
struct C { };
|
||||||
|
|
||||||
|
template <class S, class T>
|
||||||
|
S bar(const S& s, const T& t) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class S, class T>
|
||||||
|
void foo() {
|
||||||
|
A a;
|
||||||
|
B b;
|
||||||
|
a << bar(b.size(), C()); // { dg-error "no match" }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user