@@ -404,7 +404,8 @@ $(GNAME ConditionalExpression):
404
404
the result type of the conditional expression.
405
405
)
406
406
407
- $(P $(B Note:)
407
+ $(PANEL
408
+ $(NOTE
408
409
When a conditional expression is the left operand of
409
410
an $(RELATIVE_LINK2 assign_expressions, assign expression),
410
411
parentheses are required for disambiguation:
@@ -413,8 +414,8 @@ $(GNAME ConditionalExpression):
413
414
bool test;
414
415
int a, b, c;
415
416
...
416
- test ? a = b : c = 2; // Deprecated
417
- (test ? a = b : c) = 2; // Equivalent
417
+ test ? a = b : c = 2; // error
418
+ (test ? a = b : c) = 2; // OK
418
419
---
419
420
420
421
$(P This makes the intent clearer, because the first statement can
@@ -423,6 +424,7 @@ $(GNAME ConditionalExpression):
423
424
---
424
425
test ? a = b : (c = 2);
425
426
---
427
+ )
426
428
427
429
$(H2 $(LNAME2 logical_expressions, Logical Expressions))
428
430
@@ -494,6 +496,25 @@ $(H2 $(LNAME2 bitwise_expressions, Bitwise Expressions))
494
496
)
495
497
$(DDOC_SEE_ALSO $(GLINK ShiftExpression), $(GLINK ComplementExpression))
496
498
499
+ $(PANEL
500
+ $(NOTE If an *OrExpression*, *XorExpression* or *AndExpression* appears on
501
+ either side of an *EqualExpression*, *IdentityExpression* or *RelExpression*,
502
+ it is a compile error. Instead, disambiguate by using parentheses.
503
+ )
504
+
505
+ $(SPEC_RUNNABLE_EXAMPLE_FAIL
506
+ ---
507
+ int x, a, b;
508
+ x = a & 5 == b; // error
509
+ x = a & 5 is b; // error
510
+ x = a & 5 <= b; // error
511
+
512
+ x = (a & 5) == b; // OK
513
+ x = a & (5 == b); // OK
514
+ ---
515
+ )
516
+ )
517
+
497
518
$(H3 $(LNAME2 or_expressions, Or Expressions))
498
519
499
520
$(GRAMMAR
0 commit comments