This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix g++.other/init16.C
- To: mark at codesourcery dot com
- Subject: [C++ PATCH] Fix g++.other/init16.C
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Fri, 16 Feb 2001 16:59:27 +0100
- Cc: jason at redhat dot com, gcc-patches at gcc dot gnu dot org
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
Hi!
The following patch modifies init16.C test so that it does not need <string>
(otherwise it would had to s/string x/std::string x/ and it is always better
not to include anything in the tests) plus an attempt to fix it (fixes the
testcase and does not create any regressions, though I'm not 100% sure if it
shouldn't be elsewhere). I think the test got broken in Mark's 1999-07-23
reference binding change (previously convert_like simply called there
convert_to_reference instead of all the code there and convert_to_reference
handled that gracefully).
Ok to commit? If not, is it ok to commit at least the test change?
2001-02-16 Jakub Jelinek <jakub@redhat.com>
* call.c (convert_like_real): Create a temporary for non-constant
constructor.
* g++.old-deja/g++.other/init16.C: Update the test so that it does
not need <string> and also tests the initialization at runtime.
--- gcc/cp/call.c.jj Thu Feb 15 14:15:02 2001
+++ gcc/cp/call.c Fri Feb 16 17:29:08 2001
@@ -3850,7 +3850,9 @@ convert_like_real (convs, expr, fn, argn
tree ref_type = totype;
/* If necessary, create a temporary. */
- if (NEED_TEMPORARY_P (convs))
+ if (NEED_TEMPORARY_P (convs)
+ || (TREE_CODE (expr) == CONSTRUCTOR
+ && !TREE_CONSTANT (expr)))
{
tree type = TREE_TYPE (TREE_OPERAND (convs, 0));
expr = build_target_expr_with_type (expr, type);
--- gcc/testsuite/g++.old-deja/g++.other/init16.C.jj Wed Nov 8 14:22:06 2000
+++ gcc/testsuite/g++.old-deja/g++.other/init16.C Fri Feb 16 17:41:28 2001
@@ -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';
+}
Jakub