call.c (convert_like_real): Create a temporary for non-lvalue.

* call.c (convert_like_real): Create a temporary for non-lvalue.

	* g++.old-deja/g++.other/init16.C: Update the test so that it does
	not need <string> and also tests the initialization at runtime.

From-SVN: r39776
This commit is contained in:
Jakub Jelinek 2001-02-16 23:30:06 +01:00 committed by Jakub Jelinek
parent f5bbdc0c54
commit 2c1be3223f
4 changed files with 32 additions and 6 deletions

View File

@ -1,3 +1,7 @@
2001-02-16 Jakub Jelinek <jakub@redhat.com>
* call.c (convert_like_real): Create a temporary for non-lvalue.
2001-02-16 Jeffrey Oldham <oldham@codesourcery.com>
* cp-tree.h: Fix typos in comments.

View File

@ -3850,7 +3850,7 @@ convert_like_real (convs, expr, fn, argnum, inner)
tree ref_type = totype;
/* If necessary, create a temporary. */
if (NEED_TEMPORARY_P (convs))
if (NEED_TEMPORARY_P (convs) || !lvalue_p (expr))
{
tree type = TREE_TYPE (TREE_OPERAND (convs, 0));
expr = build_target_expr_with_type (expr, type);

View File

@ -1,3 +1,8 @@
2001-02-16 Jakub Jelinek <jakub@redhat.com>
* g++.old-deja/g++.other/init16.C: Update the test so that it does
not need <string> and also tests the initialization at runtime.
2001-02-16 Neil Booth <neil@daikokuya.demon.co.uk>
* gcc.c-torture/execute/longlong.c: New test.

View File

@ -1,11 +1,28 @@
// Build don't link:
// Origin: Jakub Jelinek <jakub@redhat.com>
// excess errors test - XFAIL *-*-*
#include <string>
struct bar {
char c;
bar (const char *);
bar (const bar &);
};
struct foo {
string x;
bar x;
};
extern const struct foo y = { "foo" };
bar::bar (const bar &ref)
{
c = ref.c;
}
bar::bar (const char *p)
{
c = p[2];
}
int main ()
{
return y.x.c != 'o';
}