Skip to content

Commit b310e14

Browse files
committed
Rule 7.0.6: Add user defined operator tests
1 parent 9dbc39f commit b310e14

File tree

2 files changed

+367
-0
lines changed

2 files changed

+367
-0
lines changed

cpp/misra/test/rules/RULE-7-0-6/NumericAssignmentTypeMismatch.expected

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,76 @@
4242
| test.cpp:344:8:344:14 | ... + ... | Assignment between incompatible numeric types from 'int' to 'uint8_t'. |
4343
| test.cpp:362:7:362:8 | l3 | Assignment between incompatible numeric types from 'uint16_t &' to 'uint32_t'. |
4444
| test.cpp:365:7:365:8 | l5 | Assignment between incompatible numeric types from 'uint64_t &' to 'uint32_t'. |
45+
| test.cpp:485:8:485:9 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
46+
| test.cpp:486:8:486:9 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
47+
| test.cpp:490:8:490:9 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
48+
| test.cpp:491:8:491:9 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
49+
| test.cpp:495:7:495:8 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
50+
| test.cpp:496:7:496:8 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
51+
| test.cpp:500:8:500:9 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
52+
| test.cpp:501:8:501:9 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
53+
| test.cpp:505:8:505:9 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
54+
| test.cpp:506:8:506:9 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
55+
| test.cpp:510:8:510:9 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
56+
| test.cpp:511:8:511:9 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
57+
| test.cpp:515:8:515:9 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
58+
| test.cpp:516:8:516:9 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
59+
| test.cpp:520:8:520:9 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
60+
| test.cpp:521:8:521:9 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
61+
| test.cpp:525:9:525:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
62+
| test.cpp:526:9:526:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
63+
| test.cpp:530:9:530:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
64+
| test.cpp:531:9:531:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
65+
| test.cpp:536:9:536:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
66+
| test.cpp:537:9:537:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
67+
| test.cpp:541:9:541:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
68+
| test.cpp:542:9:542:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
69+
| test.cpp:546:8:546:9 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
70+
| test.cpp:547:8:547:9 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
71+
| test.cpp:551:9:551:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
72+
| test.cpp:552:9:552:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
73+
| test.cpp:556:8:556:9 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
74+
| test.cpp:557:8:557:9 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
75+
| test.cpp:561:9:561:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
76+
| test.cpp:562:9:562:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
77+
| test.cpp:567:6:567:7 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
78+
| test.cpp:568:6:568:7 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
79+
| test.cpp:573:6:573:7 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
80+
| test.cpp:574:6:574:7 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
81+
| test.cpp:576:10:576:11 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
82+
| test.cpp:577:6:577:7 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
83+
| test.cpp:578:6:578:7 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
84+
| test.cpp:578:10:578:11 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
85+
| test.cpp:583:8:583:9 | l3 | Assignment between incompatible numeric types from 'int16_t' to 'int32_t'. |
86+
| test.cpp:584:8:584:9 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
87+
| test.cpp:585:8:585:9 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
88+
| test.cpp:589:9:589:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
89+
| test.cpp:590:9:590:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
90+
| test.cpp:594:9:594:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
91+
| test.cpp:595:9:595:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
92+
| test.cpp:599:9:599:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
93+
| test.cpp:600:9:600:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
94+
| test.cpp:604:9:604:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
95+
| test.cpp:605:9:605:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
96+
| test.cpp:609:9:609:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
97+
| test.cpp:610:9:610:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
98+
| test.cpp:614:9:614:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
99+
| test.cpp:615:9:615:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
100+
| test.cpp:619:9:619:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
101+
| test.cpp:620:9:620:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
102+
| test.cpp:624:9:624:10 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
103+
| test.cpp:625:9:625:10 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
104+
| test.cpp:629:10:629:11 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
105+
| test.cpp:630:10:630:11 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
106+
| test.cpp:634:10:634:11 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
107+
| test.cpp:635:10:635:11 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
108+
| test.cpp:640:3:640:4 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
109+
| test.cpp:641:3:641:4 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
110+
| test.cpp:645:3:645:4 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
111+
| test.cpp:646:3:646:4 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
112+
| test.cpp:650:3:650:4 | l4 | Assignment between incompatible numeric types from 'int64_t' to 'int32_t'. |
113+
| test.cpp:651:3:651:4 | l5 | Assignment between incompatible numeric types from 'uint32_t' to 'int32_t'. |
114+
| test.cpp:663:8:663:12 | 42.0 | Assignment between incompatible numeric types from 'float' to 'int32_t'. |
115+
| test.cpp:678:8:678:10 | 42 | Assignment between incompatible numeric types from 'long' to 'int32_t'. |
116+
| test.cpp:679:8:679:11 | 42 | Assignment between incompatible numeric types from 'long long' to 'int32_t'. |
117+
| test.cpp:680:8:680:10 | 42 | Assignment between incompatible numeric types from 'unsigned int' to 'int32_t'. |

