diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2012-08-06 11:49:39 +0200 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2012-08-06 09:49:39 +0000 |
commit | ca73dc295e4b1d891511cc2ce842c50d397e8cbe (patch) | |
tree | c9f965b45e0805505508b0e2a69509effef473ca /gcc | |
parent | af42f4d20b522c48efb14e57737da616687c5849 (diff) | |
download | gcc-ca73dc295e4b1d891511cc2ce842c50d397e8cbe.zip gcc-ca73dc295e4b1d891511cc2ce842c50d397e8cbe.tar.gz gcc-ca73dc295e4b1d891511cc2ce842c50d397e8cbe.tar.bz2 |
re PR c++/54165 (Cast to "void" should not implicitly call conversion functions)
/cp
2012-08-06 Marc Glisse <marc.glisse@inria.fr>
Paolo Carlini <paolo.carlini@oracle.com>
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 <marc.glisse@inria.fr>
Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54165
* g++.dg/conversion/void2.C: New.
Co-Authored-By: Paolo Carlini <paolo.carlini@oracle.com>
From-SVN: r190175
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/conversion/void2.C | 16 |
4 files changed, 35 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f57769d..86c9097 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2012-08-06 Marc Glisse <marc.glisse@inria.fr> + Paolo Carlini <paolo.carlini@oracle.com> + + 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 <marc.glisse@inria.fr> * pt.c (tsubst_copy_and_build): Handle VECTOR_TYPE like scalars. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d7a719f..25f37e8 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6053,6 +6053,12 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, /* [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 static_cast of the form static_cast<T>(e) if the declaration T t(e);" is well-formed, for some invented temporary variable @@ -6074,12 +6080,6 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, /* [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_), other than the lvalue-to-rvalue (_conv.lval_), array-to-pointer (_conv.array_), function-to-pointer (_conv.func_), and boolean diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7311f7b..371acf1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-08-06 Marc Glisse <marc.glisse@inria.fr> + Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/54165 + * g++.dg/conversion/void2.C: New. + 2012-08-06 Tom de Vries <tom@codesourcery.com> * 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 0000000..9bd6d9f --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/void2.C @@ -0,0 +1,16 @@ +// PR c++/54165 + +struct A +{ + template<typename T> + operator T() + { + T l[]; + } +}; + +int main() +{ + A a; + (void)a; +} |