re PR c/37772 (ICE with empty asm statement)

PR c/37772
	* c-parser.c (c_parser_asm_statement): Skip until close paren and
	return if c_parser_asm_string_literal returned NULL.

	* gcc.dg/pr37772.c: New test.
	* g++.dg/ext/asm11.C: New test.

From-SVN: r145401
This commit is contained in:
Jakub Jelinek 2009-04-01 15:32:22 +02:00
parent 00c7e24fdd
commit b85eb797e2
5 changed files with 61 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2009-04-01 Jakub Jelinek <jakub@redhat.com>
PR c/37772
* c-parser.c (c_parser_asm_statement): Skip until close paren and
return if c_parser_asm_string_literal returned NULL.
2009-04-01 Nick Clifton <nickc@redhat.com>
* config/m32c/m32c.h (LIBGCC2_UNITS_PER_WORD): Define if not

View File

@ -4193,6 +4193,12 @@ c_parser_asm_statement (c_parser *parser)
return NULL_TREE;
}
str = c_parser_asm_string_literal (parser);
if (str == NULL_TREE)
{
parser->lex_untranslated_string = false;
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
return NULL_TREE;
}
if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
{
simple = true;

View File

@ -1,7 +1,14 @@
2009-04-01 Jakub Jelinek <jakub@redhat.com>
PR c/37772
* gcc.dg/pr37772.c: New test.
* g++.dg/ext/asm11.C: New test.
2009-04-01 H.J. Lu <hongjiu.lu@intel.com>
(restore_ld_library_path_env_vars): Always restore GCC_EXEC_PREFIX
to its original value, or unset if it was not defined.
* lib/target-libpath.exp (restore_ld_library_path_env_vars): Always
restore GCC_EXEC_PREFIX to its original value, or unset if it was not
defined.
2009-03-31 Jason Merrill <jason@redhat.com>

View File

@ -0,0 +1,20 @@
// PR c/37772
// { dg-do compile }
// { dg-options "" }
void
foo ()
{
int i;
asm (); // { dg-error "expected string-literal before" }
asm (1); // { dg-error "expected string-literal before" }
asm (int); // { dg-error "expected string-literal before" }
asm (: "=r" (i)); // { dg-error "expected string-literal before" }
asm (1 : "=r" (i)); // { dg-error "expected string-literal before" }
asm (int : "=r" (i)); // { dg-error "expected string-literal before" }
asm (: : "r" (i)); // { dg-error "expected string-literal before" }
asm (1 : : "r" (i)); // { dg-error "expected string-literal before" }
asm (int : : "r" (i)); // { dg-error "expected string-literal before" }
asm (: : : "memory"); // { dg-error "expected string-literal before" }
asm (1 : : : "memory"); // { dg-error "expected string-literal before" }
}

View File

@ -0,0 +1,20 @@
/* PR c/37772 */
/* { dg-do compile } */
/* { dg-options "" } */
void
foo ()
{
int i;
asm (); /* { dg-error "expected string literal before" } */
asm (1); /* { dg-error "expected string literal before" } */
asm (int); /* { dg-error "expected string literal before" } */
asm (: "=r" (i)); /* { dg-error "expected string literal before" } */
asm (1 : "=r" (i)); /* { dg-error "expected string literal before" } */
asm (int : "=r" (i)); /* { dg-error "expected string literal before" } */
asm (: : "r" (i)); /* { dg-error "expected string literal before" } */
asm (1 : : "r" (i)); /* { dg-error "expected string literal before" } */
asm (int : : "r" (i)); /* { dg-error "expected string literal before" } */
asm (: : : "memory"); /* { dg-error "expected string literal before" } */
asm (1 : : : "memory"); /* { dg-error "expected string literal before" } */
}