diff options
author | mpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-04-01 13:08:05 +0000 |
---|---|---|
committer | mpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-04-01 13:08:05 +0000 |
commit | abab7c700188c03510cb9776b15007432816355b (patch) | |
tree | 957638af48e07034a160a9355bff94fde6b7c11d | |
parent | 7fc3fdaf30015bfb654cd2933ae351e1b0553771 (diff) | |
download | gcc-abab7c700188c03510cb9776b15007432816355b.tar.gz |
PR c++/65554
* class.c (finish_struct): Require that the second field of a
user-defined initializer_list be of size type.
* g++.dg/cpp0x/initlist93.C: New test.
* g++.dg/cpp0x/initlist94.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@221808 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/class.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist93.C | 13 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist94.C | 13 |
5 files changed, 39 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0d2456d6eb8..946450b48b0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-04-01 Marek Polacek <polacek@redhat.com> + + PR c++/65554 + * class.c (finish_struct): Require that the second field of a + user-defined initializer_list be of size type. + 2015-03-31 Marek Polacek <polacek@redhat.com> PR c++/65390 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index c2d420190c4..9f189fb5eaf 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6891,7 +6891,7 @@ finish_struct (tree t, tree attributes) if (f && TREE_CODE (TREE_TYPE (f)) == POINTER_TYPE) { f = next_initializable_field (DECL_CHAIN (f)); - if (f && TREE_CODE (TREE_TYPE (f)) == INTEGER_TYPE) + if (f && same_type_p (TREE_TYPE (f), size_type_node)) ok = true; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 24fbed7c7bd..399f9ccad37 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-04-01 Marek Polacek <polacek@redhat.com> + + PR c++/65554 + * g++.dg/cpp0x/initlist93.C: New test. + * g++.dg/cpp0x/initlist94.C: New test. + 2015-04-01 Max Ostapenko <m.ostapenko@partner.samsung.com> PR target/65624 diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist93.C b/gcc/testsuite/g++.dg/cpp0x/initlist93.C new file mode 100644 index 00000000000..84a47381f18 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist93.C @@ -0,0 +1,13 @@ +// PR c++/65554 +// { dg-do compile { target c++11 } } + +namespace std +{ +template <class> class initializer_list // { dg-error "definition of std::initializer_list does not match" } +{ + int *_M_array; + int _M_len; +}; +} + +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist94.C b/gcc/testsuite/g++.dg/cpp0x/initlist94.C new file mode 100644 index 00000000000..f83a81d3a45 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist94.C @@ -0,0 +1,13 @@ +// PR c++/65554 +// { dg-do compile { target c++11 } } + +typedef decltype (sizeof (int)) size_type; + +namespace std +{ +template <class> class initializer_list +{ + int *_M_array; + size_type _M_len; +}; +} |