diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2001-01-18 14:25:03 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2001-01-18 14:25:03 +0000 |
commit | f5ceeec84f7ef85b96400b54d0e2276a0c0a2ef7 (patch) | |
tree | f1e99bdfd621ac1e5fd7a7984d124b3f0e8f76e0 /gcc | |
parent | 2d6dc19dfa98f8852cf648198fe32b918754864f (diff) | |
download | gcc-f5ceeec84f7ef85b96400b54d0e2276a0c0a2ef7.zip gcc-f5ceeec84f7ef85b96400b54d0e2276a0c0a2ef7.tar.gz gcc-f5ceeec84f7ef85b96400b54d0e2276a0c0a2ef7.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/init.c | 8 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/init17.C | 18 |
5 files changed, 37 insertions, 2 deletions
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 <nathan@codesourcery.com> + + * 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 <jakub@redhat.com> * 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 <nathan@codesourcery.com> + + * g++.old-deja/g++.other/init17.C: New test. + 2001-01-18 Alexandre Oliva <aoliva@redhat.com> * 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 <nathan@codesourcery.com> + +// 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 +} |