re PR c++/57397 (Off-by-one error in diagnostic when calling variadic function template with too few arguments)
/cp 2014-07-30 Paolo Carlini <paolo.carlini@oracle.com> PR c++/57397 * pt.c (unify_arity): Add boolean parameter. (unify_too_few_arguments): Likewise. (type_unification_real): Diagnose correctly insufficient arguments in the presence of trailing variadic parameters; deducing multiple trailing packs as empty is fine. /testsuite 2014-07-30 Paolo Carlini <paolo.carlini@oracle.com> PR c++/57397 * g++.dg/cpp0x/vt-57397-1.C: New. * g++.dg/cpp0x/vt-57397-2.C: Likewise. From-SVN: r213310
This commit is contained in:
parent
b6d9404508
commit
5b9802c45c
@ -1,3 +1,12 @@
|
|||||||
|
2014-07-30 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
PR c++/57397
|
||||||
|
* pt.c (unify_arity): Add boolean parameter.
|
||||||
|
(unify_too_few_arguments): Likewise.
|
||||||
|
(type_unification_real): Diagnose correctly insufficient
|
||||||
|
arguments in the presence of trailing variadic parameters;
|
||||||
|
deducing multiple trailing packs as empty is fine.
|
||||||
|
|
||||||
2014-07-30 Jason Merrill <jason@redhat.com>
|
2014-07-30 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
PR c++/61659
|
PR c++/61659
|
||||||
|
39
gcc/cp/pt.c
39
gcc/cp/pt.c
@ -5527,13 +5527,21 @@ unify_method_type_error (bool explain_p, tree arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unify_arity (bool explain_p, int have, int wanted)
|
unify_arity (bool explain_p, int have, int wanted, bool least_p = false)
|
||||||
{
|
{
|
||||||
if (explain_p)
|
if (explain_p)
|
||||||
inform_n (input_location, wanted,
|
{
|
||||||
" candidate expects %d argument, %d provided",
|
if (least_p)
|
||||||
" candidate expects %d arguments, %d provided",
|
inform_n (input_location, wanted,
|
||||||
wanted, have);
|
" candidate expects at least %d argument, %d provided",
|
||||||
|
" candidate expects at least %d arguments, %d provided",
|
||||||
|
wanted, have);
|
||||||
|
else
|
||||||
|
inform_n (input_location, wanted,
|
||||||
|
" candidate expects %d argument, %d provided",
|
||||||
|
" candidate expects %d arguments, %d provided",
|
||||||
|
wanted, have);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5544,9 +5552,10 @@ unify_too_many_arguments (bool explain_p, int have, int wanted)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unify_too_few_arguments (bool explain_p, int have, int wanted)
|
unify_too_few_arguments (bool explain_p, int have, int wanted,
|
||||||
|
bool least_p = false)
|
||||||
{
|
{
|
||||||
return unify_arity (explain_p, have, wanted);
|
return unify_arity (explain_p, have, wanted, least_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -16627,18 +16636,26 @@ type_unification_real (tree tparms,
|
|||||||
are present, and the parm list isn't variadic. */
|
are present, and the parm list isn't variadic. */
|
||||||
if (ia < nargs && parms == void_list_node)
|
if (ia < nargs && parms == void_list_node)
|
||||||
return unify_too_many_arguments (explain_p, nargs, ia);
|
return unify_too_many_arguments (explain_p, nargs, ia);
|
||||||
/* Fail if parms are left and they don't have default values. */
|
/* Fail if parms are left and they don't have default values and
|
||||||
|
they aren't all deduced as empty packs (c++/57397). This is
|
||||||
|
consistent with sufficient_parms_p. */
|
||||||
if (parms && parms != void_list_node
|
if (parms && parms != void_list_node
|
||||||
&& TREE_PURPOSE (parms) == NULL_TREE)
|
&& TREE_PURPOSE (parms) == NULL_TREE)
|
||||||
{
|
{
|
||||||
unsigned int count = nargs;
|
unsigned int count = nargs;
|
||||||
tree p = parms;
|
tree p = parms;
|
||||||
while (p && p != void_list_node)
|
bool type_pack_p;
|
||||||
|
do
|
||||||
{
|
{
|
||||||
count++;
|
type_pack_p = TREE_CODE (TREE_VALUE (p)) == TYPE_PACK_EXPANSION;
|
||||||
|
if (!type_pack_p)
|
||||||
|
count++;
|
||||||
p = TREE_CHAIN (p);
|
p = TREE_CHAIN (p);
|
||||||
}
|
}
|
||||||
return unify_too_few_arguments (explain_p, ia, count);
|
while (p && p != void_list_node);
|
||||||
|
if (count != nargs)
|
||||||
|
return unify_too_few_arguments (explain_p, ia, count,
|
||||||
|
type_pack_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!subr)
|
if (!subr)
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2014-07-30 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
PR c++/57397
|
||||||
|
* g++.dg/cpp0x/vt-57397-1.C: New.
|
||||||
|
* g++.dg/cpp0x/vt-57397-2.C: Likewise.
|
||||||
|
|
||||||
2014-07-30 Arnaud Charlet <charlet@adacore.com>
|
2014-07-30 Arnaud Charlet <charlet@adacore.com>
|
||||||
|
|
||||||
* gnat.dg/case_null.adb, gnat.dg/specs/debug1.ads: Adjust tests.
|
* gnat.dg/case_null.adb, gnat.dg/specs/debug1.ads: Adjust tests.
|
||||||
@ -11,7 +17,6 @@
|
|||||||
|
|
||||||
* g++.dg/ipa/devirt-34.C: New testcase.
|
* g++.dg/ipa/devirt-34.C: New testcase.
|
||||||
|
|
||||||
>>>>>>> .r213302
|
|
||||||
2014-07-28 Richard Biener <rguenther@suse.de>
|
2014-07-28 Richard Biener <rguenther@suse.de>
|
||||||
|
|
||||||
PR rtl-optimization/61801
|
PR rtl-optimization/61801
|
||||||
|
22
gcc/testsuite/g++.dg/cpp0x/vt-57397-1.C
Normal file
22
gcc/testsuite/g++.dg/cpp0x/vt-57397-1.C
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// PR c++/57397
|
||||||
|
// { dg-do compile { target c++11 } }
|
||||||
|
|
||||||
|
template<class T1, class... Tn>
|
||||||
|
void foo(T1, Tn...);
|
||||||
|
|
||||||
|
template<class T1, class T2, class... Tn>
|
||||||
|
void bar(T1, T2, Tn...);
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
foo(); // { dg-error "no matching" }
|
||||||
|
// { dg-message "candidate expects at least 1 argument, 0 provided" "" { target *-*-* } 12 }
|
||||||
|
foo(1);
|
||||||
|
foo(1, 2);
|
||||||
|
bar(); // { dg-error "no matching" }
|
||||||
|
// { dg-message "candidate expects at least 2 arguments, 0 provided" "" { target *-*-* } 16 }
|
||||||
|
bar(1); // { dg-error "no matching" }
|
||||||
|
// { dg-message "candidate expects at least 2 arguments, 1 provided" "" { target *-*-* } 18 }
|
||||||
|
bar(1, 2);
|
||||||
|
bar(1, 2, 3);
|
||||||
|
}
|
24
gcc/testsuite/g++.dg/cpp0x/vt-57397-2.C
Normal file
24
gcc/testsuite/g++.dg/cpp0x/vt-57397-2.C
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// PR c++/57397
|
||||||
|
// { dg-do compile { target c++11 } }
|
||||||
|
|
||||||
|
template<class T1, class... Tn, class... Tm>
|
||||||
|
void foo(T1, Tn..., Tm...);
|
||||||
|
|
||||||
|
template<class T1, class T2, class... Tn, class... Tm>
|
||||||
|
void bar(T1, T2, Tn..., Tm...);
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
foo(); // { dg-error "no matching" }
|
||||||
|
// { dg-message "candidate expects at least 1 argument, 0 provided" "" { target *-*-* } 12 }
|
||||||
|
foo(1);
|
||||||
|
foo(1, 2);
|
||||||
|
foo(1, 2, 3);
|
||||||
|
bar(); // { dg-error "no matching" }
|
||||||
|
// { dg-message "candidate expects at least 2 arguments, 0 provided" "" { target *-*-* } 17 }
|
||||||
|
bar(1); // { dg-error "no matching" }
|
||||||
|
// { dg-message "candidate expects at least 2 arguments, 1 provided" "" { target *-*-* } 19 }
|
||||||
|
bar(1, 2);
|
||||||
|
bar(1, 2, 3);
|
||||||
|
bar(1, 2, 3, 4);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user