Update pretty printer for std::variant
authorJonathan Wakely <jwakely@redhat.com>
Thu, 22 Sep 2016 10:06:41 +0000 (11:06 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 22 Sep 2016 10:06:41 +0000 (11:06 +0100)
* python/libstdcxx/v6/printers.py (StdVariantPrinter): Adjust for
recent change to _Variant_storage.
* testsuite/libstdc++-prettyprinters/cxx17.cc: Test variant with
reference type.

From-SVN: r240345

libstdc++-v3/ChangeLog
libstdc++-v3/python/libstdcxx/v6/printers.py
libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc

index 080b4708894629d9b288373f9fa2a84455faaff7..e9bb0ce0fa6d7b4cabf2921384a71b7f5cb7fbe5 100644 (file)
@@ -1,5 +1,10 @@
 2016-09-22  Jonathan Wakely  <jwakely@redhat.com>
 
+       * python/libstdcxx/v6/printers.py (StdVariantPrinter): Adjust for
+       recent change to _Variant_storage.
+       * testsuite/libstdc++-prettyprinters/cxx17.cc: Test variant with
+       reference type.
+
        * include/bits/uses_allocator.h (__uses_allocator_construct): Qualify
        std::forward and ::new. Cast pointer to void*.
        * include/std/variant (_Variant_storage, _Union, _Variant_base)
index ac529ddbece51db7b6b59a8c942b16213a1a6a94..18c6f6b6a380c42b040a850da6b07bda83efa023 100644 (file)
@@ -994,7 +994,7 @@ class StdVariantPrinter(SingleObjContainerPrinter):
             visualizer = None
         else:
             self.contained_type = alternatives[int(self.index)]
-            addr = val['_M_first']['_M_storage'].address
+            addr = val['_M_union']['_M_first']['_M_storage'].address
             contained_value = addr.cast(self.contained_type.pointer()).dereference()
             visualizer = gdb.default_visualizer(contained_value)
         super (StdVariantPrinter, self).__init__(contained_value, visualizer, 'array')
index 42d79c05e6481019396e7542ec4ab437e34b6a24..09d79e9e59d5b7ca8396ca1f4f1775fb5c61b2bd 100644 (file)
@@ -84,6 +84,9 @@ main()
   variant<float, int, string_view> v4{ str };
 // { dg-final { note-test v4 {std::variant<float, int, std::string_view> [index 2] = {"string"}} } }
 
+  variant<string_view&> vref{str};
+// { dg-final { note-test vref {std::variant<std::basic_string_view<char, std::char_traits<char> > &> [index 0] = {"string"}} } }
+
   std::cout << "\n";
   return 0;                    // Mark SPOT
 }