OSDN Git Service

PR c++/33501
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Nov 2007 19:27:27 +0000 (19:27 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Nov 2007 19:27:27 +0000 (19:27 +0000)
* call.c (build_over_call): Don't check TREE_ADDRESSABLE
on incomplete type.

* g++.dg/warn/incomplete2.C: New test.
* g++.dg/template/incomplete4.C: New test.
* g++.dg/template/incomplete5.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/incomplete4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/incomplete5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/incomplete2.C [new file with mode: 0644]

index 96d2dd7..d62d29d 100644 (file)
@@ -1,3 +1,9 @@
+2007-11-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/33501
+       * call.c (build_over_call): Don't check TREE_ADDRESSABLE
+       on incomplete type.
+
 2007-11-06  Douglas Gregor  <doug.gregor@gmail.com>
 
        PR c++/33977
index e9d3a94..50ff8b5 100644 (file)
@@ -4993,7 +4993,8 @@ build_over_call (struct z_candidate *cand, int flags)
 
       /* Don't make a copy here if build_call is going to.  */
       if (conv->kind == ck_rvalue
-         && !TREE_ADDRESSABLE (complete_type (type)))
+         && COMPLETE_TYPE_P (complete_type (type))
+         && !TREE_ADDRESSABLE (type))
        conv = conv->u.next;
 
       val = convert_like_with_context
index 62d9b25..74a7e3b 100644 (file)
@@ -1,3 +1,10 @@
+2007-11-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/33501
+       * g++.dg/warn/incomplete2.C: New test.
+       * g++.dg/template/incomplete4.C: New test.
+       * g++.dg/template/incomplete5.C: New test.
+
 2007-11-07  Olivier Hainque  <hainque@adacore.com>
 
        * gnat.dg/max_align.adb: New test.
diff --git a/gcc/testsuite/g++.dg/template/incomplete4.C b/gcc/testsuite/g++.dg/template/incomplete4.C
new file mode 100644 (file)
index 0000000..6129e0d
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/33501
+// { dg-do compile }
+
+class A;       // { dg-error "forward declaration" }
+
+template <typename T> struct X
+{
+  static int f (T);
+  static const T &make ();
+};
+
+int
+main ()
+{
+  return X<A>::f (X<A>::make ());      // { dg-error "invalid use of incomplete type|initializing argument" }
+}
diff --git a/gcc/testsuite/g++.dg/template/incomplete5.C b/gcc/testsuite/g++.dg/template/incomplete5.C
new file mode 100644 (file)
index 0000000..9641003
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/33501
+// { dg-do compile }
+
+class A;       // { dg-error "forward declaration" }
+
+template <typename T> struct X
+{
+  static int f (T);
+  static const T &make ();
+  static const bool value = sizeof (f (make ())) == sizeof (int);      // { dg-error "invalid use of incomplete type|initializing argument" }
+};
+
+int
+main ()
+{
+  return X <A>::value;
+}
diff --git a/gcc/testsuite/g++.dg/warn/incomplete2.C b/gcc/testsuite/g++.dg/warn/incomplete2.C
new file mode 100644 (file)
index 0000000..9fdfcba
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/33501
+// { dg-do compile }
+
+class A;       // { dg-error "forward declaration" }
+
+int f (A);
+const A &make ();
+
+int
+main ()
+{
+  return f (make ());  // { dg-error "invalid use of incomplete type|initializing argument" }
+}