From: Dodji Seketeli Date: Wed, 27 Apr 2011 12:07:34 +0000 (+0000) Subject: Backport fix for PRs c++/46824, c++/42260, c++/45383 X-Git-Tag: releases/gcc-4.5.3~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f84712a73c571d229258fb8b25b96043facef63;p=thirdparty%2Fgcc.git Backport fix for PRs c++/46824, c++/42260, c++/45383 gcc/cp * call.c (add_builtin_candidate): The type of the argument of the indirection operator should not be dependent. Fix the comment. gcc/testsuite * g++.dg/conversion/cast2.C: New test. * g++.dg/conversion/cast3.C: Likewise. * g++.dg/conversion/cond4.C: Likewise. From-SVN: r173025 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ac636d345387..3ee681503173 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2011-04-26 Dodji Seketeli + + PR c++/46824 + * call.c (add_builtin_candidate): The type of + the argument of the indirection operator should not be dependent. + Fix the comment. + 2011-04-26 Jason Merrill PR c++/42687 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d4b7b050a33a..fce96b0eacf8 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1925,7 +1925,7 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code, } return; -/* 7 For every cv-qualified or cv-unqualified complete object type T, there +/* 7 For every cv-qualified or cv-unqualified object type T, there exist candidate operator functions of the form T& operator*(T*); @@ -1936,6 +1936,7 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code, case INDIRECT_REF: if (TREE_CODE (type1) == POINTER_TYPE + && !uses_template_parms (TREE_TYPE (type1)) && (TYPE_PTROB_P (type1) || TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE)) break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 888ee6035082..4d6f2f321d45 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2011-04-27 Dodji Seketeli + + PR c++/46824, c++/42260, c++/45383 + * g++.dg/conversion/cast2.C: New test. + * g++.dg/conversion/cast3.C: Likewise. + * g++.dg/conversion/cond4.C: Likewise. + 2011-04-26 Jason Merrill * g++.dg/lookup/koenig13.C: New. diff --git a/gcc/testsuite/g++.dg/conversion/cast2.C b/gcc/testsuite/g++.dg/conversion/cast2.C new file mode 100644 index 000000000000..60af70d1872f --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/cast2.C @@ -0,0 +1,10 @@ +// Contributed by Dodji Seketeli +// Origin: PR c++/42260 +// { dg-do compile } + +struct A +{ + template operator T*(); +}; + +int i = *A();// { dg-error "no match" } diff --git a/gcc/testsuite/g++.dg/conversion/cast3.C b/gcc/testsuite/g++.dg/conversion/cast3.C new file mode 100644 index 000000000000..43287a1eb368 --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/cast3.C @@ -0,0 +1,14 @@ +// Origin: PR c++/46824 + +class Incomplete; +struct Ptr +{ + operator Incomplete*(); +}; + +int +main() +{ + Ptr p; + *p; +} diff --git a/gcc/testsuite/g++.dg/conversion/cond4.C b/gcc/testsuite/g++.dg/conversion/cond4.C new file mode 100644 index 000000000000..3bd64763a183 --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/cond4.C @@ -0,0 +1,31 @@ +// Origin: PR c++/45383 +// { dg-do run } + +struct null { + null() {} + template + operator T*() const { + return 0; + } + + template + operator T C::*() const { + return 0; + } +private: + null(const null&); + null& operator=(const null&); + void operator&() const; +}; + +static struct null null; + +int +main() +{ + int* ptr = null; + if (ptr == null) + return 0; + if (ptr != null) + return 1; +}