OSDN Git Service

PR c++/47003
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 22 Dec 2010 19:23:15 +0000 (19:23 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 22 Dec 2010 19:23:15 +0000 (19:23 +0000)
* tree.c (stabilize_expr): Really stabilize scalar glvalues.

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

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/volatile2.C [new file with mode: 0644]

index 62b7d8d..cb9cd95 100644 (file)
@@ -1,3 +1,8 @@
+2010-12-22  Jason Merrill  <jason@redhat.com>
+
+       PR c++/47003
+       * tree.c (stabilize_expr): Really stabilize scalar glvalues.
+
 2010-12-22  Rodrigo Rivas Costa <rodrigorivascosta@gmail.com>
 
        * parser.c (cp_parser_unary_expression): Call pedwarn for alignof
index 1a77dc1..ecb764a 100644 (file)
@@ -3058,9 +3058,7 @@ stabilize_expr (tree exp, tree* initp)
 
   if (!TREE_SIDE_EFFECTS (exp))
     init_expr = NULL_TREE;
-  /* There are no expressions with REFERENCE_TYPE, but there can be call
-     arguments with such a type; just treat it as a pointer.  */
-  else if (TREE_CODE (TREE_TYPE (exp)) == REFERENCE_TYPE
+  else if (!TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (exp))
           || !lvalue_or_rvalue_with_address_p (exp))
     {
       init_expr = get_target_expr (exp);
index 06257d1..906fc60 100644 (file)
@@ -1,3 +1,7 @@
+2010-12-22  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/init/volatile2.C: New.
+
 2010-12-22  Rodrigo Rivas Costa <rodrigorivascosta@gmail.com>
 
        * g++.dg/cpp0x/alignof2.C: New.
diff --git a/gcc/testsuite/g++.dg/init/volatile2.C b/gcc/testsuite/g++.dg/init/volatile2.C
new file mode 100644 (file)
index 0000000..036d5f1
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/47003
+
+struct A
+{
+  A(int);
+};
+
+volatile int i;
+
+int main()
+{
+  A *q = new A (i);
+}