Don't use C++ comments in assembly

Message ID Yd+e0Vfnb8B5hqfc@squeak.grove.modra.org
State New
Headers show
Series
  • Don't use C++ comments in assembly
Related show

Commit Message

H.J. Lu via Binutils Jan. 13, 2022, 3:38 a.m.
It might seem to work, but only if '/' is a start of comment char.

	* testsuite/ld-elf/dt-relr-1.s: Use # for comment.
	* testsuite/ld-elf/dt-relr-2.s: Likewise.
	* testsuite/ld-elf/dt-relr-3.s: Likewise.


-- 
Alan Modra
Australia Development Lab, IBM

Comments

H.J. Lu via Binutils Jan. 13, 2022, 7:58 a.m. | #1
On 13.01.2022 04:38, Alan Modra via Binutils wrote:
> It might seem to work, but only if '/' is a start of comment char.

> 

> 	* testsuite/ld-elf/dt-relr-1.s: Use # for comment.

> 	* testsuite/ld-elf/dt-relr-2.s: Likewise.

> 	* testsuite/ld-elf/dt-relr-3.s: Likewise.

> 

> diff --git a/ld/testsuite/ld-elf/dt-relr-1.s b/ld/testsuite/ld-elf/dt-relr-1.s

> index 1eb34588160..ce1a876b1e8 100644

> --- a/ld/testsuite/ld-elf/dt-relr-1.s

> +++ b/ld/testsuite/ld-elf/dt-relr-1.s

> @@ -9,5 +9,5 @@ _start:

>  	.globl data

>  data:

>  	.byte 0

> -	// Offset is not a multiple of 2.  Don't use DT_RELR.

> +# Offset is not a multiple of 2.  Don't use DT_RELR.


Just for my own education, since I've been wondering how to write comments
in tests suitable for all (or at least most) targets: # isn't a universal
comment char either (having a different meaning e.g. on Arm). In
gas/testsuite/gas/all/quoted-sym-names.s I did use /**/ which looks to
have worked quite well ... Elsewhere I find ";#" in use.

Jan
H.J. Lu via Binutils Jan. 13, 2022, 8:32 a.m. | #2
On Thu, Jan 13, 2022 at 08:58:25AM +0100, Jan Beulich wrote:
> On 13.01.2022 04:38, Alan Modra via Binutils wrote:

> > It might seem to work, but only if '/' is a start of comment char.

> > 

> > 	* testsuite/ld-elf/dt-relr-1.s: Use # for comment.

> > 	* testsuite/ld-elf/dt-relr-2.s: Likewise.

> > 	* testsuite/ld-elf/dt-relr-3.s: Likewise.

> > 

> > diff --git a/ld/testsuite/ld-elf/dt-relr-1.s b/ld/testsuite/ld-elf/dt-relr-1.s

> > index 1eb34588160..ce1a876b1e8 100644

> > --- a/ld/testsuite/ld-elf/dt-relr-1.s

> > +++ b/ld/testsuite/ld-elf/dt-relr-1.s

> > @@ -9,5 +9,5 @@ _start:

> >  	.globl data

> >  data:

> >  	.byte 0

> > -	// Offset is not a multiple of 2.  Don't use DT_RELR.

> > +# Offset is not a multiple of 2.  Don't use DT_RELR.

> 

> Just for my own education, since I've been wondering how to write comments

> in tests suitable for all (or at least most) targets: # isn't a universal

> comment char either (having a different meaning e.g. on Arm). In


No, it isn't, but it almost universally begins a comment line when
at the start of the line.  grep line_comment_chars.

> gas/testsuite/gas/all/quoted-sym-names.s I did use /**/ which looks to

> have worked quite well


Yes, that style should also be universally accepted.

 ... Elsewhere I find ";#" in use.

For most targets this is a logical line break, followed by start of
line comment.  For ns32k, the one target that doesn't use '#' as a
start of line comment, ';' happens to be the start of line comment.

-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/ld/testsuite/ld-elf/dt-relr-1.s b/ld/testsuite/ld-elf/dt-relr-1.s
index 1eb34588160..ce1a876b1e8 100644
--- a/ld/testsuite/ld-elf/dt-relr-1.s
+++ b/ld/testsuite/ld-elf/dt-relr-1.s
@@ -9,5 +9,5 @@  _start:
 	.globl data
 data:
 	.byte 0
-	// Offset is not a multiple of 2.  Don't use DT_RELR.
+# Offset is not a multiple of 2.  Don't use DT_RELR.
 	.dc.a __ehdr_start + 10
diff --git a/ld/testsuite/ld-elf/dt-relr-2.s b/ld/testsuite/ld-elf/dt-relr-2.s
index bd1f3dfa16f..1fcee6c6fce 100644
--- a/ld/testsuite/ld-elf/dt-relr-2.s
+++ b/ld/testsuite/ld-elf/dt-relr-2.s
@@ -16,5 +16,5 @@  data:
 	.dc.a __ehdr_start + 9
 
 	.byte 0
-	// Offset is not a multiple of 2.  Don't use DT_RELR.
+# Offset is not a multiple of 2.  Don't use DT_RELR.
 	.dc.a __ehdr_start + 10
diff --git a/ld/testsuite/ld-elf/dt-relr-3.s b/ld/testsuite/ld-elf/dt-relr-3.s
index d020132466f..41ea08ec28c 100644
--- a/ld/testsuite/ld-elf/dt-relr-3.s
+++ b/ld/testsuite/ld-elf/dt-relr-3.s
@@ -4,7 +4,7 @@ 
 _start:
 	.byte 0
 
-	// Section alignment is not a multiple of 2.  Don't use DT_RELR.
+# Section alignment is not a multiple of 2.  Don't use DT_RELR.
 	.data
 	.p2align 0
 	.globl data