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