PR c++/77790 - ICE with auto function in C++11 mode
* decl.c (undeduced_auto_decl): Remove C++14 limitation. (require_deduced_type): Add complain parm, return bool. * cp-tree.h: Adjust. * decl2.c (mark_used): Use require_deduced_type. From-SVN: r245358
This commit is contained in:
parent
31deea5e71
commit
bc61048a14
@ -1,3 +1,11 @@
|
|||||||
|
2017-02-11 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/77790 - ICE with auto function in C++11 mode
|
||||||
|
* decl.c (undeduced_auto_decl): Remove C++14 limitation.
|
||||||
|
(require_deduced_type): Add complain parm, return bool.
|
||||||
|
* cp-tree.h: Adjust.
|
||||||
|
* decl2.c (mark_used): Use require_deduced_type.
|
||||||
|
|
||||||
2017-02-10 Jason Merrill <jason@redhat.com>
|
2017-02-10 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
PR c++/78908 - template ops and bitfields
|
PR c++/78908 - template ops and bitfields
|
||||||
|
@ -5909,7 +5909,7 @@ extern tree reshape_init (tree, tree, tsubst_flags_t);
|
|||||||
extern tree next_initializable_field (tree);
|
extern tree next_initializable_field (tree);
|
||||||
extern tree fndecl_declared_return_type (tree);
|
extern tree fndecl_declared_return_type (tree);
|
||||||
extern bool undeduced_auto_decl (tree);
|
extern bool undeduced_auto_decl (tree);
|
||||||
extern void require_deduced_type (tree);
|
extern bool require_deduced_type (tree, tsubst_flags_t = tf_warning_or_error);
|
||||||
|
|
||||||
extern tree finish_case_label (location_t, tree, tree);
|
extern tree finish_case_label (location_t, tree, tree);
|
||||||
extern tree cxx_maybe_build_cleanup (tree, tsubst_flags_t);
|
extern tree cxx_maybe_build_cleanup (tree, tsubst_flags_t);
|
||||||
|
@ -16138,24 +16138,29 @@ fndecl_declared_return_type (tree fn)
|
|||||||
return TREE_TYPE (TREE_TYPE (fn));
|
return TREE_TYPE (TREE_TYPE (fn));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns true iff DECL was declared with an auto return type and it has
|
/* Returns true iff DECL was declared with an auto type and it has
|
||||||
not yet been deduced to a real type. */
|
not yet been deduced to a real type. */
|
||||||
|
|
||||||
bool
|
bool
|
||||||
undeduced_auto_decl (tree decl)
|
undeduced_auto_decl (tree decl)
|
||||||
{
|
{
|
||||||
if (cxx_dialect < cxx14)
|
if (cxx_dialect < cxx11)
|
||||||
return false;
|
return false;
|
||||||
return type_uses_auto (TREE_TYPE (decl));
|
return type_uses_auto (TREE_TYPE (decl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Complain if DECL has an undeduced return type. */
|
/* Complain if DECL has an undeduced return type. */
|
||||||
|
|
||||||
void
|
bool
|
||||||
require_deduced_type (tree decl)
|
require_deduced_type (tree decl, tsubst_flags_t complain)
|
||||||
{
|
{
|
||||||
if (undeduced_auto_decl (decl))
|
if (undeduced_auto_decl (decl))
|
||||||
|
{
|
||||||
|
if (complain & tf_error)
|
||||||
error ("use of %qD before deduction of %<auto%>", decl);
|
error ("use of %qD before deduction of %<auto%>", decl);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "gt-cp-decl.h"
|
#include "gt-cp-decl.h"
|
||||||
|
@ -5084,12 +5084,9 @@ mark_used (tree decl, tsubst_flags_t complain)
|
|||||||
|| DECL_LANG_SPECIFIC (decl) == NULL
|
|| DECL_LANG_SPECIFIC (decl) == NULL
|
||||||
|| DECL_THUNK_P (decl))
|
|| DECL_THUNK_P (decl))
|
||||||
{
|
{
|
||||||
if (!processing_template_decl && type_uses_auto (TREE_TYPE (decl)))
|
if (!processing_template_decl
|
||||||
{
|
&& !require_deduced_type (decl, complain))
|
||||||
if (complain & tf_error)
|
|
||||||
error ("use of %qD before deduction of %<auto%>", decl);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5117,12 +5114,8 @@ mark_used (tree decl, tsubst_flags_t complain)
|
|||||||
&& uses_template_parms (DECL_TI_ARGS (decl)))
|
&& uses_template_parms (DECL_TI_ARGS (decl)))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (undeduced_auto_decl (decl))
|
if (!require_deduced_type (decl, complain))
|
||||||
{
|
|
||||||
if (complain & tf_error)
|
|
||||||
error ("use of %qD before deduction of %<auto%>", decl);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
/* If we don't need a value, then we don't need to synthesize DECL. */
|
/* If we don't need a value, then we don't need to synthesize DECL. */
|
||||||
if (cp_unevaluated_operand || in_discarded_stmt)
|
if (cp_unevaluated_operand || in_discarded_stmt)
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
// { dg-do compile { target c++11 } }
|
// { dg-do compile { target c++11 } }
|
||||||
|
|
||||||
auto foo(); // { dg-error "auto" "" { target { ! c++14 } } }
|
auto foo(); // { dg-error "auto" "" { target { ! c++14 } } }
|
||||||
auto fp = foo; // { dg-error "auto" "" { target c++14 } }
|
auto fp = foo; // { dg-error "auto" }
|
||||||
|
11
gcc/testsuite/g++.dg/cpp1y/auto-fn35.C
Normal file
11
gcc/testsuite/g++.dg/cpp1y/auto-fn35.C
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// PR c++/77790
|
||||||
|
// { dg-do compile { target c++11 } }
|
||||||
|
|
||||||
|
template < typename S > struct A
|
||||||
|
{
|
||||||
|
// { dg-error "" "" { target c++11_only } .+1 }
|
||||||
|
template < typename T > static auto f () { return 0; }
|
||||||
|
template < class U = decltype (f < S > ()) > int g () { return 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
auto a = A < int > {}.g ();
|
Loading…
Reference in New Issue
Block a user