C++ parser refusing asm statatement

Mark Mitchell mark@codesourcery.com
Wed Jan 8 17:00:00 GMT 2003



--On Tuesday, January 07, 2003 10:04:39 PM +0100 Jan Hubicka <jh@suse.cz> 
wrote:

> Hi,
> now with fixed xmmintrin.h I am almost able to compile it with C++.
> However this looks like parser bug:

Fixed with this patch.  Tested on i686-pc-liux-gnu, applied on the
mainline.

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com

2003-01-07  Mark Mitchell  <mark@codesourcery.com>

	* parser.c (cp_parser_asm_definition): Correct handling of omitted
	operands.

2003-01-07  Mark Mitchell  <mark@codesourcery.com>

	* g++.dg/ext/asm4.C: New test.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.21
diff -c -5 -p -r1.21 parser.c
*** cp/parser.c	6 Jan 2003 21:32:14 -0000	1.21
--- cp/parser.c	8 Jan 2003 07:59:45 -0000
*************** cp_parser_asm_definition (parser)
*** 9590,9600 ****
  	  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))
  	    outputs = cp_parser_asm_operand_list (parser);
  	}
        /* 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))
--- 9590,9602 ----
  	  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))
  	    outputs = cp_parser_asm_operand_list (parser);
  	}
        /* 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))
*************** cp_parser_asm_definition (parser)
*** 9614,9624 ****
  	    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))
  	    inputs = cp_parser_asm_operand_list (parser);
  	}
        else if (cp_lexer_next_token_is (parser->lexer, CPP_SCOPE))
  	/* The clobbers are coming next.  */
  	clobbers_p = true;
--- 9616,9628 ----
  	    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);
  	}
        else if (cp_lexer_next_token_is (parser->lexer, CPP_SCOPE))
  	/* The clobbers are coming next.  */
  	clobbers_p = true;
*************** cp_parser_asm_definition (parser)
*** 9629,9639 ****
  	{
  	  if (!clobbers_p)
  	    /* Consume the `:'.  */
  	    cp_lexer_consume_token (parser->lexer);
  	  /* Parse the clobbers.  */
! 	  clobbers = cp_parser_asm_clobber_list (parser);
  	}
      }
    /* Look for the closing `)'.  */
    if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'"))
      cp_parser_skip_to_closing_parenthesis (parser);
--- 9633,9645 ----
  	{
  	  if (!clobbers_p)
  	    /* Consume the `:'.  */
  	    cp_lexer_consume_token (parser->lexer);
  	  /* Parse the clobbers.  */
! 	  if (cp_lexer_next_token_is_not (parser->lexer,
! 					  CPP_CLOSE_PAREN))
! 	    clobbers = cp_parser_asm_clobber_list (parser);
  	}
      }
    /* Look for the closing `)'.  */
    if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'"))
      cp_parser_skip_to_closing_parenthesis (parser);
Index: testsuite/g++.dg/ext/asm4.C
===================================================================
RCS file: testsuite/g++.dg/ext/asm4.C
diff -N testsuite/g++.dg/ext/asm4.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/ext/asm4.C	8 Jan 2003 07:59:45 -0000
***************
*** 0 ****
--- 1,4 ----
+ void f ()
+ {
+   __asm__ __volatile__ ("" : : );
+ }



More information about the Gcc-patches mailing list