public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Question regarding C++ and inline assembler...
@ 2000-01-27 11:50 Scott Bambrough
  2000-01-27 12:43 ` Alexandre Oliva
  0 siblings, 1 reply; 4+ messages in thread
From: Scott Bambrough @ 2000-01-27 11:50 UTC (permalink / raw)
  To: gcc

The following code fragment generates a error when compiled as C++ code, but not
as C code.

int main (int argc, char **argv)
{
  __asm__ ("mov r0, #0", ::: "r0");	/* error in C++, not C */
  __asm__ ("mov r0, #0", : : : "r0");   /* fine in C and C++ */
}

Shouldn't the C++ compiler be able to cope with no whitespace between the colons
when compiling the inline assembler?

Scott

-- 
Scott Bambrough - Software Engineer
REBEL.COM    http://www.rebel.com
NetWinder    http://www.netwinder.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question regarding C++ and inline assembler...
  2000-01-27 11:50 Question regarding C++ and inline assembler Scott Bambrough
@ 2000-01-27 12:43 ` Alexandre Oliva
  2000-01-27 12:52   ` David Young
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Oliva @ 2000-01-27 12:43 UTC (permalink / raw)
  To: Scott Bambrough; +Cc: gcc

On Jan 27, 2000, Scott Bambrough <scottb@netwinder.org> wrote:

> Shouldn't the C++ compiler be able to cope with no whitespace
> between the colons when compiling the inline assembler?

Well, it could do it, but `::' is a C++ token, totally different from
`: :'.  So it would be best not to rely on g++'s special-casing of
`::' within asm statements.  Anyway, g++ accepts `>>' as `> >' when
`>' is used as a template bracket, so this might be considered
precedent.  I doubt a patch that implemented this feature would be
rejected.

-- 
Alexandre Oliva http://www.ic.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{lsd.ic.unicamp.br,guarana.{org,com}} aoliva@{acm,computer}.org
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question regarding C++ and inline assembler...
  2000-01-27 12:43 ` Alexandre Oliva
@ 2000-01-27 12:52   ` David Young
  2000-01-28  4:28     ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: David Young @ 2000-01-27 12:52 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: Scott Bambrough, gcc

> Anyway, g++ accepts `>>' as `> >' when
> `>' is used as a template bracket

That could be because >> pattern being the ANSI shift-right is defined to  
accept white space and comments within the token, so

>>
>  >
> /*obnoxious comment*/ >

are all tokenized to the same >> token

-- from my understanding

whereas :: is not part of ANSI-C, thus there does not have to be such  
ignoring of white and comments by design.

Please correct me if I'm wrong.

Thanks A Bunch! David Young; VVI-DCS
dyoung@vvi.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question regarding C++ and inline assembler...
  2000-01-27 12:52   ` David Young
@ 2000-01-28  4:28     ` Andreas Schwab
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2000-01-28  4:28 UTC (permalink / raw)
  To: David.Young; +Cc: Alexandre Oliva, Scott Bambrough, gcc

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 704 bytes --]

David Young <dyoung@vviuh221.vvi.com> writes:

|> > Anyway, g++ accepts `>>' as `> >' when
|> > `>' is used as a template bracket
|> 
|> That could be because >> pattern being the ANSI shift-right is defined to  
|> accept white space and comments within the token, so
|> 
|> >>
|> >  >
|> > /*obnoxious comment*/ >
|> 
|> are all tokenized to the same >> token

This is wrong.  There must not be any whitespace inside tokens (except
string and character literals, of course).

Andreas.

-- 
Andreas Schwab                                  "And now for something
SuSE Labs                                        completely different."
schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-01-28  4:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-27 11:50 Question regarding C++ and inline assembler Scott Bambrough
2000-01-27 12:43 ` Alexandre Oliva
2000-01-27 12:52   ` David Young
2000-01-28  4:28     ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).