aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-11-04 22:29:35 +0000
committerJason Merrill <jason@redhat.com>2009-11-04 22:29:35 +0000
commit29c55a1f15aefdec349617695afd7a3b640b482a (patch)
treedfb6623ce109741f4ca6acf4db63280aef6ca777
parent2c8c3654069d03a48e39ddc05e9a2b945ee15202 (diff)
PR c++/39413
* search.c (lookup_base): Don't complete_type (base). git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@153920 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/search.c6
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/template/nested3.C7
-rw-r--r--gcc/testsuite/g++.dg/template/overload11.C27
5 files changed, 43 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 82104d280b5..edf3ca86a96 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2009-11-04 Jason Merrill <jason@redhat.com>
+ PR c++/39413
+ * search.c (lookup_base): Don't complete_type (base).
+
PR c++/35067
* method.c (use_thunk): Check DECL_WEAK as well as
DECL_ONE_ONLY.
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index d6521fb6f82..356f3d6f52b 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -214,9 +214,11 @@ lookup_base (tree t, tree base, base_access access, base_kind *kind_ptr)
t_binfo = TYPE_BINFO (t);
}
- base = complete_type (TYPE_MAIN_VARIANT (base));
+ base = TYPE_MAIN_VARIANT (base);
- if (t_binfo)
+ /* If BASE is incomplete, it can't be a base of T--and instantiating it
+ might cause an error. */
+ if (t_binfo && (COMPLETE_TYPE_P (base) || TYPE_BEING_DEFINED (base)))
{
struct lookup_base_data_s data;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5f63688f2fc..61f8450e081 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2009-11-04 Jason Merrill <jason@redhat.com>
+
+ PR c++/39413
+ * g++.dg/template/overload11.C: New.
+ * g++.dg/template/nested3.C: Adjust.
+
2009-11-04 Eric Botcazou <ebotcazou@adacore.com>
PR ada/20548
diff --git a/gcc/testsuite/g++.dg/template/nested3.C b/gcc/testsuite/g++.dg/template/nested3.C
index 1ae4bf7647d..5652e178a70 100644
--- a/gcc/testsuite/g++.dg/template/nested3.C
+++ b/gcc/testsuite/g++.dg/template/nested3.C
@@ -5,13 +5,13 @@ class A {
int _k;
};
T1 _t1;
- T2 _t2; // { dg-message "instantiated" }
+ T2 _t2;
};
template <class U>
-class B { // { dg-error "declaration" }
+class B {
class SubB1 {
- B _i; // { dg-error "incomplete type" }
+ B _i;
};
class SubB2 {
@@ -19,7 +19,6 @@ class B { // { dg-error "declaration" }
};
A<U,SubB1>::SubA<SubB2> _a; // { dg-error "not a base type" "not base" }
// { dg-message "note" "note" { target *-*-* } 20 }
- // { dg-message "instantiated" "inst" { target *-*-* } 20 }
// { dg-error "non-template" "non-template" { target *-*-* } 20 }
};
diff --git a/gcc/testsuite/g++.dg/template/overload11.C b/gcc/testsuite/g++.dg/template/overload11.C
new file mode 100644
index 00000000000..d7b0a7c9f1c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/overload11.C
@@ -0,0 +1,27 @@
+// PR c++/39413
+// We don't need to instantiate Wrapper<int> to check the
+// foo(const Thingy&) overload.
+
+template <class T> struct Incomplete;
+
+template <typename T> class Wrapper
+{
+ Incomplete<T> i;
+};
+
+template <typename T> struct Thingy
+{
+ Thingy();
+ Thingy(const Wrapper<T>& v);
+
+ template <typename X> void foo(const Thingy<X>&);
+ void foo(const Thingy&);
+};
+
+int main()
+{
+ Thingy<int> ap1;
+ Thingy<float> bp1;
+
+ ap1.foo(bp1);
+}