فهرست منبع

[linux-port] Resolve ternary ambiguities (#1278)

A few ternary operators took different types in the second and
third position, which some compilers refuse to resolve. By casting
the second operand to the type of the assigned variable and make
it match the third operand which was already cast.
Greg Roth 7 سال پیش
والد
کامیت
a62836b6dc
2فایلهای تغییر یافته به همراه5 افزوده شده و 5 حذف شده
  1. 1 1
      lib/Transforms/IPO/Inliner.cpp
  2. 4 4
      lib/Transforms/Scalar/LoopUnrollPass.cpp

+ 1 - 1
lib/Transforms/IPO/Inliner.cpp

@@ -83,7 +83,7 @@ Inliner::Inliner(char &ID)
 
 Inliner::Inliner(char &ID, int Threshold, bool InsertLifetime)
   : CallGraphSCCPass(ID), InlineThreshold(InlineLimit.getNumOccurrences() > 0 ?
-                                          InlineLimit : Threshold),
+                                          unsigned(InlineLimit) : Threshold),
     InsertLifetime(InsertLifetime) {}
 
 /// For this class, we declare that we require and preserve the call graph.

+ 4 - 4
lib/Transforms/Scalar/LoopUnrollPass.cpp

@@ -101,13 +101,13 @@ namespace {
   public:
     static char ID; // Pass ID, replacement for typeid
     LoopUnroll(int T = -1, int C = -1, int P = -1, int R = -1) : LoopPass(ID) {
-      CurrentThreshold = (T == -1) ? UnrollThreshold : unsigned(T);
+      CurrentThreshold = (T == -1) ? unsigned(UnrollThreshold) : unsigned(T);
       CurrentPercentDynamicCostSavedThreshold =
           UnrollPercentDynamicCostSavedThreshold;
       CurrentDynamicCostSavingsDiscount = UnrollDynamicCostSavingsDiscount;
-      CurrentCount = (C == -1) ? UnrollCount : unsigned(C);
-      CurrentAllowPartial = (P == -1) ? UnrollAllowPartial : (bool)P;
-      CurrentRuntime = (R == -1) ? UnrollRuntime : (bool)R;
+      CurrentCount = (C == -1) ? unsigned(UnrollCount) : unsigned(C);
+      CurrentAllowPartial = (P == -1) ? (bool)UnrollAllowPartial : (bool)P;
+      CurrentRuntime = (R == -1) ? (bool)UnrollRuntime : (bool)R;
 
       UserThreshold = (T != -1) || (UnrollThreshold.getNumOccurrences() > 0);
       UserPercentDynamicCostSavedThreshold =