Blob Blame History Raw
From 049d078b605900efec98c6a9caceb17cdc10c5e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 30 Mar 2016 14:47:26 +0200
Subject: [PATCH] Adapt to GCC 6
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

GCC 6 produces this error:

src/generate/t_java_generator.cc: In member function 'void t_java_generator::generate_process_async_function(t_service*, t_function*)':
src/generate/t_java_generator.cc:2830:14: error: operands to ?: have different types 'bool' and 'std::basic_ostream<char>'
        first ? first = false : indent(f_service_) << "else ";
        ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This patch ports relevant part of upstream commit:

t 16a23a6618754a5a87aeb8df99a72516b0272fb3
Author: Konrad Grochowski <hcorg@apache.org>
Date:   Thu Nov 13 15:33:38 2014 +0100

    THRIFT-2729: C++ - .clang-format created and applied

    Client: C++
    Patch: Konrad Grochowski

    make style command added

and:

commit 5f2d34e5ab33651059a085525b3adbab6a877e6f
Author: Roger Meier <roger@apache.org>
Date:   Sat Nov 16 16:43:41 2013 +0100

    THRIFT-2229 thrift failed to build on OSX 10.9 GM

that are part of 0.9.3 release.

<https://bugzilla.redhat.com/show_bug.cgi?id=1306671>

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 compiler/cpp/src/generate/t_java_generator.cc |  3 ++-
 compiler/cpp/src/generate/t_rb_generator.cc   |  8 ++++----
 tutorial/cpp/CppClient.cpp                    |  6 +++---
 tutorial/cpp/CppServer.cpp                    | 16 ++++++++--------
 4 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index e443dc0..0f8740e 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -2827,7 +2827,8 @@ void t_java_generator::generate_process_async_function(t_service* tservice,
      bool first = true;
      if (xceptions.size() > 0) {
     	 for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-    		 first ? first = false : indent(f_service_) << "else ";
+		 if (x_iter != xceptions.begin())
+			indent(f_service_) << "else ";
     		 indent(f_service_) << "if (e instanceof " << type_name((*x_iter)->get_type(), false, false)<<") {" << endl;
     		 indent(f_service_) << indent() << "result." << (*x_iter)->get_name() << " = (" << type_name((*x_iter)->get_type(), false, false) << ") e;" << endl;
     	  	 indent(f_service_) << indent() << "result.set" << get_cap_name((*x_iter)->get_name()) << get_cap_name("isSet") << "(true);" << endl;
diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc
index 082f316..fc679a1 100644
--- a/compiler/cpp/src/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/generate/t_rb_generator.cc
@@ -359,21 +359,21 @@ void t_rb_generator::generate_enum(t_enum* tenum) {
   
   // Create a hash mapping values back to their names (as strings) since ruby has no native enum type
   f_types_.indent() << "VALUE_MAP = {";
-  bool first = true;
   for(c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     // Populate the hash
     int value = (*c_iter)->get_value();
-    first ? first = false : f_types_ << ", ";
+    if (c_iter != constants.begin())
+      f_types_ << ", ";
     f_types_ << value << " => \"" << capitalize((*c_iter)->get_name()) << "\"";
   }
   f_types_ << "}" << endl;
   
   // Create a set with valid values for this enum
   f_types_.indent() << "VALID_VALUES = Set.new([";
-  first = true;
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     // Populate the set
-    first ? first = false : f_types_ << ", ";
+    if (c_iter != constants.begin())
+      f_types_ << ", ";
     f_types_ << capitalize((*c_iter)->get_name());
   }
   f_types_ << "]).freeze" << endl;
diff --git a/tutorial/cpp/CppClient.cpp b/tutorial/cpp/CppClient.cpp
index ba71caa..b91df2e 100644
--- a/tutorial/cpp/CppClient.cpp
+++ b/tutorial/cpp/CppClient.cpp
@@ -38,9 +38,9 @@ using namespace shared;
 using namespace boost;
 
 int main(int argc, char** argv) {
-  shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
-  shared_ptr<TTransport> transport(new TBufferedTransport(socket));
-  shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
+  boost::shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
+  boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
+  boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
   CalculatorClient client(protocol);
 
   try {
diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp
index d0dbad9..f19258c 100644
--- a/tutorial/cpp/CppServer.cpp
+++ b/tutorial/cpp/CppServer.cpp
@@ -113,11 +113,11 @@ protected:
 
 int main(int argc, char **argv) {
 
-  shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
-  shared_ptr<CalculatorHandler> handler(new CalculatorHandler());
-  shared_ptr<TProcessor> processor(new CalculatorProcessor(handler));
-  shared_ptr<TServerTransport> serverTransport(new TServerSocket(9090));
-  shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
+  boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
+  boost::shared_ptr<CalculatorHandler> handler(new CalculatorHandler());
+  boost::shared_ptr<TProcessor> processor(new CalculatorProcessor(handler));
+  boost::shared_ptr<TServerTransport> serverTransport(new TServerSocket(9090));
+  boost::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
 
   TSimpleServer server(processor,
                        serverTransport,
@@ -128,10 +128,10 @@ int main(int argc, char **argv) {
   /**
    * Or you could do one of these
 
-  shared_ptr<ThreadManager> threadManager =
+  boost::shared_ptr<ThreadManager> threadManager =
     ThreadManager::newSimpleThreadManager(workerCount);
-  shared_ptr<PosixThreadFactory> threadFactory =
-    shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
+  boost::shared_ptr<PosixThreadFactory> threadFactory =
+    boost::shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
   threadManager->threadFactory(threadFactory);
   threadManager->start();
   TThreadPoolServer server(processor,
-- 
2.5.5