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(
2309
2309
return visitChildExpr (FalseExpr);
2310
2310
}
2311
2311
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
+
2312
2318
LabelTy LabelEnd = this ->getLabel (); // Label after the operator.
2313
2319
LabelTy LabelFalse = this ->getLabel (); // Label for the false expr.
2314
2320
2321
+ if (IsBcpCall) {
2322
+ if (!this ->emitStartSpeculation (E))
2323
+ return false ;
2324
+ }
2325
+
2315
2326
if (!this ->visitBool (Condition))
2316
2327
return false ;
2317
-
2318
2328
if (!this ->jumpFalse (LabelFalse))
2319
2329
return false ;
2320
-
2321
2330
if (!visitChildExpr (TrueExpr))
2322
2331
return false ;
2323
-
2324
2332
if (!this ->jump (LabelEnd))
2325
2333
return false ;
2326
-
2327
2334
this ->emitLabel (LabelFalse);
2328
-
2329
2335
if (!visitChildExpr (FalseExpr))
2330
2336
return false ;
2331
-
2332
2337
this ->fallthrough (LabelEnd);
2333
2338
this ->emitLabel (LabelEnd);
2334
2339
2340
+ if (IsBcpCall)
2341
+ return this ->emitEndSpeculation (E);
2335
2342
return true ;
2336
2343
}
2337
2344
Original file line number Diff line number Diff line change @@ -59,13 +59,10 @@ template<typename T> constexpr bool bcp(T t) {
59
59
}
60
60
61
61
constexpr 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;
63
63
}
64
64
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" )));
69
66
70
67
constexpr bool AndFold (const int &a, const int &b) {
71
68
return __builtin_constant_p (a && b);
You can’t perform that action at this time.
0 commit comments