This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++: Missing documentation for MODOP_EXPR
Mark Mitchell <mark@codesourcery.com> writes:
| On Fri, 2003-08-15 at 11:10, Gabriel Dos Reis wrote:
| > Mark,
| >
| > While working on the new C++ pretty-printer, I came to realize that
| > MODOP_EXPR is documented nowhere. The only comment I can find is this:
| >
| > /* A whole bunch of tree codes for the initial, superficial parsing of
| > templates. */
| >
| > from cp/cp-tree.def. While the meaning of most of those "bunch of
| > tree codes" may be infered from their names and some familiarity with
| > the C++ front end, that of MODOP_EXPR remains obscure to me.
| >
| > Could you enlighten me?
|
| It's an assignment operator (including compound assignments) while
| parsing a template.
I guessed that while looking at some output. But I could not go far.
For example, given the following from libstdc++-v3
// Convert numeric value of type _Tv to string and return length of
// string. If snprintf is available use it, otherwise fall back to
// the unsafe sprintf which, in general, can be dangerous and should
// be avoided.
template<typename _Tv>
int
__convert_from_v(char* __out, const int __size, const char* __fmt,
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
_Tv __v, const __c_locale& __cloc, int __prec = -1)
{
__c_locale __old = __gnu_cxx::__uselocale(__cloc);
#else
_Tv __v, const __c_locale&, int __prec = -1)
{
char* __old = setlocale(LC_ALL, NULL);
char* __sav = static_cast<char*>(malloc(strlen(__old) + 1));
if (__sav)
strcpy(__sav, __old);
setlocale(LC_ALL, "C");
#endif
int __ret;
#ifdef _GLIBCPP_USE_C99
if (__prec >= 0)
__ret = snprintf(__out, __size, __fmt, __prec, __v);
else
__ret = snprintf(__out, __size, __fmt, __v);
#else
if (__prec >= 0)
__ret = sprintf(__out, __fmt, __prec, __v);
else
__ret = sprintf(__out, __fmt, __v);
#endif
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__gnu_cxx::__uselocale(__old);
#else
setlocale(LC_ALL, __sav);
free(__sav);
#endif
return __ret;
}
}
Both
__ret = sprintf(__out, __fmt, __prec, __v);
and
__ret = sprintf(__out, __fmt, __v);
are represented as MODOP_EXPR.
My questions are:
1) is __ret the first operand?
2) is sprintf the second operand?
3) is the argument list the third operand?
I don't think the answers for the last two questions are "yes". What
I'm after is the meaning of the tree operands.
Thanks.
-- Gaby