From db9d22747831cd595b6e909a588a1c87ead2a698 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 4 Sep 2019 20:10:13 +0000 Subject: [PATCH] Remove -fdeduce-init-list. From-SVN: r275387 --- gcc/ChangeLog | 4 ++++ gcc/c-family/ChangeLog | 4 ++++ gcc/c-family/c.opt | 4 ++-- gcc/cp/ChangeLog | 5 +++++ gcc/cp/call.c | 32 ---------------------------- gcc/cp/pt.c | 5 ----- gcc/doc/invoke.texi | 22 ------------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C | 12 +++-------- 9 files changed, 23 insertions(+), 70 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index be92d37..0f4b61d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2019-09-04 Marek Polacek + + * doc/invoke.texi: Remove -fdeduce-init-list documentation. + 2019-09-04 Uroš Bizjak PR target/32413 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index ecdaaeb..2720e64 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2019-09-04 Marek Polacek + + * c.opt (fdeduce-init-list): Ignored. + 2019-09-04 Prathamesh Kulkarni PR c/78736 diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 38a8e7d..143833d 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1460,8 +1460,8 @@ C ObjC C++ ObjC++ Emit debug annotations during preprocessing. fdeduce-init-list -C++ ObjC++ Var(flag_deduce_init_list) Init(0) --fdeduce-init-list enable deduction of std::initializer_list for a template type parameter from a brace-enclosed initializer-list. +C++ ObjC++ Ignore +Does nothing. Preserved for backward compatibility. fdeclone-ctor-dtor C++ ObjC++ Var(flag_declone_ctor_dtor) Init(-1) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8eb81c5..605b3d7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-09-04 Marek Polacek + + * call.c (build_over_call): Remove -fdeduce-init-list implementation. + * pt.c (unify): Likewise. + 2019-09-01 Marek Polacek PR c++/91129 - wrong error with binary op in template argument. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 01a25ad..c3045d9 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8337,38 +8337,6 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) && !(flags & LOOKUP_EXPLICIT_TMPL_ARGS)) conversion_warning = false; - /* Warn about initializer_list deduction that isn't currently in the - working draft. */ - if (cxx_dialect > cxx98 - && flag_deduce_init_list - && cand->template_decl - && is_std_init_list (non_reference (type)) - && BRACE_ENCLOSED_INITIALIZER_P (arg)) - { - tree tmpl = TI_TEMPLATE (cand->template_decl); - tree realparm = chain_index (j, DECL_ARGUMENTS (cand->fn)); - tree patparm = get_pattern_parm (realparm, tmpl); - tree pattype = TREE_TYPE (patparm); - if (PACK_EXPANSION_P (pattype)) - pattype = PACK_EXPANSION_PATTERN (pattype); - pattype = non_reference (pattype); - - if (TREE_CODE (pattype) == TEMPLATE_TYPE_PARM - && (cand->explicit_targs == NULL_TREE - || (TREE_VEC_LENGTH (cand->explicit_targs) - <= TEMPLATE_TYPE_IDX (pattype)))) - { - pedwarn (input_location, 0, "deducing %qT as %qT", - non_reference (TREE_TYPE (patparm)), - non_reference (type)); - pedwarn (DECL_SOURCE_LOCATION (cand->fn), 0, - " in call to %qD", cand->fn); - pedwarn (input_location, 0, - " (you can disable this with " - "%<-fno-deduce-init-list%>)"); - } - } - /* Set user_conv_p on the argument conversions, so rvalue/base handling knows not to allow any more UDCs. This needs to happen after we process cand->warnings. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 187f9d8..15cc4b2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -22073,11 +22073,6 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, unsigned i; tree orig_parm = parm; - /* Replace T with std::initializer_list for deduction. */ - if (TREE_CODE (parm) == TEMPLATE_TYPE_PARM - && flag_deduce_init_list) - parm = listify (parm); - if (!is_std_init_list (parm) && TREE_CODE (parm) != ARRAY_TYPE) /* We can only deduce from an initializer list argument if the diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 34d0746..fad19dd 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2550,28 +2550,6 @@ of a loop too many expressions need to be evaluated, the resulting constexpr evaluation might take too long. The default is 33554432 (1<<25). -@item -fdeduce-init-list -@opindex fdeduce-init-list -Enable deduction of a template type parameter as -@code{std::initializer_list} from a brace-enclosed initializer list, i.e.@: - -@smallexample -template auto forward(T t) -> decltype (realfn (t)) -@{ - return realfn (t); -@} - -void f() -@{ - forward(@{1,2@}); // call forward> -@} -@end smallexample - -This deduction was implemented as a possible extension to the -originally proposed semantics for the C++11 standard, but was not part -of the final standard, so it is disabled by default. This option is -deprecated, and may be removed in a future version of G++. - @item -fno-elide-constructors @opindex fno-elide-constructors @opindex felide-constructors diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5b6332a..ecde4ca 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-09-04 Marek Polacek + + * g++.dg/cpp0x/initlist-deduce.C: Don't use -fdeduce-init-list. Remove + dg-warning. Add dg-error. + 2019-09-04 Prathamesh Kulkarni PR c/78736 diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C b/gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C index 6ae32a6..59d98ef 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C @@ -1,9 +1,4 @@ -// Test for deduction of T as std::initializer_list. This isn't currently -// supported by the working draft, but is necessary for perfect forwarding -// of initializer-lists to things that can take a std::initializer_list. - -// { dg-options "-fdeduce-init-list" } -// { dg-do run { target c++11 } } +// { dg-do compile { target c++11 } } #include @@ -15,14 +10,13 @@ struct A void f (A a) { } template -auto g (T&& t) -> decltype (f(t)) // { dg-warning "call" } +auto g (T&& t) -> decltype (f(t)) { return f(t); } int main() { - g({1}); // { dg-warning "deduc" } + g({1}); // { dg-error "no matching function" } } -// { dg-prune-output "-fno-deduce-init-list" } -- 2.7.4