From: Mark Mitchell Date: Mon, 21 May 2001 18:36:57 +0000 (+0000) Subject: c-decl.c (finish_decl): Don't set DECL_C_HARD_REGISTER for non-register variables. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0adc3c19711068a5fc3a1f97e7e77cac98606ac4;p=platform%2Fupstream%2Fgcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 861b4ba..5690962 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2001-05-21 Mark Mitchell + + * 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 * dbxout.c (MINIMAL_DEBUG, flag_minimal_debug): Lose. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 3de4592..0c08662 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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); } diff --git a/gcc/extend.texi b/gcc/extend.texi index 0d96b25..48c6ea1 100644 --- a/gcc/extend.texi +++ b/gcc/extend.texi @@ -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: diff --git a/gcc/testsuite/gcc.dg/20010520-1.c b/gcc/testsuite/gcc.dg/20010520-1.c new file mode 100644 index 0000000..c96dbc4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20010520-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-w" } */ + +void f () +{ + int i __asm__ ("%eax"); + __asm__ volatile ("" : "=a" (i)); +} + +