summaryrefslogtreecommitdiff
path: root/xsd
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-07-04 11:31:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-07-04 11:31:20 +0200
commit9e53510ee0bb5f74536f0e1636f0fb2d55edffc1 (patch)
tree62b061e562f89d89c1deb64abd71c6c60a806f34 /xsd
parent9d4a4dd3aedc0b30a55e4013b18cdb6439a9b422 (diff)
Don't create named temporary when generating C++11 code
This doesn't interact well with moveable-only types (std::unique_ptr).
Diffstat (limited to 'xsd')
-rw-r--r--xsd/cxx/parser/attribute-validation-source.cxx18
-rw-r--r--xsd/cxx/parser/element-validation-source.cxx17
2 files changed, 28 insertions, 7 deletions
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 << "}";
diff --git a/xsd/cxx/parser/element-validation-source.cxx b/xsd/cxx/parser/element-validation-source.cxx
index 3acba34..310ea27 100644
--- a/xsd/cxx/parser/element-validation-source.cxx
+++ b/xsd/cxx/parser/element-validation-source.cxx
@@ -308,9 +308,20 @@ namespace CXX
os << inst << "->" << post << " ();"
<< "this->" << name << " ();";
else
- os << arg_type (type) << " tmp (" << inst << "->" <<
- post << " ());"
- << "this->" << name << " (tmp);";
+ {
+ // 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 (" << inst << "->" <<
+ post << " ());"
+ << "this->" << name << " (tmp);";
+ else
+ os << "this->" << name << " (" << inst << "->" <<
+ post << " ());";
+ }
os << "}";
}