+2011-05-09 Jason Merrill <jason@redhat.com>
+
+ PR c++/34772
+ * decl.c (initialize_local_var): Use DECL_INITIAL for simple
+ initialization.
+
2011-05-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement final/override for member functions.
/* Perform the initialization. */
if (init)
{
- int saved_stmts_are_full_exprs_p;
+ if (TREE_CODE (init) == INIT_EXPR
+ && !TREE_SIDE_EFFECTS (TREE_OPERAND (init, 1)))
+ {
+ /* Stick simple initializers in DECL_INITIAL so that
+ -Wno-init-self works (c++/34772). */
+ gcc_assert (TREE_OPERAND (init, 0) == decl);
+ DECL_INITIAL (decl) = TREE_OPERAND (init, 1);
+ }
+ else
+ {
+ int saved_stmts_are_full_exprs_p;
- /* If we're only initializing a single object, guard the destructors
- of any temporaries used in its initializer with its destructor.
- This isn't right for arrays because each element initialization is
- a full-expression. */
- if (cleanup && TREE_CODE (type) != ARRAY_TYPE)
- wrap_temporary_cleanups (init, cleanup);
+ /* If we're only initializing a single object, guard the
+ destructors of any temporaries used in its initializer with
+ its destructor. This isn't right for arrays because each
+ element initialization is a full-expression. */
+ if (cleanup && TREE_CODE (type) != ARRAY_TYPE)
+ wrap_temporary_cleanups (init, cleanup);
- gcc_assert (building_stmt_tree ());
- saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
- current_stmt_tree ()->stmts_are_full_exprs_p = 1;
- finish_expr_stmt (init);
- current_stmt_tree ()->stmts_are_full_exprs_p =
- saved_stmts_are_full_exprs_p;
+ gcc_assert (building_stmt_tree ());
+ saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
+ current_stmt_tree ()->stmts_are_full_exprs_p = 1;
+ finish_expr_stmt (init);
+ current_stmt_tree ()->stmts_are_full_exprs_p =
+ saved_stmts_are_full_exprs_p;
+ }
}
/* Set this to 0 so we can tell whether an aggregate which was
+2011-05-09 Jason Merrill <jason@redhat.com>
+
+ * gcc.dg/gcc.dg/uninit-D.c: Move to c-c++-common.
+ * gcc.dg/gcc.dg/uninit-D-O0.c: Move to c-c++-common.
+ * gcc.dg/gcc.dg/uninit-E.c: Move to c-c++-common.
+ * gcc.dg/gcc.dg/uninit-E-O0.c: Move to c-c++-common.
+ * gcc.dg/gcc.dg/uninit-F.c: Move to c-c++-common.
+ * gcc.dg/gcc.dg/uninit-F-O0.c: Move to c-c++-common.
+ * gcc.dg/gcc.dg/uninit-G.c: Move to c-c++-common.
+ * gcc.dg/gcc.dg/uninit-G-O0.c: Move to c-c++-common.
+
2011-05-08 Ville Voutilainen <ville.voutilainen@gmail.com>
* g++.dg/inherit/virtual9.C: New.
--- /dev/null
+/* Test we do not warn about initializing variable with self. */
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized" } */
+
+int f()
+{
+ int i = i;
+ return i;
+}
--- /dev/null
+/* Test we do not warn about initializing variable with self. */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized" } */
+
+int f()
+{
+ int i = i;
+ return i;
+}
--- /dev/null
+/* Test we do warn about initializing variable with self when -Winit-self is supplied. */
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -Winit-self" } */
+
+int f()
+{
+ int i = i; /* { dg-warning "i" "uninitialized variable warning" } */
+ return i;
+}
--- /dev/null
+/* Test we do warn about initializing variable with self when -Winit-self is supplied. */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -Winit-self" } */
+
+int f()
+{
+ int i = i; /* { dg-warning "i" "uninitialized variable warning" } */
+ return i;
+}
--- /dev/null
+/* Test we do warn about initializing variable with self in the initialization. */
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized" } */
+
+int f()
+{
+ int i = i + 1; /* { dg-warning "i" "uninitialized variable warning" } */
+ return i;
+}
--- /dev/null
+/* Test we do warn about initializing variable with self in the initialization. */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized" } */
+
+int f()
+{
+ int i = i + 1; /* { dg-warning "i" "uninitialized variable warning" } */
+ return i;
+}
--- /dev/null
+/* Test we do not warn about initializing variable with address of self in the initialization. */
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized" } */
+
+void *f()
+{
+ void *i = &i;
+ return i;
+}
--- /dev/null
+/* Test we do not warn about initializing variable with address of self in the initialization. */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized" } */
+
+void *f()
+{
+ void *i = &i;
+ return i;
+}
+++ /dev/null
-/* Test we do not warn about initializing variable with self. */
-/* { dg-do compile } */
-/* { dg-options "-Wuninitialized" } */
-
-int f()
-{
- int i = i;
- return i;
-}
+++ /dev/null
-/* Test we do not warn about initializing variable with self. */
-/* { dg-do compile } */
-/* { dg-options "-O -Wuninitialized" } */
-
-int f()
-{
- int i = i;
- return i;
-}
+++ /dev/null
-/* Test we do warn about initializing variable with self when -Winit-self is supplied. */
-/* { dg-do compile } */
-/* { dg-options "-Wuninitialized -Winit-self" } */
-
-int f()
-{
- int i = i; /* { dg-warning "i" "uninitialized variable warning" } */
- return i;
-}
+++ /dev/null
-/* Test we do warn about initializing variable with self when -Winit-self is supplied. */
-/* { dg-do compile } */
-/* { dg-options "-O -Wuninitialized -Winit-self" } */
-
-int f()
-{
- int i = i; /* { dg-warning "i" "uninitialized variable warning" } */
- return i;
-}
+++ /dev/null
-/* Test we do warn about initializing variable with self in the initialization. */
-/* { dg-do compile } */
-/* { dg-options "-Wuninitialized" } */
-
-int f()
-{
- int i = i + 1; /* { dg-warning "i" "uninitialized variable warning" } */
- return i;
-}
+++ /dev/null
-/* Test we do warn about initializing variable with self in the initialization. */
-/* { dg-do compile } */
-/* { dg-options "-O -Wuninitialized" } */
-
-int f()
-{
- int i = i + 1; /* { dg-warning "i" "uninitialized variable warning" } */
- return i;
-}
+++ /dev/null
-/* Test we do not warn about initializing variable with address of self in the initialization. */
-/* { dg-do compile } */
-/* { dg-options "-Wuninitialized" } */
-
-void *f()
-{
- void *i = &i;
- return i;
-}
+++ /dev/null
-/* Test we do not warn about initializing variable with address of self in the initialization. */
-/* { dg-do compile } */
-/* { dg-options "-O -Wuninitialized" } */
-
-void *f()
-{
- void *i = &i;
- return i;
-}