re PR c++/52510 (libitm/config/posix/rwlock.cc doesn't compile)
authorJason Merrill <jason@redhat.com>
Tue, 20 Mar 2012 19:14:29 +0000 (15:14 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 20 Mar 2012 19:14:29 +0000 (15:14 -0400)
PR c++/52510
* decl.c (reshape_init_class): Handle repeated reshaping.
* search.c (lookup_field_1): Add sanity check.

From-SVN: r185587

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/search.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist66.C [new file with mode: 0644]

index 7908bb32775c9d181150de378f4ddf77fc469b46..5fbf3f57a45f1f2a7d31636e50102760f27837bd 100644 (file)
@@ -1,3 +1,9 @@
+2012-03-20  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52510
+       * decl.c (reshape_init_class): Handle repeated reshaping.
+       * search.c (lookup_field_1): Add sanity check.
+
 2012-03-19  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/14710
index a18b312841d2549959245f65f8acee8140cf36f7..2b2a551740ec501b719e175ce4fb940cfa88cc6c 100644 (file)
@@ -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)
            {
index a1f8a3db173a7dde16d71b8923dbf37415e754e3..bd1bc576429b5c476b92cbcdf38e768fd9b9ed34 100644 (file)
@@ -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)
index 124ea7234f95c19ae542fbff7e1e0268e37d4ba8..f86eb1944ea1095b4601c27a3bc948a58959143d 100644 (file)
@@ -1,3 +1,8 @@
+2012-03-20  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52510
+       * g++.dg/cpp0x/initlist66.C: New.
+
 2012-03-20  Georg-Johann Lay  <avr@gjlay.de>
 
        * gcc.target/avr/progmem.h (pgm_read_char): Define depending on
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist66.C b/gcc/testsuite/g++.dg/cpp0x/initlist66.C
new file mode 100644 (file)
index 0000000..4fc162e
--- /dev/null
@@ -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})
+{ }
+