提交 c8cb2ca3 编写于 作者: A Andy Whitcroft 提交者: Linus Torvalds

checkpatch: types: some types may also be identifiers

Some types such as typedefs may overlap real identifiers.  Be more
targetted about when a type can really exist.  Where it cannot let it be
an identifier.  This prevents false reporting of the minus '-' in unary
context in the following:

	foo[bar->bool - 1];
Signed-off-by: NAndy Whitcroft <apw@shadowen.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 fee61c47
...@@ -171,6 +171,7 @@ our @modifierList = ( ...@@ -171,6 +171,7 @@ our @modifierList = (
sub build_types { sub build_types {
my $mods = "(?: \n" . join("|\n ", @modifierList) . "\n)"; my $mods = "(?: \n" . join("|\n ", @modifierList) . "\n)";
my $all = "(?: \n" . join("|\n ", @typeList) . "\n)"; my $all = "(?: \n" . join("|\n ", @typeList) . "\n)";
$Modifier = qr{(?:$Attribute|$Sparse|$mods)};
$NonptrType = qr{ $NonptrType = qr{
(?:const\s+)? (?:const\s+)?
(?:$mods\s+)? (?:$mods\s+)?
...@@ -178,15 +179,14 @@ sub build_types { ...@@ -178,15 +179,14 @@ sub build_types {
(?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)| (?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)|
(?:${all}\b) (?:${all}\b)
) )
(?:\s+$Sparse|\s+const)* (?:\s+$Modifier|\s+const)*
}x; }x;
$Type = qr{ $Type = qr{
$NonptrType $NonptrType
(?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)? (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)?
(?:\s+$Inline|\s+$Sparse|\s+$Attribute|\s+$mods)* (?:\s+$Inline|\s+$Modifier)*
}x; }x;
$Declare = qr{(?:$Storage\s+)?$Type}; $Declare = qr{(?:$Storage\s+)?$Type};
$Modifier = qr{(?:$Attribute|$Sparse|$mods)};
} }
build_types(); build_types();
...@@ -715,7 +715,7 @@ sub annotate_values { ...@@ -715,7 +715,7 @@ sub annotate_values {
$av_preprocessor = 0; $av_preprocessor = 0;
} }
} elsif ($cur =~ /^($Type)/) { } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\))/) {
print "DECLARE($1)\n" if ($dbg_values > 1); print "DECLARE($1)\n" if ($dbg_values > 1);
$type = 'T'; $type = 'T';
...@@ -800,8 +800,9 @@ sub annotate_values { ...@@ -800,8 +800,9 @@ sub annotate_values {
print "PAREN('$1')\n" if ($dbg_values > 1); print "PAREN('$1')\n" if ($dbg_values > 1);
} }
} elsif ($cur =~ /^($Ident)\(/o) { } elsif ($cur =~ /^($Ident)\s*\(/o) {
print "FUNC($1)\n" if ($dbg_values > 1); print "FUNC($1)\n" if ($dbg_values > 1);
$type = 'V';
$av_pending = 'V'; $av_pending = 'V';
} elsif ($cur =~ /^($Ident|$Constant)/o) { } elsif ($cur =~ /^($Ident|$Constant)/o) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册