re PR c++/14397 (Access check for wrong copy constructor)
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 9 Mar 2004 18:44:02 +0000 (18:44 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 9 Mar 2004 18:44:02 +0000 (18:44 +0000)
cp:
PR c++/14397
* call.c (convert_like_real): Build a const qualified temporary,
when testing ctor access.
testsuite:
PR c++/14397
* g++.dg/overload/ref1.C: New.

From-SVN: r79196

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/overload/ref1.C [new file with mode: 0644]

index eefa1e76dbcd0d39bde05caa30f976f3c7711775..a0d2b0674921d0894493ea770febd891bf5cfd7e 100644 (file)
@@ -1,3 +1,9 @@
+2004-03-09  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/14397
+       * call.c (convert_like_real): Build a const qualified temporary,
+       when testing ctor access.
+
 2004-03-09  Mark Mitchell  <mark@codesourcery.com>
 
        * call.c (initialize_reference): Fix typo.
index b43efcdae3f6ba1521bd3d638a075953af14ebef..320159ba9e7f8e8d8f50bde221c87aff45beeaa0 100644 (file)
@@ -4209,9 +4209,10 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
       if (convs->check_copy_constructor_p)
        /* Generate a temporary copy purely to generate the required
           diagnostics.  */
-       build_temp (build_dummy_object (totype), totype, 
-                   LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING,
-                   &diagnostic_fn);
+       build_temp
+         (build_dummy_object
+          (build_qualified_type (totype, TYPE_QUAL_CONST)),
+          totype, LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING, &diagnostic_fn);
        return expr;
     case ck_ambig:
       /* Call build_user_type_conversion again for the error.  */
index bf41ef5900f1de8e369b407de169f7ac487c377c..6f61dd7e5e0eedc6832307c8112ba88ed24fb763 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-09  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/14397
+       * g++.dg/overload/ref1.C: New.
+
 2004-03-09  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
        PR c++/14409
diff --git a/gcc/testsuite/g++.dg/overload/ref1.C b/gcc/testsuite/g++.dg/overload/ref1.C
new file mode 100644 (file)
index 0000000..e239d88
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright (C) 2004 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 5 Mar 2004 <nathan@codesourcery.com>
+
+// Origin: schmid@snake.iap.physik.tu-darmstadt.de
+// Bug 14397: Bogus access error.
+
+struct S { 
+    S (int); 
+    S(S const&); 
+  private: 
+    S(S&); 
+}; 
+S foo() 
+{ 
+  int result = 0;
+  
+  S s ((0,S (result)));
+  
+  return S (result); 
+}