File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -2309,29 +2309,36 @@ bool Compiler<Emitter>::VisitAbstractConditionalOperator(
23092309 return visitChildExpr (FalseExpr);
23102310 }
23112311
2312+ bool IsBcpCall = false ;
2313+ if (const auto *CE = dyn_cast<CallExpr>(Condition->IgnoreParenCasts ());
2314+ CE && CE->getBuiltinCallee () == Builtin::BI__builtin_constant_p) {
2315+ IsBcpCall = true ;
2316+ }
2317+
23122318 LabelTy LabelEnd = this ->getLabel (); // Label after the operator.
23132319 LabelTy LabelFalse = this ->getLabel (); // Label for the false expr.
23142320
2321+ if (IsBcpCall) {
2322+ if (!this ->emitStartSpeculation (E))
2323+ return false ;
2324+ }
2325+
23152326 if (!this ->visitBool (Condition))
23162327 return false ;
2317-
23182328 if (!this ->jumpFalse (LabelFalse))
23192329 return false ;
2320-
23212330 if (!visitChildExpr (TrueExpr))
23222331 return false ;
2323-
23242332 if (!this ->jump (LabelEnd))
23252333 return false ;
2326-
23272334 this ->emitLabel (LabelFalse);
2328-
23292335 if (!visitChildExpr (FalseExpr))
23302336 return false ;
2331-
23322337 this ->fallthrough (LabelEnd);
23332338 this ->emitLabel (LabelEnd);
23342339
2340+ if (IsBcpCall)
2341+ return this ->emitEndSpeculation (E);
23352342 return true ;
23362343}
23372344
Original file line number Diff line number Diff line change @@ -59,13 +59,10 @@ template<typename T> constexpr bool bcp(T t) {
5959}
6060
6161constexpr intptr_t ptr_to_int (const void *p) {
62- return __builtin_constant_p (1 ) ? (intptr_t )p : (intptr_t )p; // expected-note {{cast that performs the conversions of a reinterpret_cast}}
62+ return __builtin_constant_p (1 ) ? (intptr_t )p : (intptr_t )p;
6363}
6464
65- // / This is from test/SemaCXX/builtin-constant-p.cpp, but it makes no sense.
66- // / ptr_to_int is called before bcp(), so it fails. GCC does not accept this either.
67- static_assert (bcp(ptr_to_int(" foo" ))); // expected-error {{not an integral constant expression}} \
68- // expected-note {{in call to}}
65+ static_assert (bcp(ptr_to_int(" foo" )));
6966
7067constexpr bool AndFold (const int &a, const int &b) {
7168 return __builtin_constant_p (a && b);
You can’t perform that action at this time.
0 commit comments