This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] PR c/7490


Richard Henderson wrote:
> 
> On Tue, Nov 26, 2002 at 02:49:19PM +0100, Philippe Trebuchet wrote:
> > This also result in an ICE without the patch.
> > void foo()
> >  {
> >      auto void BAR() {};
> >      auto void bar () __attribute__ ((alias ("BAR")));
> >      bar();
> 
> This also doesn't do what you think.  There *still* is no
> definition for the assembly-level symbol "BAR".  You have
> introduced a definition for "BAR.0".
> 
> > !       id = maybe_get_identifier (TREE_STRING_POINTER (id));
> 
> No, this is not what I mean.  The alias is, for better or
> worse, defined at the assembly level, not the source language
> level.  This affects C++ significantly more than C due to
> name mangling.
> 
> r~

You are right, I was wrong. thank you for correcting me.
So a correct testcase could be
void BAR(){};
void foo()
{
   void bar() __attribute__ ((alias ("BAR")));
   bar();
}

that also result in an ICE.

void foo()
{
   void bar();
   bar();
}

you also said:

Richard Henderson wrote:

[snip]

>Yes.  Two things I'd like to see:
>
>(1) Don't accept alias definitions in a nested scope, since the scope
>    doesn't actually nest.

you say that you would like to prevent alias definition in a nested
scope, this seems easy and the following patch does it, doesn't he?

>(2) Notice aliases of undefined symbols.  Due to our non-management 
>    of assembly-level symbols, this is quite hard at the moment.  :-/

I could try to have a look at this in second time.  

							--Philippe
Index: gcc/ChangeLog
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/ChangeLog,v
retrieving revision 1.15991
diff -c -p -3 -r1.15991 ChangeLog
*** gcc/ChangeLog	26 Nov 2002 00:51:05 -0000	1.15991
--- gcc/ChangeLog	27 Nov 2002 10:04:34 -0000
***************
*** 1,3 ****
--- 1,7 ----
+ 2002-11-25  Philippe Trebuchet   <ptrebuc@farewell.inria.fr>
+ 
+ 	* c-semantics.c (genrtl_scope_stmt): Fix local alias Handling
+ 
  2002-11-25  Richard Henderson  <rth@redhat.com>
  
  	* alias.c (find_base_value): Use new_reg_base_value if it's live.
Index: gcc/c-semantics.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/c-semantics.c,v
retrieving revision 1.47
diff -c -p -3 -r1.47 c-semantics.c
*** gcc/c-semantics.c	22 Sep 2002 02:03:15 -0000	1.47
--- gcc/c-semantics.c	27 Nov 2002 10:04:34 -0000
*************** genrtl_scope_stmt (t)
*** 620,628 ****
  	      && !TREE_ASM_WRITTEN (fn)
  	      && TREE_ADDRESSABLE (fn))
  	    {
! 	      push_function_context ();
! 	      output_inline_function (fn);
! 	      pop_function_context ();
  	    }
  	}
      }
--- 620,642 ----
  	      && !TREE_ASM_WRITTEN (fn)
  	      && TREE_ADDRESSABLE (fn))
  	    {
! 	      tree alias;
! 	      alias = lookup_attribute ("alias", DECL_ATTRIBUTES (fn));
! 	      if (alias)
! 		{
! 		  alias=TREE_VALUE(TREE_VALUE(alias));
! 		  error(" `%s' is defining an alias in a nested scope",
! 			TREE_STRING_POINTER(alias));
! 		}
! 	      else if (DECL_SAVED_INSNS (fn) != NULL)
! 		  {
! 		    push_function_context ();
! 		    output_inline_function (fn);
! 		    pop_function_context ();
! 		  }
! 	      else 
! 		error ("no definition for auto nested function `%s'",
! 		       IDENTIFIER_POINTER (DECL_NAME (fn)));
  	    }
  	}
      }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]