Re: [Doxygen-develop] gcc 3.3 patch
Brought to you by:
dimitri
From: James M. D. <mdu...@ya...> - 2003-07-22 10:57:40
|
Please do not apply this patch yet, when i run doxygen, it hangs the entire system. I think it might have something to do with this command : > + operator CPPValueParser & () > + { > + static CPPValueParser ret = *this; > + return ret; > + } mike --- James Michael DuPont <mdu...@ya...> wrote: > Dear All, > > I have just compiled doxygen with the new gcc (3.3) > it has a problem with a union of objects with a constructor. > > CPPValue > > I have removed the constructor, and put it into a derived class > CppValue2. > > The class CppValueParser is used by the Parser directly. > > The users of the CPPValue now use CPPValue2, the parsers uses > CppValueParser. > > This all has the effect of isolating the constructor from the parser, > but making them work togeather. Surely this can be done better, just > a > quick hack.. > > > Mike > > ===== > James Michael DuPont > http://introspector.sourceforge.net/ > > __________________________________ > Do you Yahoo!? > Yahoo! SiteBuilder - Free, easy-to-use web site design software > http://sitebuilder.yahoo.com> diff -u src/constexp.y ../src/constexp.y > --- src/constexp.y Mon Jan 20 04:40:09 2003 > +++ ../src/constexp.y Tue Jul 22 11:11:41 2003 > @@ -26,7 +26,7 @@ > #define MSDOS > #endif > > -#define YYSTYPE CPPValue > +#define YYSTYPE CPPValueParser > > #include <stdio.h> > #include <stdlib.h> > @@ -93,7 +93,7 @@ > { $$ = $1; } > | logical_or_expression TOK_OR > logical_and_expression > { > - $$ = CPPValue( (long)((long)$1 || (long)$3) ); > + $$ = CPPValue2( (long)((long)$1 || (long)$3) ); > } > ; > > @@ -101,7 +101,7 @@ > { $$ = $1; } > | logical_and_expression TOK_AND inclusive_or_expression > { > - $$ = CPPValue( (long)((long)$1 && (long)$3) ); > + $$ = CPPValue2( (long)((long)$1 && (long)$3) ); > } > ; > > @@ -110,7 +110,7 @@ > | inclusive_or_expression TOK_BITWISEOR > exclusive_or_expression > { > - $$ = CPPValue( (long)$1 | (long)$3 ); > + $$ = CPPValue2( (long)$1 | (long)$3 ); > } > ; > > @@ -118,7 +118,7 @@ > { $$ = $1; } > | exclusive_or_expression TOK_BITWISEXOR and_expression > { > - $$ = CPPValue( (long)$1 ^ (long)$3 ); > + $$ = CPPValue2( (long)$1 ^ (long)$3 ); > } > ; > > @@ -126,7 +126,7 @@ > { $$ = $1; } > | and_expression TOK_AMPERSAND equality_expression > { > - $$ = CPPValue( (long)$1 & (long)$3 ); > + $$ = CPPValue2( (long)$1 & (long)$3 ); > } > ; > > @@ -134,11 +134,11 @@ > { $$ = $1; } > | equality_expression TOK_EQUAL relational_expression > { > - $$ = CPPValue( (long)((double)$1 == (double)$3) ); > + $$ = CPPValue2( (long)((double)$1 == (double)$3) ); > } > | equality_expression TOK_NOTEQUAL relational_expression > { > - $$ = CPPValue( (long)((double)$1 != > (double)$3) ); > + $$ = CPPValue2( (long)((double)$1 != > (double)$3) ); > } > ; > > @@ -146,21 +146,21 @@ > { $$ = $1; } > | relational_expression TOK_LESSTHAN shift_expression > { > - $$ = CPPValue( (long)((double)$1 < (double)$3) ); > + $$ = CPPValue2( (long)((double)$1 < (double)$3) ); > } > | relational_expression TOK_GREATERTHAN shift_expression > { > - $$ = CPPValue( (long)((double)$1 > > (double)$3) ); > + $$ = CPPValue2( (long)((double)$1 > > (double)$3) ); > } > | relational_expression TOK_LESSTHANOREQUALTO > shift_expression > { > - $$ = CPPValue( (long)((double)$1 <= (double)$3) ); > + $$ = CPPValue2( (long)((double)$1 <= (double)$3) ); > } > | relational_expression TOK_GREATERTHANOREQUALTO > shift_expression > { > - $$ = CPPValue( (long)((double)$1 >= (double)$3) ); > + $$ = CPPValue2( (long)((double)$1 >= (double)$3) ); > } > ; > > @@ -168,11 +168,11 @@ > { $$ = $1; } > | shift_expression TOK_SHIFTLEFT additive_expression > { > - $$ = CPPValue( (long)$1 << (long)$3 ); > + $$ = CPPValue2( (long)$1 << (long)$3 ); > } > | shift_expression TOK_SHIFTRIGHT additive_expression > { > - $$ = CPPValue( (long)$1 >> (long)$3 ); > + $$ = CPPValue2( (long)$1 >> (long)$3 ); > } > ; > > @@ -182,22 +182,22 @@ > { > if (!$1.isInt() || !$3.isInt()) > { > - $$ = CPPValue( (double)$1 + (double)$3 ); > + $$ = CPPValue2( (double)$1 + (double)$3 ); > } > else > { > - $$ = CPPValue( (long)$1 + (long)$3 ); > + $$ = CPPValue2( (long)$1 + (long)$3 ); > } > } > | additive_expression TOK_MINUS multiplicative_expression > { > if (!$1.isInt() || !$3.isInt()) > { > - $$ = CPPValue( (double)$1 - (double)$3 ); > + $$ = CPPValue2( (double)$1 - (double)$3 ); > } > else > { > - $$ = CPPValue( (long)$1 - (long)$3 ); > + $$ = CPPValue2( (long)$1 - (long)$3 ); > } > } > ; > @@ -208,31 +208,31 @@ > { > if (!$1.isInt() || !$3.isInt()) > { > - $$ = CPPValue( (double)$1 * (double)$3 ); > + $$ = CPPValue2( (double)$1 * (double)$3 ); > } > else > { > - $$ = CPPValue( (long)$1 * (long)$3 ); > + $$ = CPPValue2( (long)$1 * (long)$3 ); > } > } > | multiplicative_expression TOK_DIVIDE unary_expression > { > if (!$1.isInt() || !$3.isInt()) > { > - $$ = CPPValue( (double)$1 / (double)$3 ); > + $$ = CPPValue2( (double)$1 / (double)$3 ); > } > else > { > long value = $3; > if (value==0) value=1; > - $$ = CPPValue( (long)$1 / value ); > + $$ = CPPValue2( (long)$1 / value ); > } > } > | multiplicative_expression TOK_MOD unary_expression > { > long value = $3; > if (value==0) value=1; > - $$ = CPPValue( (long)$1 % value ); > + $$ = CPPValue2( (long)$1 % value ); > } > ; > > @@ -243,17 +243,17 @@ > | TOK_MINUS unary_expression > { > if ($2.isInt()) > - $$ = CPPValue(-(long)$2); > + $$ = CPPValue2(-(long)$2); > else > - $$ = CPPValue(-(double)$2); > + $$ = CPPValue2(-(double)$2); > } > | TOK_TILDE unary_expression > { > - $$ = CPPValue(~(long)$2); > + $$ = CPPValue2(~(long)$2); > } > | TOK_NOT unary_expression > { > - $$ = CPPValue((long)!(long)$2); > + $$ = CPPValue2((long)!(long)$2); > } > ; > > Only in ../src/: constexp.y.~1.21.~ > diff -u src/cppvalue.cpp ../src/cppvalue.cpp > --- src/cppvalue.cpp Mon Jan 20 04:40:09 2003 > +++ ../src/cppvalue.cpp Tue Jul 22 11:00:18 2003 > @@ -21,27 +21,27 @@ > #include "cppvalue.h" > #include "constexp.h" > > -CPPValue parseOctal() > +CPPValue2 parseOctal() > { > long val = 0; > for (const char *p = g_strToken.data(); *p != 0; p++) > { > if (*p >= '0' && *p <= '7') val = val * 8 + *p - '0'; > } > - return CPPValue(val); > + return CPPValue2(val); > } > > -CPPValue parseDecimal() > +CPPValue2 parseDecimal() > { > long val = 0; > for (const char *p = g_strToken.data(); *p != 0; p++) > { > if (*p >= '0' && *p <= '9') val = val * 10 + *p - '0'; > } > - return CPPValue(val); > + return CPPValue2(val); > } > > -CPPValue parseHexadecimal() > +CPPValue2 parseHexadecimal() > { > long val = 0; > for (const char *p = g_strToken.data(); *p != 0; p++) > @@ -51,37 +51,37 @@ > else if (*p >= 'A' && *p <= 'F') val = val * 16 + *p - 'A' + 10; > } > //printf("parseHexadecimal %s->%x\n",g_strToken.data(),val); > - return CPPValue(val); > + return CPPValue2(val); > } > > -CPPValue parseCharacter() // does not work for '\n' and the alike > +CPPValue2 parseCharacter() // does not work for '\n' and the alike > { > if (g_strToken[1]=='\\') > { > switch(g_strToken[2]) > { > - case 'n': return CPPValue((long)'\n'); > - case 't': return CPPValue((long)'\t'); > - case 'v': return CPPValue((long)'\v'); > - case 'b': return CPPValue((long)'\b'); > - case 'r': return CPPValue((long)'\r'); > - case 'f': return CPPValue((long)'\f'); > - case 'a': return CPPValue((long)'\a'); > - case '\\': return CPPValue((long)'\\'); > - case '?': return CPPValue((long)'\?'); > - case '\'': return CPPValue((long)'\''); > - case '"': return CPPValue((long)'"'); > + case 'n': return CPPValue2((long)'\n'); > + case 't': return CPPValue2((long)'\t'); > + case 'v': return CPPValue2((long)'\v'); > + case 'b': return CPPValue2((long)'\b'); > + case 'r': return CPPValue2((long)'\r'); > + case 'f': return CPPValue2((long)'\f'); > + case 'a': return CPPValue2((long)'\a'); > + case '\\': return CPPValue2((long)'\\'); > + case '?': return CPPValue2((long)'\?'); > + case '\'': return CPPValue2((long)'\''); > + case '"': return CPPValue2((long)'"'); > case '0': return parseOctal(); > case 'x': > case 'X': return parseHexadecimal(); > default: printf("Invalid escape sequence %s > found!\n",g_strToken.data()); > - return CPPValue(0L); > + return CPPValue2(0L); > } > } > - return CPPValue((long)g_strToken[1]); > + return CPPValue2((long)g_strToken[1]); > } > > -CPPValue parseFloat() > +CPPValue2 parseFloat() > { > - return CPPValue(atof(g_strToken)); > + return CPPValue2(atof(g_strToken)); > } > Only in ../src/: cppvalue.cpp.~1.23.~ > diff -u src/cppvalue.h ../src/cppvalue.h > --- src/cppvalue.h Mon Jan 20 04:40:09 2003 > +++ ../src/cppvalue.h Tue Jul 22 11:14:22 2003 > @@ -28,9 +28,6 @@ > > > enum Type { Int, Float }; > - > - CPPValue(long val=0) : type(Int) { v.l = val; } > - CPPValue(double val) : type(Float) { v.d = val; } > > operator double () const { return type==Int ? (double)v.l : v.d; > } > operator long () const { return type==Int ? v.l : (long)v.d; > } > @@ -45,7 +42,7 @@ > printf("(%f)\n",v.d); > } > > - private: > + > Type type; > union { > double d; > @@ -53,10 +50,51 @@ > } v; > }; > > -extern CPPValue parseOctal(); > -extern CPPValue parseDecimal(); > -extern CPPValue parseHexadecimal(); > -extern CPPValue parseCharacter(); > -extern CPPValue parseFloat(); > +class CPPValueParser : public CPPValue > +{ > + public : > +CPPValue & operator = (CPPValue b) > +{ > + type = b.type; > + if (type == CPPValue::Int) > + { > + v.l = b.v.l; > + } > + else > + { > + v.d = b.v.d; > + } > + return *this; > +} > + > +}; > + > +class CPPValue2 : public CPPValue > +{ > + public : > + CPPValue2() {type = CPPValue::Int; v.l = 0; } > + CPPValue2(long val) { > + type = CPPValue::Int; > + v.l = val; > + > + } > + > + CPPValue2(double val) { > + type = CPPValue::Float; > + v.d = val; > + } > + > + operator CPPValueParser & () > + { > + static CPPValueParser ret = *this; > + return ret; > + } > +}; > + > +extern CPPValue2 parseOctal(); > +extern CPPValue2 parseDecimal(); > +extern CPPValue2 parseHexadecimal(); > +extern CPPValue2 parseCharacter(); > +extern CPPValue2 parseFloat(); > > #endif > ===== James Michael DuPont http://introspector.sourceforge.net/ __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com |