From: Jonathan Wakely Date: Thu, 22 Sep 2016 10:06:41 +0000 (+0100) Subject: Update pretty printer for std::variant X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6fdc74c91b2d1dc12544a351721d647be1a84085;p=gcc.git 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. From-SVN: r240345 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 080b4708894..e9bb0ce0fa6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,10 @@ 2016-09-22 Jonathan Wakely + * 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) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index ac529ddbece..18c6f6b6a38 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 42d79c05e64..09d79e9e59d 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc @@ -84,6 +84,9 @@ main() variant v4{ str }; // { dg-final { note-test v4 {std::variant [index 2] = {"string"}} } } + variant vref{str}; +// { dg-final { note-test vref {std::variant > &> [index 0] = {"string"}} } } + std::cout << "\n"; return 0; // Mark SPOT }