From 84b64170630dee8583c444e6dbf9df00fe6e88b5 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 9 Jul 2014 21:23:06 +0000 Subject: DR 1584 PR c++/57466 /cp 2014-07-09 Paolo Carlini DR 1584 PR c++/57466 * pt.c (check_cv_quals_for_unify): Implement resolution, disregard cv-qualifiers of function types. /testsuite 2014-07-09 Paolo Carlini DR 1584 PR c++/57466 * g++.dg/template/pr57466.C: New. * g++.dg/cpp0x/pr57466.C: Likewise. * g++.dg/template/unify6.C: Update. From-SVN: r212410 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/pt.c | 5 +++++ gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/g++.dg/cpp0x/pr57466.C | 18 ++++++++++++++++++ gcc/testsuite/g++.dg/template/pr57466.C | 8 ++++++++ gcc/testsuite/g++.dg/template/unify6.C | 11 +++++------ 6 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr57466.C create mode 100644 gcc/testsuite/g++.dg/template/pr57466.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f1832ce4..6174193 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2014-07-09 Paolo Carlini + + DR 1584 + PR c++/57466 + * pt.c (check_cv_quals_for_unify): Implement resolution, disregard + cv-qualifiers of function types. + 2014-07-09 Andrew Sutton Paolo Carlini diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7bbbf03..7b79280 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17189,6 +17189,11 @@ check_cv_quals_for_unify (int strict, tree arg, tree parm) int arg_quals = cp_type_quals (arg); int parm_quals = cp_type_quals (parm); + /* DR 1584: cv-qualification of a deduced function type is + ignored; see 8.3.5 [dcl.fct]. */ + if (TREE_CODE (arg) == FUNCTION_TYPE) + return 1; + if (TREE_CODE (parm) == TEMPLATE_TYPE_PARM && !(strict & UNIFY_ALLOW_OUTER_MORE_CV_QUAL)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e4cd3bc..675e343 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2014-07-09 Paolo Carlini + + DR 1584 + PR c++/57466 + * g++.dg/template/pr57466.C: New. + * g++.dg/cpp0x/pr57466.C: Likewise. + * g++.dg/template/unify6.C: Update. + 2014-07-09 Francois-Xavier Coudert * gfortran.dg/ieee/underflow_1.f90: New file. diff --git a/gcc/testsuite/g++.dg/cpp0x/pr57466.C b/gcc/testsuite/g++.dg/cpp0x/pr57466.C new file mode 100644 index 0000000..792a3cb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr57466.C @@ -0,0 +1,18 @@ +// PR c++/57466 +// { dg-do compile { target c++11 } } + +template + constexpr bool + is_pointer(const T*) + { return true; } + +template + constexpr bool + is_pointer(const T&) + { return false; } + +using F = void(); + +constexpr F* f = nullptr; + +static_assert( is_pointer(f), "function pointer is a pointer" ); diff --git a/gcc/testsuite/g++.dg/template/pr57466.C b/gcc/testsuite/g++.dg/template/pr57466.C new file mode 100644 index 0000000..6dd3710 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr57466.C @@ -0,0 +1,8 @@ +// DR 1584, PR c++/57466 + +template void f2(const T*); +void g2(); + +void m() { + f2(g2); // OK: cv-qualification of deduced function type ignored +} diff --git a/gcc/testsuite/g++.dg/template/unify6.C b/gcc/testsuite/g++.dg/template/unify6.C index 551c96e..374bb91 100644 --- a/gcc/testsuite/g++.dg/template/unify6.C +++ b/gcc/testsuite/g++.dg/template/unify6.C @@ -3,21 +3,20 @@ void Baz (); -template void Foo1 (T *); // #1 -template void Foo1 (T const *a) {a (1);} // #2 +template void Foo1 (T *); +template void Foo1 (T const *a) {a (1);} // { dg-error "too many arguments" } template T const *Foo2 (T *); -template void Foo3 (T *, T const * = 0); // { dg-message "note" } +template void Foo3 (T *, T const * = 0); void Bar () { - Foo1 (&Baz); // #1 + Foo1 (&Baz); // { dg-message "required from here" } Foo2 (&Baz); Foo3 (&Baz); - Foo3 (&Baz, &Baz); // { dg-error "no matching function" "" } - // { dg-message "(candidate|incompatible cv-qualifiers)" "candidate note" { target *-*-* } 21 } + Foo3 (&Baz, &Baz); } -- cgit v1.1