diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2013-06-18 22:20:10 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2013-06-18 22:20:10 +0000 |
commit | 3dd55b2f9fdbf102dad43fca46578f4054174d45 (patch) | |
tree | 27ef82e87b2d387554a2aeeb7e01bb6eaa32823f /gcc | |
parent | 299a5f6a095479accf70497650752faaae9ed859 (diff) | |
download | gcc-3dd55b2f9fdbf102dad43fca46578f4054174d45.zip gcc-3dd55b2f9fdbf102dad43fca46578f4054174d45.tar.gz gcc-3dd55b2f9fdbf102dad43fca46578f4054174d45.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/parser.c | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/decltype55.C | 20 |
5 files changed, 58 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1b58ba0..7e25e52 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +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. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d844d15..904ae0b 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3602fcd..25cbf31 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 743ae6c..53b844f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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. diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype55.C b/gcc/testsuite/g++.dg/cpp0x/decltype55.C new file mode 100644 index 0000000..95427fc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype55.C @@ -0,0 +1,20 @@ +// 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); +} |