This allows the customary syntax for declaring named arguments,
such as:
asm ("mov %[out],%[in]" : [out] "=r" (x) : [in] "r" (y));
Since :[ is comple-error-inducingly invalid syntax in other cases,
this won't create unintentional leniency for normal uses of [
Signed-off-by: Dave Martin <[email protected]>
---
scripts/checkpatch.pl | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e3c7fc0..2c2fa51 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1988,11 +1988,13 @@ sub process {
# 1. with a type on the left -- int [] a;
# 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
# 3. inside a curly brace -- = { [0...10] = 5 }
+# 4. after a colon for inline asm -- asm ("..." : [name] "constraint" (arg))
while ($line =~ /(.*?\s)\[/g) {
my ($where, $prefix) = ($-[1], $1);
if ($prefix !~ /$Type\s+$/ &&
($where != 0 || $prefix !~ /^.\s+$/) &&
- $prefix !~ /{\s+$/) {
+ $prefix !~ /{\s+$/ &&
+ $prefix !~ /:\s+$/) {
ERROR("space prohibited before open square bracket '['\n" . $herecurr);
}
}
--
1.7.1
On Tue, 2010-11-16 at 12:13 +0000, Dave Martin wrote:
> This allows the customary syntax for declaring named arguments,
> such as:
>
> asm ("mov %[out],%[in]" : [out] "=r" (x) : [in] "r" (y));
Andy:
Maybe it'd be better to have a checkpatch pass that does
something similar to the c comment removal for asm blocks.
Maybe keyed on "\basm(\s+volatile){0,1}\s*" and strip
everything in the () block that follows it.
On Tue, Nov 16, 2010 at 07:00:12AM -0800, Joe Perches wrote:
> On Tue, 2010-11-16 at 12:13 +0000, Dave Martin wrote:
> > This allows the customary syntax for declaring named arguments,
> > such as:
> >
> > asm ("mov %[out],%[in]" : [out] "=r" (x) : [in] "r" (y));
>
> Andy:
>
> Maybe it'd be better to have a checkpatch pass that does
> something similar to the c comment removal for asm blocks.
>
> Maybe keyed on "\basm(\s+volatile){0,1}\s*" and strip
> everything in the () block that follows it.
Yeah am starting to think that whatever is in there is a different
world.
-apw