From: Marc Glisse Date: Mon, 6 Aug 2012 09:49:39 +0000 (+0200) Subject: re PR c++/54165 (Cast to "void" should not implicitly call conversion functions) X-Git-Tag: releases/gcc-4.8.0~4099 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ca73dc295e4b1d891511cc2ce842c50d397e8cbe;p=thirdparty%2Fgcc.git re PR c++/54165 (Cast to "void" should not implicitly call conversion functions) /cp 2012-08-06 Marc Glisse Paolo Carlini PR c++/54165 * typeck.c (build_static_cast_1): Move the conversion to void case before the perform_direct_initialization_if_possible call. /testsuite 2012-08-06 Marc Glisse Paolo Carlini PR c++/54165 * g++.dg/conversion/void2.C: New. Co-Authored-By: Paolo Carlini From-SVN: r190175 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f57769dc2faa..86c9097f67fe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2012-08-06 Marc Glisse + Paolo Carlini + + PR c++/54165 + * typeck.c (build_static_cast_1): Move the conversion to void case + before the perform_direct_initialization_if_possible call. + 2012-08-03 Marc Glisse * pt.c (tsubst_copy_and_build): Handle VECTOR_TYPE like scalars. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d7a719fcf44b..25f37e896fa2 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6051,6 +6051,12 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, intype = TREE_TYPE (expr); } + /* [expr.static.cast] + + Any expression can be explicitly converted to type cv void. */ + if (TREE_CODE (type) == VOID_TYPE) + return convert_to_void (expr, ICV_CAST, complain); + /* [expr.static.cast] An expression e can be explicitly converted to a type T using a @@ -6072,12 +6078,6 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, return result; } - /* [expr.static.cast] - - Any expression can be explicitly converted to type cv void. */ - if (TREE_CODE (type) == VOID_TYPE) - return convert_to_void (expr, ICV_CAST, complain); - /* [expr.static.cast] The inverse of any standard conversion sequence (clause _conv_), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7311f7b8c4ca..371acf198f33 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-08-06 Marc Glisse + Paolo Carlini + + PR c++/54165 + * g++.dg/conversion/void2.C: New. + 2012-08-06 Tom de Vries * gcc.dg/tree-ssa/vrp78.c: New test. diff --git a/gcc/testsuite/g++.dg/conversion/void2.C b/gcc/testsuite/g++.dg/conversion/void2.C new file mode 100644 index 000000000000..9bd6d9f4c75c --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/void2.C @@ -0,0 +1,16 @@ +// PR c++/54165 + +struct A +{ + template + operator T() + { + T l[]; + } +}; + +int main() +{ + A a; + (void)a; +}