This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ Darwin Port BUG in source code
On 2005-02-06, at 22:22, Andrew Pinski wrote:
On Feb 6, 2005, at 4:10 PM, Marcin Dalecki wrote:
I wonder why the corresponding pargma unused implementation in
darwin-c.c is calling c_lex() and similar functions, which appear at
least to be C code dependant. However strictly adhering to the advice
the attached patch should at least give proper semantics then.
<lookup_name.diff>
Call c_lex is fine, if you look at the file c-pragma.c which is for
both the C and C++
front-ends.
What I would do instead of this (semi) huge patch is to make
lookup_name in the C++
correspond to C prototype and change the C++ front-end to use a newer
function
for the old lookup_name.
Please look a bit closer. It's the C++ part which gets an additional
parameter to
differentiate the name lookup scope (namespace type or else). The code
there is indeed a
bit fussy and I don't think it would be easy to tackle with it. In esp.
the last
parameter there is decoded by the following one-shoot "function" - code
placed in a
function called only once it's a function for me it's just an elaborate
notation:
/* Combine prefer_type and namespaces_only into flags. */
static int
lookup_flags (int prefer_type, int namespaces_only)
{
if (namespaces_only)
return LOOKUP_PREFER_NAMESPACES;
if (prefer_type > 1)
return LOOKUP_PREFER_TYPES;
if (prefer_type > 0)
return LOOKUP_PREFER_BOTH;
return 0;
}
and then
flags |= lookup_flags(prefer_type, namespace_only);
But just:
if (namespaces_only)
flags |= LOOKUP_PREFER_NAMESPACES;
if (prefer_type > 1)
flags |= LOOKUP_PREFER_TYPES;
if (prefer_type > 0)
flags |= LOOKUP_PREFER_BOTH;
Would do it as well. And then it becomes really obvious that the logics
is
a bit wired. We stuff known information in to flags to decode the same
information
multiple times later on. Pretty sure a sign that the information passed
in first place
is not encoded in the most convenient way. For me the problem is thus
on the hand of C++.