From 9e53510ee0bb5f74536f0e1636f0fb2d55edffc1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 4 Jul 2013 11:31:20 +0200 Subject: Don't create named temporary when generating C++11 code This doesn't interact well with moveable-only types (std::unique_ptr). --- xsd/cxx/parser/attribute-validation-source.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'xsd/cxx/parser/attribute-validation-source.cxx') diff --git a/xsd/cxx/parser/attribute-validation-source.cxx b/xsd/cxx/parser/attribute-validation-source.cxx index 4aadb62..c4fe5ad 100644 --- a/xsd/cxx/parser/attribute-validation-source.cxx +++ b/xsd/cxx/parser/attribute-validation-source.cxx @@ -120,10 +120,20 @@ namespace CXX os << "this->" << inst << "->" << post << " ();" << "this->" << name << " ();"; else - os << arg_type (type) << " tmp (this->" << inst << "->" << - post << " ());" - << "this->" << name << " (tmp);" - << endl; + { + // Don't create an lvalue in C++11 (think std::unique_ptr). + // In C++98 we do it for compatibility with older/broken + // compilers (e.g., IBM xlC that needs an lvalue to pass + // std::auto_ptr). + // + if (options.std () == cxx_version::cxx98) + os << arg_type (type) << " tmp (this->" << inst << "->" << + post << " ());" + << "this->" << name << " (tmp);"; + else + os << "this->" << name << " (this->" << inst << "->" << + post << " ());"; + } os << "}"; -- cgit v1.1