OSDN Git Service

PR c++/46526
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Nov 2010 23:50:21 +0000 (23:50 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Nov 2010 23:50:21 +0000 (23:50 +0000)
* semantics.c (cxx_eval_call_expression): Unshare the result.

* g++.dg/cpp0x/constexpr-base3.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-base3.C [new file with mode: 0644]

index b192ed1..e3d97d2 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/46526
+       * semantics.c (cxx_eval_call_expression): Unshare the result.
+
 2010-11-19  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * parser.c (cp_parser_objc_protocol_declaration): Pass attributes
index 38e03f6..9b565da 100644 (file)
@@ -6042,7 +6042,7 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t,
     }
 
   pop_cx_call_context ();
-  return result;
+  return unshare_expr (result);
 }
 
 /* FIXME speed this up, it's taking 16% of compile time on sieve testcase.  */
index 38a694c..1a54308 100644 (file)
@@ -1,5 +1,8 @@
 2010-11-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/46526
+       * g++.dg/cpp0x/constexpr-base3.C: New test.
+
        PR tree-optimization/45830
        * gcc.target/i386/pr45830.c: New test.
        * gcc.c-torture/execute/pr45830.c: New test.
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-base3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-base3.C
new file mode 100644 (file)
index 0000000..cffe9ea
--- /dev/null
@@ -0,0 +1,27 @@
+// PR c++/46526
+// { dg-do run }
+// { dg-options "-std=c++0x" }
+
+struct Base
+{
+  virtual int getid () = 0;
+};
+
+struct A : public Base
+{
+  virtual int getid () { return 1; }
+};
+
+struct B : public Base
+{
+  virtual int getid () { throw "here"; }
+};
+
+int
+main ()
+{
+  A a;
+  B b;
+  Base& ar = a;
+  ar.getid ();
+}