cpp/misra/test/rules/RULE-7-0-6/test.cpp

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,4 +384,298 @@ void test_compound_assignments() {
384384
l2 >>= 1; // COMPLIANT - compound assignment, rule does not apply
385385
l4 += l1; // COMPLIANT - compound assignment, rule does not apply
386386
l4 -= s32; // COMPLIANT - compound assignment, rule does not apply
387+
}
388+
389+
// Test user-defined operators - always non-extensible
390+
struct UserDefinedOperators {
391+
UserDefinedOperators(std::int32_t l1) {}
392+
393+
// Binary operators
394+
UserDefinedOperators operator+(std::int32_t l1) const {
395+
return UserDefinedOperators{0};
396+
}
397+
UserDefinedOperators operator-(std::int32_t l1) const {
398+
return UserDefinedOperators{0};
399+
}
400+
UserDefinedOperators operator*(std::int32_t l1) const {
401+
return UserDefinedOperators{0};
402+
}
403+
UserDefinedOperators operator/(std::int32_t l1) const {
404+
return UserDefinedOperators{0};
405+
}
406+
UserDefinedOperators operator%(std::int32_t l1) const {
407+
return UserDefinedOperators{0};
408+
}
409+
UserDefinedOperators operator&(std::int32_t l1) const {
410+
return UserDefinedOperators{0};
411+
}
412+
UserDefinedOperators operator|(std::int32_t l1) const {
413+
return UserDefinedOperators{0};
414+
}
415+
UserDefinedOperators operator^(std::int32_t l1) const {
416+
return UserDefinedOperators{0};
417+
}
418+
UserDefinedOperators operator<<(std::int32_t l1) const {
419+
return UserDefinedOperators{0};
420+
}
421+
UserDefinedOperators operator>>(std::int32_t l1) const {
422+
return UserDefinedOperators{0};
423+
}
424+
425+
// Comparison operators
426+
bool operator==(std::int32_t l1) const { return true; }
427+
bool operator!=(std::int32_t l1) const { return false; }
428+
bool operator<(std::int32_t l1) const { return false; }
429+
bool operator<=(std::int32_t l1) const { return false; }
430+
bool operator>(std::int32_t l1) const { return false; }
431+
bool operator>=(std::int32_t l1) const { return false; }
432+
433+
// Subscript operator
434+
std::int32_t operator[](std::int32_t l1) const { return 0; }
435+
436+
// Function call operator
437+
std::int32_t operator()(std::int32_t l1) const { return 0; }
438+
std::int32_t operator()(std::int32_t l1, std::int32_t l2) const { return 0; }
439+
440+
// Assignment operators
441+
UserDefinedOperators &operator=(std::int32_t l1) { return *this; }
442+
UserDefinedOperators &operator+=(std::int32_t l1) { return *this; }
443+
UserDefinedOperators &operator-=(std::int32_t l1) { return *this; }
444+
UserDefinedOperators &operator*=(std::int32_t l1) { return *this; }
445+
UserDefinedOperators &operator/=(std::int32_t l1) { return *this; }
446+
UserDefinedOperators &operator%=(std::int32_t l1) { return *this; }
447+
UserDefinedOperators &operator&=(std::int32_t l1) { return *this; }
448+
UserDefinedOperators &operator|=(std::int32_t l1) { return *this; }
449+
UserDefinedOperators &operator^=(std::int32_t l1) { return *this; }
450+
UserDefinedOperators &operator<<=(std::int32_t l1) { return *this; }
451+
UserDefinedOperators &operator>>=(std::int32_t l1) { return *this; }
452+
453+
// Increment/decrement operators
454+
UserDefinedOperators &operator++() { return *this; }
455+
UserDefinedOperators operator++(int) { return UserDefinedOperators{0}; }
456+
UserDefinedOperators &operator--() { return *this; }
457+
UserDefinedOperators operator--(int) { return UserDefinedOperators{0}; }
458+
};
459+
460+
// Global user-defined operators
461+
UserDefinedOperators operator+(std::int32_t l1,
462+
const UserDefinedOperators &l2) {
463+
return UserDefinedOperators{0};
464+
}
465+
466+
UserDefinedOperators operator-(std::int32_t l1,
467+
const UserDefinedOperators &l2) {
468+
return UserDefinedOperators{0};
469+
}
470+
471+
bool operator==(std::int32_t l1, const UserDefinedOperators &l2) {
472+
return true;
473+
}
474+
475+
void test_user_defined_operators() {
476+
UserDefinedOperators l1{42};
477+
std::int32_t l2 = 10;
478+
std::int16_t l3 = 5;
479+
std::int64_t l4 = 100;
480+
std::uint32_t l5 = 20;
481+
482+
// Member operators - non-extensible, exact type match required
483+
l1 + l2; // COMPLIANT - exact type match
484+
l1 + l3; // COMPLIANT - widening conversion is allowed
485+
l1 + l4; // NON_COMPLIANT - different type
486+
l1 + l5; // NON_COMPLIANT - different signedness
487+
488+
l1 - l2; // COMPLIANT - exact type match
489+
l1 - l3; // COMPLIANT - widening conversion is allowed
490+
l1 - l4; // NON_COMPLIANT - different type
491+
l1 - l5; // NON_COMPLIANT - different signedness
492+
493+
l1 *l2; // COMPLIANT - exact type match
494+
l1 *l3; // COMPLIANT - widening conversion is allowed
495+
l1 *l4; // NON_COMPLIANT - different type
496+
l1 *l5; // NON_COMPLIANT - different signedness
497+
498+
l1 / l2; // COMPLIANT - exact type match
499+
l1 / l3; // COMPLIANT - widening conversion is allowed
500+
l1 / l4; // NON_COMPLIANT - different type
501+
l1 / l5; // NON_COMPLIANT - different signedness
502+
503+
l1 % l2; // COMPLIANT - exact type match
504+
l1 % l3; // COMPLIANT - widening conversion is allowed
505+
l1 % l4; // NON_COMPLIANT - different type
506+
l1 % l5; // NON_COMPLIANT - different signedness
507+
508+
l1 & l2; // COMPLIANT - exact type match
509+
l1 & l3; // COMPLIANT - widening conversion is allowed
510+
l1 & l4; // NON_COMPLIANT - different type
511+
l1 & l5; // NON_COMPLIANT - different signedness
512+
513+
l1 | l2; // COMPLIANT - exact type match
514+
l1 | l3; // COMPLIANT - widening conversion is allowed
515+
l1 | l4; // NON_COMPLIANT - different type
516+
l1 | l5; // NON_COMPLIANT - different signedness
517+
518+
l1 ^ l2; // COMPLIANT - exact type match
519+
l1 ^ l3; // COMPLIANT - widening conversion is allowed
520+
l1 ^ l4; // NON_COMPLIANT - different type
521+
l1 ^ l5; // NON_COMPLIANT - different signedness
522+
523+
l1 << l2; // COMPLIANT - exact type match
524+
l1 << l3; // COMPLIANT - widening conversion is allowed
525+
l1 << l4; // NON_COMPLIANT - different type
526+
l1 << l5; // NON_COMPLIANT - different signedness
527+
528+
l1 >> l2; // COMPLIANT - exact type match
529+
l1 >> l3; // COMPLIANT - widening conversion is allowed
530+
l1 >> l4; // NON_COMPLIANT - different type
531+
l1 >> l5; // NON_COMPLIANT - different signedness
532+
533+
// Comparison operators
534+
l1 == l2; // COMPLIANT - exact type match
535+
l1 == l3; // COMPLIANT - widening conversion is allowed
536+
l1 == l4; // NON_COMPLIANT - different type
537+
l1 == l5; // NON_COMPLIANT - different signedness
538+
539+
l1 != l2; // COMPLIANT - exact type match
540+
l1 != l3; // COMPLIANT - widening conversion is allowed
541+
l1 != l4; // NON_COMPLIANT - different type
542+
l1 != l5; // NON_COMPLIANT - different signedness
543+
544+
l1 < l2; // COMPLIANT - exact type match
545+
l1 < l3; // COMPLIANT - widening conversion is allowed
546+
l1 < l4; // NON_COMPLIANT - different type
547+
l1 < l5; // NON_COMPLIANT - different signedness
548+
549+
l1 <= l2; // COMPLIANT - exact type match
550+
l1 <= l3; // COMPLIANT - widening conversion is allowed
551+
l1 <= l4; // NON_COMPLIANT - different type
552+
l1 <= l5; // NON_COMPLIANT
553+
554+
l1 > l2; // COMPLIANT - exact type match
555+
l1 > l3; // COMPLIANT - widening conversion is allowed
556+
l1 > l4; // NON_COMPLIANT
557+
l1 > l5; // NON_COMPLIANT - different signedness
558+
559+
l1 >= l2; // COMPLIANT - exact type match
560+
l1 >= l3; // COMPLIANT - widening conversion is allowed
561+
l1 >= l4; // NON_COMPLIANT
562+
l1 >= l5; // NON_COMPLIANT - different signedness
563+
564+
// Subscript operator
565+
l1[l2]; // COMPLIANT - exact type match
566+
l1[l3]; // COMPLIANT - widening conversion is allowed
567+
l1[l4]; // NON_COMPLIANT - different type
568+
l1[l5]; // NON_COMPLIANT - different signedness
569+
570+
// Function call operator
571+
l1(l2); // COMPLIANT - exact type match
572+
l1(l3); // COMPLIANT - widening conversion is allowed
573+
l1(l4); // NON_COMPLIANT - different type
574+
l1(l5); // NON_COMPLIANT - different signedness
575+
l1(l2, l2); // COMPLIANT - both exact type match
576+
l1(l2, l4); // NON_COMPLIANT - second parameter different type
577+
l1(l4, l2); // NON_COMPLIANT - first parameter different type
578+
l1(l4, l5); // NON_COMPLIANT - both parameters different type
579+
580+
// The presence of a default copy constructor for UserDefinedOperators means
581+
// that assignments through operator= must be exact type matches.
582+
l1 = l2; // COMPLIANT - exact type match
583+
l1 = l3; // NON_COMPLIANT
584+
l1 = l4; // NON_COMPLIANT
585+
l1 = l5; // NON_COMPLIANT
586+
587+
l1 += l2; // COMPLIANT - exact type match
588+
l1 += l3; // COMPLIANT - widening conversion is allowed
589+
l1 += l4; // NON_COMPLIANT - different type
590+
l1 += l5; // NON_COMPLIANT - different signedness
591+
592+
l1 -= l2; // COMPLIANT - exact type match
593+
l1 -= l3; // COMPLIANT - widening conversion is allowed
594+
l1 -= l4; // NON_COMPLIANT - different type
595+
l1 -= l5; // NON_COMPLIANT - different signedness
596+
597+
l1 *= l2; // COMPLIANT - exact type match
598+
l1 *= l3; // COMPLIANT - widening conversion is allowed
599+
l1 *= l4; // NON_COMPLIANT - different type
600+
l1 *= l5; // NON_COMPLIANT - different signedness
601+
602+
l1 /= l2; // COMPLIANT - exact type match
603+
l1 /= l3; // COMPLIANT - widening conversion is allowed
604+
l1 /= l4; // NON_COMPLIANT - different type
605+
l1 /= l5; // NON_COMPLIANT - different signedness
606+
607+
l1 %= l2; // COMPLIANT - exact type match
608+
l1 %= l3; // COMPLIANT - widening conversion is allowed
609+
l1 %= l4; // NON_COMPLIANT - different type
610+
l1 %= l5; // NON_COMPLIANT - different signedness
611+
612+
l1 &= l2; // COMPLIANT - exact type match
613+
l1 &= l3; // COMPLIANT - widening conversion is allowed
614+
l1 &= l4; // NON_COMPLIANT - different type
615+
l1 &= l5; // NON_COMPLIANT - different signedness
616+
617+
l1 |= l2; // COMPLIANT - exact type match
618+
l1 |= l3; // COMPLIANT - widening conversion is allowed
619+
l1 |= l4; // NON_COMPLIANT - different type
620+
l1 |= l5; // NON_COMPLIANT - different signedness
621+
622+
l1 ^= l2; // COMPLIANT - exact type match
623+
l1 ^= l3; // COMPLIANT - widening conversion is allowed
624+
l1 ^= l4; // NON_COMPLIANT - different type
625+
l1 ^= l5; // NON_COMPLIANT - different signedness
626+
627+
l1 <<= l2; // COMPLIANT - exact type match
628+
l1 <<= l3; // COMPLIANT - widening conversion is allowed
629+
l1 <<= l4; // NON_COMPLIANT - different type
630+
l1 <<= l5; // NON_COMPLIANT - different signedness
631+
632+
l1 >>= l2; // COMPLIANT - exact type match
633+
l1 >>= l3; // COMPLIANT - widening conversion is allowed
634+
l1 >>= l4; // NON_COMPLIANT - different type
635+
l1 >>= l5; // NON_COMPLIANT - different signedness
636+
637+
// Global operators
638+
l2 + l1; // COMPLIANT - exact type match
639+
l3 + l1; // COMPLIANT - widening conversion is allowed
640+
l4 + l1; // NON_COMPLIANT - different type
641+
l5 + l1; // NON_COMPLIANT - different signedness
642+
643+
l2 - l1; // COMPLIANT - exact type match
644+
l3 - l1; // COMPLIANT - widening conversion is allowed
645+
l4 - l1; // NON_COMPLIANT - different type
646+
l5 - l1; // NON_COMPLIANT - different signedness
647+
648+
l2 == l1; // COMPLIANT - exact type match
649+
l3 == l1; // COMPLIANT - widening conversion is allowed
650+
l4 == l1; // NON_COMPLIANT - different type
651+
l5 == l1; // NON_COMPLIANT - different signedness
652+
}
653+
654+
// Test user-defined operators with constants
655+
void test_user_defined_operators_constants() {
656+
UserDefinedOperators l1{42};
657+
658+
// Constants with exact type match
659+
l1 + 42; // COMPLIANT
660+
l1 + 42L; // COMPLIANT
661+
l1 + 42LL; // COMPLIANT
662+
l1 + 42U; // COMPLIANT
663+
l1 + 42.0f; // NON_COMPLIANT - float constant
664+
665+
l1 == 42; // COMPLIANT - integer constant is int/int32_t
666+
l1 == 42L; // COMPLIANT - long constant
667+
l1 == 42LL; // COMPLIANT - long long constant
668+
l1 == 42U; // COMPLIANT - unsigned constant
669+
670+
l1[42]; // COMPLIANT - integer constant is int/int32_t
671+
l1[42L]; // COMPLIANT - long constant
672+
l1[42LL]; // COMPLIANT - long long constant
673+
l1[42U]; // COMPLIANT - unsigned constant
674+
675+
// The presence of a default copy constructor for UserDefinedOperators means
676+
// that assignments through operator= must be exact type matches.
677+
l1 = 42; // COMPLIANT - integer constant is int/int32_t
678+
l1 = 42L; // NON_COMPLIANT
679+
l1 = 42LL; // NON_COMPLIANT
680+
l1 = 42U; // NON_COMPLIANT
387681
}

0 commit comments

Comments
 (0)