mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
tests: fix invalid C++11 code
* tests/c++.at (Object): Somehow instances of Object were assigned YY_NULL, which is 0 most of the time (that case passes), but is nullptr in C++11, and there is nothing in Object to support such an assignment (failure). Use 0 as value, and provide the needed assignment operator. Also, use a more natural order within the class definition.
This commit is contained in:
58
tests/c++.at
58
tests/c++.at
@@ -613,14 +613,42 @@ $1
|
|||||||
/// A class that counts its number of instances.
|
/// A class that counts its number of instances.
|
||||||
struct Object
|
struct Object
|
||||||
{
|
{
|
||||||
|
char val;
|
||||||
|
|
||||||
|
Object (char v)
|
||||||
|
: val (v)
|
||||||
|
{
|
||||||
|
Object::instances.push_back(this);
|
||||||
|
log (this, "Object::Object");
|
||||||
|
}
|
||||||
|
|
||||||
|
Object ()
|
||||||
|
: val ('?')
|
||||||
|
{
|
||||||
|
Object::instances.push_back(this);
|
||||||
|
log (this, "Object::Object");
|
||||||
|
}
|
||||||
|
|
||||||
|
Object& operator= (char v)
|
||||||
|
{
|
||||||
|
val = v;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~Object ()
|
||||||
|
{
|
||||||
|
Object::instances.remove (this);
|
||||||
|
log (this, "Object::~Object");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static part.
|
||||||
typedef std::list<const Object*> objects;
|
typedef std::list<const Object*> objects;
|
||||||
static objects instances;
|
static objects instances;
|
||||||
char val;
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
empty ()
|
empty ()
|
||||||
{
|
{
|
||||||
return instances.empty();
|
return instances.empty ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -643,26 +671,6 @@ $1
|
|||||||
std::cerr << " }" << std::endl;
|
std::cerr << " }" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object (char v)
|
|
||||||
: val (v)
|
|
||||||
{
|
|
||||||
instances.push_back(this);
|
|
||||||
log (this, "Object::Object");
|
|
||||||
}
|
|
||||||
|
|
||||||
Object ()
|
|
||||||
: val ('?')
|
|
||||||
{
|
|
||||||
instances.push_back(this);
|
|
||||||
log (this, "Object::Object");
|
|
||||||
}
|
|
||||||
|
|
||||||
~Object ()
|
|
||||||
{
|
|
||||||
instances.remove(this);
|
|
||||||
log (this, "Object::~Object");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -725,11 +733,11 @@ item:
|
|||||||
// Not just 'E', otherwise we reduce when 'E' is the lookahead, and
|
// Not just 'E', otherwise we reduce when 'E' is the lookahead, and
|
||||||
// then the stack is emptied, defeating the point of the test.
|
// then the stack is emptied, defeating the point of the test.
|
||||||
| 'E' 'a' { YYUSE($][1); $][$ = $][2; }
|
| 'E' 'a' { YYUSE($][1); $][$ = $][2; }
|
||||||
| 'R' { $][$ = YY_NULL; ]AT_VARIANT_IF([], [delete $][1]; )[YYERROR; }
|
| 'R' { $][$ = 0; ]AT_VARIANT_IF([], [delete $][1]; )[YYERROR; }
|
||||||
| 'p' { $][$ = $][1; }
|
| 'p' { $][$ = $][1; }
|
||||||
| 's' { $][$ = $][1; throw std::runtime_error ("reduction"); }
|
| 's' { $][$ = $][1; throw std::runtime_error ("reduction"); }
|
||||||
| 'T' { $][$ = YY_NULL; ]AT_VARIANT_IF([], [delete $][1]; )[YYABORT; }
|
| 'T' { $][$ = 0; ]AT_VARIANT_IF([], [delete $][1]; )[YYABORT; }
|
||||||
| error { $][$ = YY_NULL; yyerrok; }
|
| error { $][$ = 0; yyerrok; }
|
||||||
;
|
;
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user