On 21/09/16 20:23 -0700, Tim Shen wrote:
On Wed, Sep 21, 2016 at 1:52 AM, Jonathan Wakely wrote:
THanks, OK for trunk.


Committed.

This fixes the pretty printer.

Committed to trunk.

commit 6b869af56fa80da5b746390ce5616ebebcc0bd5d
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Sep 22 10:06:41 2016 +0000

    Update pretty printer for std::variant
    
    	* python/libstdcxx/v6/printers.py (StdVariantPrinter): Adjust for
    	recent change to _Variant_storage.
    	* testsuite/libstdc++-prettyprinters/cxx17.cc: Test variant with
    	reference type.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240345 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index ac529dd..18c6f6b 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -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')
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
index 42d79c0..09d79e9 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
@@ -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
 }

Reply via email to