From: Nathan Sidwell Date: Thu, 18 Jan 2001 14:25:03 +0000 (+0000) Subject: typeck.c (build_modify_expr): Say `initialization' for INIT_EXPRs. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f5ceeec84f7ef85b96400b54d0e2276a0c0a2ef7;p=platform%2Fupstream%2Fgcc.git typeck.c (build_modify_expr): Say `initialization' for INIT_EXPRs. cp: * typeck.c (build_modify_expr): Say `initialization' for INIT_EXPRs. * init.c (build_default_init): Convert to enumeral type, if needed. testsuite: * g++.old-deja/g++.other/init17.C: New test. From-SVN: r39121 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 23eecef..fce2a4d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2001-01-18 Nathan Sidwell + + * typeck.c (build_modify_expr): Say `initialization' for + INIT_EXPRs. + * init.c (build_default_init): Convert to enumeral type, if + needed. + 2001-01-18 Jakub Jelinek * parse.y (nomods_initdcl0): Properly set things up for diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 98f4bbd..1516d69 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -232,7 +232,13 @@ build_default_init (type) /* --if T is a reference type, no initialization is performed. */ return NULL_TREE; else - init = integer_zero_node; + { + init = integer_zero_node; + + if (TREE_CODE (type) == ENUMERAL_TYPE) + /* We must make enumeral types the right type. */ + init = fold (build1 (NOP_EXPR, type, init)); + } init = digest_init (type, init, 0); return init; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index fafa55e..7a61dec 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5822,7 +5822,7 @@ build_modify_expr (lhs, modifycode, rhs) if (modifycode == INIT_EXPR) { newrhs = convert_for_initialization (lhs, lhstype, newrhs, LOOKUP_NORMAL, - "assignment", NULL_TREE, 0); + "initialization", NULL_TREE, 0); if (current_function_decl && lhs == DECL_RESULT (current_function_decl)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4482c3d..2bb910f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-01-18 Nathan Sidwell + + * g++.old-deja/g++.other/init17.C: New test. + 2001-01-18 Alexandre Oliva * gcc.dg/cpp/if-2.c: Adjust for signed wchar_t. diff --git a/gcc/testsuite/g++.old-deja/g++.other/init17.C b/gcc/testsuite/g++.old-deja/g++.other/init17.C new file mode 100644 index 0000000..4a6e582 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init17.C @@ -0,0 +1,18 @@ +// Build don't link: + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 17 Jan 2001 + +// Bug 1631. Default initialization of enumeral types did not convert to the +// enumeral type. + +enum X { alpha, beta }; + +void f(void *ptr) +{ + X y = X (); + X y1 (0); // ERROR - cannot convert + X y2 = X (0); + X *x = new X (); + X *x2 = new X (0); // ERROR - cannot convert +}