Commit 0adc3c19 by Mark Mitchell Committed by Mark Mitchell

c-decl.c (finish_decl): Don't set DECL_C_HARD_REGISTER for non-register variables.

	* c-decl.c (finish_decl): Don't set DECL_C_HARD_REGISTER for
	non-register variables.
	* extend.texi: Document that asm-specifications do not make sense
	for non-static local variables.

From-SVN: r42403
parent 01936f3a
2001-05-21 Mark Mitchell <mark@codesourcery.com>
* c-decl.c (finish_decl): Don't set DECL_C_HARD_REGISTER for
non-register variables.
* extend.texi: Document that asm-specifications do not make sense
for non-static local variables.
2001-05-21 Jason Merrill <jason_merrill@redhat.com>
* dbxout.c (MINIMAL_DEBUG, flag_minimal_debug): Lose.
......
......@@ -3616,11 +3616,30 @@ finish_decl (decl, init, asmspec_tree)
}
else
{
/* This is a local variable. If there is an ASMSPEC, the
user has requested that we handle it specially. */
if (asmspec)
{
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
DECL_C_HARD_REGISTER (decl) = 1;
/* In conjunction with an ASMSPEC, the `register'
keyword indicates that we should place the variable
in a particular register. */
if (DECL_REGISTER (decl))
DECL_C_HARD_REGISTER (decl) = 1;
/* If this is not a static variable, issue a warning.
It doesn't make any sense to give an ASMSPEC for an
ordinary, non-register local variable. Historically,
GCC has accepted -- but ignored -- the ASMSPEC in
this case. */
if (TREE_CODE (decl) == VAR_DECL
&& !DECL_REGISTER (decl)
&& !TREE_STATIC (decl))
warning_with_decl (decl,
"ignoring asm-specifier for non-static local variable `%s'");
else
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
}
add_decl_stmt (decl);
}
......
......@@ -3290,6 +3290,13 @@ On systems where an underscore is normally prepended to the name of a C
function or variable, this feature allows you to define names for the
linker that do not start with an underscore.
It does not make sense to use this feature with a non-static local
variable since such variables do not have assembler names. If you are
trying to put the variable in a particular register, see @ref{Explicit
Reg Vars}. GCC presently accepts such code with a warning, but will
probably be changed to issue an error, rather than a warning, in the
future.
You cannot use @code{asm} in this way in a function @emph{definition}; but
you can get the same effect by writing a declaration for the function
before its definition and putting @code{asm} there, like this:
......
/* { dg-do compile { target i?86-*-* } } */
/* { dg-options "-w" } */
void f ()
{
int i __asm__ ("%eax");
__asm__ volatile ("" : "=a" (i));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment