g++ not accepting certain asm constructs

Jan Beulich JBeulich@novell.com
Tue Aug 10 16:49:00 GMT 2004


g++ (starting with 3.4.0) rejected constructs like __asm__(: ::), while
3.3.3
accepted them and comments in the sources also indicate this is
supposed to
work.

Built and tested on i686-pc-linux-gnu.

Jan

cp:
2004-08-10 Jan Beulich <jbeulich@novell.com>

	* parser.c (cp_parser_asm_definition): Properly consume scope
operator
	tokens preceding the clobbers. Don't check for scope operator
	following inputs. Simplify inputs handling to match that now
used for
	clobbers.

testsuite:
2004-08-10 Jan Beulich <jbeulich@novell.com>

	* g++.dg/ext/asm5.C: New.

---
/home/jbeulich/src/gcc/mainline/2004-08-09.09.08/gcc/cp/parser.c	2004-08-05
08:53:07.000000000 +0200
+++ 2004-08-09.09.08/gcc/cp/parser.c	2004-08-10 12:35:51.000000000
+0200
@@ -10362,26 +10362,19 @@ cp_parser_asm_definition (cp_parser* par
       /* If the next token is `::', there are no outputs, and the
 	 next token is the beginning of the inputs.  */
       else if (cp_lexer_next_token_is (parser->lexer, CPP_SCOPE))
-	{
-	  /* Consume the `::' token.  */
-	  cp_lexer_consume_token (parser->lexer);
-	  /* The inputs are coming next.  */
-	  inputs_p = true;
-	}
+	/* The inputs are coming next.  */
+	inputs_p = true;
 
       /* Look for inputs.  */
       if (inputs_p
 	  || cp_lexer_next_token_is (parser->lexer, CPP_COLON))
 	{
-	  if (!inputs_p)
-	    /* Consume the `:'.  */
-	    cp_lexer_consume_token (parser->lexer);
+	  /* Consume the `:' or `::'.  */
+	  cp_lexer_consume_token (parser->lexer);
 	  /* Parse the output-operands.  */
 	  if (cp_lexer_next_token_is_not (parser->lexer,
 					  CPP_COLON)
 	      && cp_lexer_next_token_is_not (parser->lexer,
-					     CPP_SCOPE)
-	      && cp_lexer_next_token_is_not (parser->lexer,
 					     CPP_CLOSE_PAREN))
 	    inputs = cp_parser_asm_operand_list (parser);
 	}
@@ -10393,9 +10386,8 @@ cp_parser_asm_definition (cp_parser* par
       if (clobbers_p
 	  || cp_lexer_next_token_is (parser->lexer, CPP_COLON))
 	{
-	  if (!clobbers_p)
-	    /* Consume the `:'.  */
-	    cp_lexer_consume_token (parser->lexer);
+	  /* Consume the `:' or `::'.  */
+	  cp_lexer_consume_token (parser->lexer);
 	  /* Parse the clobbers.  */
 	  if (cp_lexer_next_token_is_not (parser->lexer,
 					  CPP_CLOSE_PAREN))
---
/home/jbeulich/src/gcc/mainline/2004-08-09.09.08/gcc/testsuite/g++.dg/ext/asm5.C	1970-01-01
01:00:00.000000000 +0100
+++ 2004-08-09.09.08/gcc/testsuite/g++.dg/ext/asm5.C	2004-08-10
12:28:29.000000000 +0200
@@ -0,0 +1,35 @@
+void f (int i)
+{
+ __asm__("" : );
+ __asm__("" : "+g" (i));
+
+ __asm__("" :: );
+ __asm__("" :: "g" (i));
+
+ __asm__("" : : );
+ __asm__("" : "+g" (i) : );
+ __asm__("" : : "g" (i));
+ __asm__("" : "+g" (i) :  "g" (i));
+
+ __asm__("" ::: );
+ __asm__("" ::: "memory");
+
+ __asm__("" : :: );
+ __asm__("" : "+g" (i) :: );
+ __asm__("" : :: "memory");
+ __asm__("" : "+g" (i) :: "memory");
+
+ __asm__("" :: : );
+ __asm__("" :: "g" (i) : );
+ __asm__("" :: : "memory");
+ __asm__("" :: "g" (i) : "memory");
+
+ __asm__("" : : : );
+ __asm__("" : "+g" (i) : : );
+ __asm__("" : : "g" (i) : );
+ __asm__("" : : : "memory");
+ __asm__("" : "+g" (i) : "g" (i) : );
+ __asm__("" : "+g" (i) : : "memory");
+ __asm__("" : : "g" (i) : "memory");
+ __asm__("" : "+g" (i) : "g" (i) : "memory");
+}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-mainline-cp-asm.patch
Type: application/octet-stream
Size: 3219 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040810/1bd7038d/attachment.obj>


More information about the Gcc-patches mailing list