From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg McGary To: gcc@gcc.gnu.org Subject: Re: RFC: adding lookups on the target names for alias attributes Date: Thu, 21 Sep 2000 00:35:00 -0000 Message-id: References: <200009210122.SAA00879@kayak.mcgary.org> X-SW-Source: 2000-09/msg00496.html Greg McGary writes: > I'd like to do this in decl_attributes: > > 1) Lookup the target name, seeking a decl with the same > flavor (function, data, type, whatever) as the aliasing decl > yielding a target decl. > > 2) If a target decl of appropriate flavor is found and is unambiguous > (overloading in C++ being the primary source of ambiguity), use the > target decl's DECL_ASSEMBLER_NAME as the alias target, rather than > the programmer-supplied target string. > > If the target name is not found, is the wrong flavor, or is > ambiguous, issue a warning and use the programmer-supplied string. > The warning is justified because if the target remains undefined in > the object file, then the assembler will silently ignore the alias, > which is unexpected and sometimes confusing behavior. It's easy > enough to avoid the warning by placing the alias decl after the > target's definition. Explicitly mangled C++ names need special > handling to avoid the warning, but I'm inclined to just let that > slide for now since aliases seem to be seldom, if ever, used in C++. Don't everyone chime in at once! 8^) Here's a better idea: As documented, the alias attribute takes a literal-string argument, but the parser will accept an identifier as a general attribute arg well. Therefore, retain old behavior for literal-string targets. Implement new behavior when an identifier appears as target name. For C++, the parser should accept a scope-qualified name (e.g., alias (a::b)) Example: Old style: /* OK to reference "__foo" before __foo is defined. */ void foo () attribute ((alias ("__foo"))); void __foo () {} New style: void __foo () {} /* Must define __foo before referencing it. */ void foo () attribute ((alias (__foo))); Basically, the new style gives better error checking, since it will ensure (a) that a target name is declared before being referenced as an alias target, (b) that the decls of alias and target are consistent (same flavor; and for functions, that arg signatures match), (c) the alias target is automatically mangled. Comments? Greg