* C++ PATCH for c++/52510 (rejects-valid with list-initialization of pthread_cond)
@ 2012-03-20 19:17 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2012-03-20 19:17 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 235 bytes --]
My change for core issue 1270 to allow brace elision in all
list-initialization resulted in multiple calls to reshape_init for the
same CONSTRUCTOR, which we weren't handling properly.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 52510.patch --]
[-- Type: text/x-patch, Size: 2108 bytes --]
commit d7b5c07030b11599b846342b19ff50306043965f
Author: Jason Merrill <jason@redhat.com>
Date: Mon Mar 19 16:57:48 2012 -0400
PR c++/52510
* decl.c (reshape_init_class): Handle repeated reshaping.
* search.c (lookup_field_1): Add sanity check.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a18b312..2b2a551 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5110,7 +5110,11 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p,
return error_mark_node;
}
- field = lookup_field_1 (type, d->cur->index, /*want_type=*/false);
+ if (TREE_CODE (d->cur->index) == FIELD_DECL)
+ /* We already reshaped this. */
+ gcc_assert (d->cur->index == field);
+ else
+ field = lookup_field_1 (type, d->cur->index, /*want_type=*/false);
if (!field || TREE_CODE (field) != FIELD_DECL)
{
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index a1f8a3d..bd1bc57 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -384,6 +384,8 @@ lookup_field_1 (tree type, tree name, bool want_type)
{
tree field;
+ gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
+
if (TREE_CODE (type) == TEMPLATE_TYPE_PARM
|| TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM
|| TREE_CODE (type) == TYPENAME_TYPE)
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist66.C b/gcc/testsuite/g++.dg/cpp0x/initlist66.C
new file mode 100644
index 0000000..4fc162e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist66.C
@@ -0,0 +1,29 @@
+// PR c++/52510
+// { dg-do compile { target c++11 } }
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+typedef uint64_t upad64_t;
+
+typedef struct _pthread_cond {
+ struct {
+ uint8_t __pthread_cond_flag[4];
+ uint16_t __pthread_cond_type;
+ uint16_t __pthread_cond_magic;
+ } __pthread_cond_flags;
+ upad64_t __pthread_cond_data;
+} pthread_cond_t;
+
+class gtm_rwlock
+{
+ pthread_cond_t c_readers;
+ public:
+ gtm_rwlock();
+};
+
+gtm_rwlock::gtm_rwlock()
+ : c_readers ({{{0, 0, 0, 0}, 0, 0x4356}, 0})
+{ }
+
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-03-20 19:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-20 19:17 C++ PATCH for c++/52510 (rejects-valid with list-initialization of pthread_cond) Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).