Commit 3dd55b2f by Paolo Carlini Committed by Paolo Carlini

re PR c++/53211 (range-based 'for' expression of type 'const int []' has incomplete type)

/cp
2013-06-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/53211
	* pt.c (type_dependent_expression_p): Handle an array of unknown
	bound depending on a variadic parameter.
	* parser.c (cp_parser_range_for): Revert PR56794 changes.

/testsuite
2013-06-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/53211
	* g++.dg/cpp0x/decltype55.C: New.

From-SVN: r200178
parent 299a5f6a
2013-06-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/53211
* pt.c (type_dependent_expression_p): Handle an array of unknown
bound depending on a variadic parameter.
* parser.c (cp_parser_range_for): Revert PR56794 changes.
2013-06-17 Richard Biener <rguenther@suse.de>
* cp-tree.h (ANON_AGGRNAME_FORMAT, ANON_AGGRNAME_P): Move to tree.h.
......
......@@ -9750,10 +9750,7 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl)
range_expr = error_mark_node;
stmt = begin_range_for_stmt (scope, init);
finish_range_for_decl (stmt, range_decl, range_expr);
if (range_expr != error_mark_node
&& !type_dependent_expression_p (range_expr)
/* The length of an array might be dependent. */
&& COMPLETE_TYPE_P (complete_type (TREE_TYPE (range_expr)))
if (!type_dependent_expression_p (range_expr)
/* do_auto_deduction doesn't mess with template init-lists. */
&& !BRACE_ENCLOSED_INITIALIZER_P (range_expr))
do_range_for_auto_deduction (range_decl, range_expr);
......
......@@ -20079,6 +20079,29 @@ type_dependent_expression_p (tree expression)
&& VAR_HAD_UNKNOWN_BOUND (expression))
return true;
/* An array of unknown bound depending on a variadic parameter, eg:
template<typename... Args>
void foo (Args... args)
{
int arr[] = { args... };
}
template<int... vals>
void bar ()
{
int arr[] = { vals... };
}
If the array has no length and has an initializer, it must be that
we couldn't determine its length in cp_complete_array_type because
it is dependent. */
if (VAR_P (expression)
&& TREE_CODE (TREE_TYPE (expression)) == ARRAY_TYPE
&& !TYPE_DOMAIN (TREE_TYPE (expression))
&& DECL_INITIAL (expression))
return true;
if (TREE_TYPE (expression) == unknown_type_node)
{
if (TREE_CODE (expression) == ADDR_EXPR)
......
2013-06-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/53211
* g++.dg/cpp0x/decltype55.C: New.
2013-06-18 Marek Polacek <polacek@redhat.com>
* gcc.dg/c90-fordecl-1.c: Adjust expected message.
......@@ -7,11 +12,11 @@
* c-c++-common/cilk-plus/AN/sec_reduce_ind_same_value.c: New test.
2013-06-17 Balaji V. Iyer <balaji.v.iyer@intel.com>
* c-c++-common/cilk-plus/AN/array_test1.c: Make this an execution test.
Also changed the returns from error as distinct values so that it is
easier to debug.
2013-06-17 Sofiane Naci <sofiane.naci@arm.com>
* gcc.target/aarch64/scalar_intrinsics.c: Update.
......
// PR c++/53211
// { dg-do compile { target c++11 } }
template<typename A, typename B>
struct is_same { static const bool value = false; };
template<typename A>
struct is_same<A, A> { static const bool value = true; };
template<typename... Args>
void func(Args... args)
{
int arr[] = { args... };
static_assert (is_same<decltype(arr), int[sizeof...(Args)]>::value, "");
}
int main()
{
func(1, 2, 3, 4);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment