Bug 12390 - binutils as accepts single '/' as if it were a comment
Summary: binutils as accepts single '/' as if it were a comment
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: unspecified
: P2 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-11 22:40 UTC by Nick Lewycky
Modified: 2011-01-18 13:37 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Update documentation describing special characters (11.67 KB, patch)
2011-01-18 10:58 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Lewycky 2011-01-11 22:40:14 UTC
I found some code in the wild (NSPR from Mozilla) which is using / as a comment block, ala.:

  / -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  / 
  / ***** BEGIN LICENSE BLOCK *****
  / Version: MPL 1.1/GPL 2.0/LGPL 2.1
  /

which isn't a documented way of writing a comment. Now, the documentation does say "On some machines there are two different line comment characters. One character only begins a comment if it is the first non-whitespace character on a line, while the other always begins a comment." but never specifies whether / is such a character.

I'm going to propose that gas document the support of '//' style comments (along-side /* and */) and change code to reject bare '/'. On the other side, I'm going to ask the Mozilla folks to change their code from '/' to '//' for these comments.

Quick reference, the documentation I refer to is http://sourceware.org/binutils/docs-2.21/as/Comments.html#Comments
Comment 1 Mikael Pettersson 2011-01-13 23:46:34 UTC
I have some old code which uses these single-/ comments.  As far as I can tell, Solaris/x86 has used this convention since at least 1995, and gas for Linux/x86 has accepted it since at least 1997.  Removing support for it now is not an option, IMO.
Comment 2 Hans-Peter Nilsson 2011-01-14 00:03:24 UTC
Is the reporter confused by the placement of 
<http://sourceware.org/binutils/docs-2.21/as/i386_002dOptions.html#i386_002dOptions>?  Perhaps that /-documentation should go in a Syntax / Special characters subsection similar to other ports?
Comment 3 Nick Lewycky 2011-01-14 00:08:13 UTC
I hadn't seen that paragraph. That describes a comment format not mentioned in the comments section here: http://sourceware.org/binutils/docs-2.21/as/Comments.html#Comments
Comment 4 Hans-Peter Nilsson 2011-01-14 00:19:51 UTC
(In reply to comment #3)
> I hadn't seen that paragraph. That describes a comment format not mentioned in
> the comments section here:
> http://sourceware.org/binutils/docs-2.21/as/Comments.html#Comments

Stray and stale documentation there, which can easily be read as being complete.  I'll rephrase myself: it is a mistake to mention port-specific features there at all.  It should IMHO just be in each port-specific section (for the port at hand, 80386 Dependent Features), in a subsection called Syntax::Special characters.
Comment 5 Nick Clifton 2011-01-18 10:58:09 UTC
Created attachment 5199 [details]
Update documentation describing special characters
Comment 6 Nick Clifton 2011-01-18 13:37:08 UTC
Hi Guys,

  I agree with Hans-Peter.  The current line comment behaviour should not be changed, but it should be documented on a per-target basis, rather than in the generic documentation.  Hence I am going to check in the uploaded patch.  Since the same reasoning applies to the line separator character as well, the patch also updates the documentation with regard to this feature.

Cheers
  Nick

gas/ChangeLog
2011-01-18  Nick Clifton  <nickc@redhat.com>

	PR gas/12390
	* doc/all.texi: Add NS32K
	* doc/as.texinfo: Remove target specific details of which
	characters act as comment initiators and statement separators into
	individual target specific files.
	* doc/c-alpha.texi (Alpha-Chars): Document special behaviour of
	the hash character at the start of a line.
	* doc/c-arm.texi (ARM-Chars): Likewise.
	* doc/c-avr.texi (AVR-Chars): Likewise.
	* doc/c-d10v.texi (D10V-Chars): Likewise.
	* doc/c-d30v.texi (D30V-Chars):	Likewise.
	* doc/c-mmix.texi (MMIX-Chars): Likewise.
	* doc/c-s390.texi (s390 characters): Likewise.
	* doc/c-sh.texi (SH-Chars): Likewise.
	* doc/c-sh64.texi (SH64-Chars): Likewise.
	* doc/c-sparc.texi (SPARC-Chars): Likewise.
	* doc/c-tic6x.texi (TIC6X Syntax): Likewise.
	* doc/c-xtensa.texi (Xtensa Syntax): Likewise.
	* doc/c-z80.texi (Z80-Chars): Likewise.
	* doc/c-z8k.texi (Z8000-Chars): Likewise.
	* doc/c-pdp11.texi (PDP11-Syntax): Document line separator character.
	* doc/c-arc.texi (ARC-Chars): Fill in this subsection.
	* doc/c-bfin.texi (Blackfin Syntax): Document line comment and
	line separator characters.
	* doc/c-cr16.texi (CR16 Syntax): Likewise.
	* doc/c-i386.texi (i386-Chars): Likewise.
	* doc/c-i860.texi (i860-Chars):	Likewise.
	* doc/c-i960.texi (i960-Chars):	Likewise.
	* doc/c-ip2k.texi (IP2K-Chars):	Likewise.
	* doc/c-lm32.texi (LM32-Chars):	likewise.
	* doc/c-m32c.texi (M32C-Chars): Likewise.
	* doc/c-m68hc11.texi (M68HC11-syntax): Likewise.
	* doc/c-m68k.texi (M68K-Chars): Likewise.
	* doc/c-microblaze.texi (MicroBlaze-Chars): Likewise.
	* doc/c-msp430.texi (MSP430-Chars): Likewise.
	* doc/c-mt.texi (MT-Chars): Likewise.
	* doc/c-ns32k.texi (NS32K-Chars): Likewise.
	* doc/c-pj.texi (PJ-Chars): Likewise.
	* doc/c-ppc.texi (PowerPC-Chars): Likewise.
	* doc/c-rx.texi (RX-Chars): Likewise.
	* doc/c-score.texi (SCORE-Chars): Likewise.
	* doc/c-tic54x.texi (TIC54X-Chars): Likewise.
	* doc/c-v850.texi (V850-Chars): Likewise.
	* doc/c-vax.texi (VAX-Chars): Likewise.
	* doc/c-xc16x.texi (xc16x-Chars): Likewise.
Comment 7 Sourceware Commits 2011-01-18 13:37:43 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2011-01-18 13:37:40

Modified files:
	gas            : ChangeLog 
	gas/doc        : all.texi as.texinfo c-alpha.texi c-arc.texi 
	                 c-arm.texi c-avr.texi c-bfin.texi c-cr16.texi 
	                 c-d10v.texi c-d30v.texi c-h8300.texi 
	                 c-hppa.texi c-i386.texi c-i860.texi c-i960.texi 
	                 c-ip2k.texi c-lm32.texi c-m32c.texi 
	                 c-m68hc11.texi c-m68k.texi c-microblaze.texi 
	                 c-mips.texi c-mmix.texi c-msp430.texi c-mt.texi 
	                 c-ns32k.texi c-pdp11.texi c-pj.texi c-ppc.texi 
	                 c-rx.texi c-s390.texi c-score.texi c-sh.texi 
	                 c-sh64.texi c-sparc.texi c-tic54x.texi 
	                 c-tic6x.texi c-v850.texi c-vax.texi 
	                 c-xc16x.texi c-xtensa.texi c-z80.texi 
	                 c-z8k.texi 

Log message:
	PR gas/12390
	* doc/all.texi: Add NS32K
	* doc/as.texinfo: Remove target specific details of which
	characters act as comment initiators and statement separators into
	individual target specific files.
	* doc/c-alpha.texi (Alpha-Chars): Document special behaviour of
	the hash character at the start of a line.
	* doc/c-arm.texi (ARM-Chars): Likewise.
	* doc/c-avr.texi (AVR-Chars): Likewise.
	* doc/c-d10v.texi (D10V-Chars): Likewise.
	* doc/c-d30v.texi (D30V-Chars):	Likewise.
	* doc/c-mmix.texi (MMIX-Chars): Likewise.
	* doc/c-s390.texi (s390 characters): Likewise.
	* doc/c-sh.texi (SH-Chars): Likewise.
	* doc/c-sh64.texi (SH64-Chars): Likewise.
	* doc/c-sparc.texi (SPARC-Chars): Likewise.
	* doc/c-tic6x.texi (TIC6X Syntax): Likewise.
	* doc/c-xtensa.texi (Xtensa Syntax): Likewise.
	* doc/c-z80.texi (Z80-Chars): Likewise.
	* doc/c-z8k.texi (Z8000-Chars): Likewise.
	* doc/c-pdp11.texi (PDP11-Syntax): Document line separator character.
	* doc/c-arc.texi (ARC-Chars): Fill in this subsection.
	* doc/c-bfin.texi (Blackfin Syntax): Document line comment and
	line separator characters.
	* doc/c-cr16.texi (CR16 Syntax): Likewise.
	* doc/c-i386.texi (i386-Chars): Likewise.
	* doc/c-i860.texi (i860-Chars):	Likewise.
	* doc/c-i960.texi (i960-Chars):	Likewise.
	* doc/c-ip2k.texi (IP2K-Chars):	Likewise.
	* doc/c-lm32.texi (LM32-Chars):	likewise.
	* doc/c-m32c.texi (M32C-Chars): Likewise.
	* doc/c-m68hc11.texi (M68HC11-syntax): Likewise.
	* doc/c-m68k.texi (M68K-Chars): Likewise.
	* doc/c-microblaze.texi (MicroBlaze-Chars): Likewise.
	* doc/c-msp430.texi (MSP430-Chars): Likewise.
	* doc/c-mt.texi (MT-Chars): Likewise.
	* doc/c-ns32k.texi (NS32K-Chars): Likewise.
	* doc/c-pj.texi (PJ-Chars): Likewise.
	* doc/c-ppc.texi (PowerPC-Chars): Likewise.
	* doc/c-rx.texi (RX-Chars): Likewise.
	* doc/c-score.texi (SCORE-Chars): Likewise.
	* doc/c-tic54x.texi (TIC54X-Chars): Likewise.
	* doc/c-v850.texi (V850-Chars): Likewise.
	* doc/c-vax.texi (VAX-Chars): Likewise.
	* doc/c-xc16x.texi (xc16x-Chars): Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/ChangeLog.diff?cvsroot=src&r1=1.4389&r2=1.4390
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/all.texi.diff?cvsroot=src&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/as.texinfo.diff?cvsroot=src&r1=1.230&r2=1.231
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-alpha.texi.diff?cvsroot=src&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-arc.texi.diff?cvsroot=src&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-arm.texi.diff?cvsroot=src&r1=1.82&r2=1.83
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-avr.texi.diff?cvsroot=src&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-bfin.texi.diff?cvsroot=src&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-cr16.texi.diff?cvsroot=src&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-d10v.texi.diff?cvsroot=src&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-d30v.texi.diff?cvsroot=src&r1=1.1.1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-h8300.texi.diff?cvsroot=src&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-hppa.texi.diff?cvsroot=src&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-i386.texi.diff?cvsroot=src&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-i860.texi.diff?cvsroot=src&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-i960.texi.diff?cvsroot=src&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-ip2k.texi.diff?cvsroot=src&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-lm32.texi.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-m32c.texi.diff?cvsroot=src&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-m68hc11.texi.diff?cvsroot=src&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-m68k.texi.diff?cvsroot=src&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-microblaze.texi.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-mips.texi.diff?cvsroot=src&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-mmix.texi.diff?cvsroot=src&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-msp430.texi.diff?cvsroot=src&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-mt.texi.diff?cvsroot=src&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-ns32k.texi.diff?cvsroot=src&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-pdp11.texi.diff?cvsroot=src&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-pj.texi.diff?cvsroot=src&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-ppc.texi.diff?cvsroot=src&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-rx.texi.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-s390.texi.diff?cvsroot=src&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-score.texi.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-sh.texi.diff?cvsroot=src&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-sh64.texi.diff?cvsroot=src&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-sparc.texi.diff?cvsroot=src&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-tic54x.texi.diff?cvsroot=src&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-tic6x.texi.diff?cvsroot=src&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-v850.texi.diff?cvsroot=src&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-vax.texi.diff?cvsroot=src&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-xc16x.texi.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-xtensa.texi.diff?cvsroot=src&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-z80.texi.diff?cvsroot=src&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/c-z8k.texi.diff?cvsroot=src&r1=1.4&r2=1.5