Fallout from when I started checking for abstract classes as function
parameter types; if we see an incomplete type when we check for
abstractness, we save it to a list and check it again later when it's
complete. But we shouldn't do that in SFINAE context. This change is
already on the trunk, as part of a larger patch.
Tested x86_64-pc-linux-gnu, applying to 4.8.
commit 911dd30618250216d5eadca07b98a264d14f422f
Author: Jason Merrill <ja...@redhat.com>
Date: Mon Jul 29 16:52:53 2013 -0400
PR c++/58022
* typeck2.c (abstract_virtuals_error_sfinae): Don't remember
lookup in SFINAE context.
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 9b7db62..9c9f075 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -262,7 +262,7 @@ abstract_virtuals_error_sfinae (tree decl, tree type, tsubst_flags_t complain)
so that we can check again once it is completed. This makes sense
only for objects for which we have a declaration or at least a
name. */
- if (!COMPLETE_TYPE_P (type))
+ if (!COMPLETE_TYPE_P (type) && (complain & tf_error))
{
void **slot;
struct pending_abstract_type *pat;
diff --git a/gcc/testsuite/g++.dg/template/abstract1.C b/gcc/testsuite/g++.dg/template/abstract1.C
new file mode 100644
index 0000000..20bbf5a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/abstract1.C
@@ -0,0 +1,12 @@
+// PR c++/58022
+
+template <class T> struct A { };
+template <class T> A<T> & operator<< (A<T>&, T);
+template <class T> class foo;
+template <class T> A<char> & operator<<(A<char>& o, const foo<T>& l);
+template <class T> class foo {
+ friend A<char>& operator<< <T> (A<char>& o, const foo<T>& l);
+};
+class bar;
+foo<bar> fb;
+class bar { virtual void baz()=0; };