File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -6551,6 +6551,40 @@ sub process {
6551
6551
}
6552
6552
}
6553
6553
6554
+ # check for macro names defining constants - should be capitalized
6555
+ if ($line =~ / ^\+\s *#\s *define\s +([a-z][a-zA-Z0-9_]*)\s +/ ) {
6556
+ my $macro_name = $1 ;
6557
+ # Skip function-like macros (those with parentheses)
6558
+ if ($line !~ / ^\+\s *#\s *define\s +$macro_name \s *\( / ) {
6559
+ # Skip common exceptions
6560
+ if ($macro_name !~ / ^(?:asm|__asm__|volatile|__volatile__|inline|__inline__|restrict|__restrict__|typeof|__typeof__)$ / ) {
6561
+ WARN(" MACRO_CASE" ,
6562
+ " Macro name '$macro_name ' should be capitalized (names of macros defining constants should be capitalized)\n " . $herecurr );
6563
+ }
6564
+ }
6565
+ }
6566
+
6567
+ # check for enum labels - should be capitalized
6568
+ if ($line =~ / ^\+\s *([a-z][a-zA-Z0-9_]*)\s *[,=}]/ ) {
6569
+ my $enum_name = $1 ;
6570
+ my $in_enum = 0;
6571
+ # Look back to see if we're inside an enum
6572
+ for (my $ln = $linenr - 1; $ln >= $linenr - 20 && $ln >= 0; $ln --) {
6573
+ my $prevrawline = $rawlines [$ln ];
6574
+ if ($prevrawline =~ / enum\s +\w *\s *\{ / ) {
6575
+ $in_enum = 1;
6576
+ last ;
6577
+ }
6578
+ if ($prevrawline =~ / \} [^;]*;/ ) {
6579
+ last ;
6580
+ }
6581
+ }
6582
+ if ($in_enum ) {
6583
+ WARN(" ENUM_CASE" ,
6584
+ " Enum label '$enum_name ' should be capitalized (names of labels in enums should be capitalized)\n " . $herecurr );
6585
+ }
6586
+ }
6587
+
6554
6588
# check for feature test macros that request C library API extensions, violating rules A.4 and A.5
6555
6589
6556
6590
if ($line =~ / #\s *define\s +$api_defines / ) {
You can’t perform that action at this time.
0 commit comments