OSDN Git Service

cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Jan 2001 14:25:03 +0000 (14:25 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Jan 2001 14:25:03 +0000 (14:25 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39121 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/init17.C [new file with mode: 0644]

index 23eecef..fce2a4d 100644 (file)
@@ -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
index 98f4bbd..1516d69 100644 (file)
@@ -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;
index fafa55e..7a61dec 100644 (file)
@@ -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))
        {
index 4482c3d..2bb910f 100644 (file)
@@ -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 (file)
index 0000000..4a6e582
--- /dev/null
@@ -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
+}