aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-03-16 22:36:40 -0400
committerJason Merrill <jason@gcc.gnu.org>2013-03-16 22:36:40 -0400
commit95ffad49d5499e3de6fcd0d261fa3870755995c2 (patch)
treec57d8324a30e45c9cdcfa7208935e309709d9997
parent346928a2c9741ac4347b5b29551259a93bc30a7f (diff)
downloadgcc-95ffad49d5499e3de6fcd0d261fa3870755995c2.zip
gcc-95ffad49d5499e3de6fcd0d261fa3870755995c2.tar.gz
gcc-95ffad49d5499e3de6fcd0d261fa3870755995c2.tar.bz2
DR 337 PR c++/17232
DR 337 PR c++/17232 * pt.c (tsubst) [ARRAY_TYPE]: Use abstract_virtuals_error_sfinae. * typeck2.c (abstract_virtuals_error_sfinae): Call complete_type. From-SVN: r196734
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c10
-rw-r--r--gcc/cp/typeck2.c4
-rw-r--r--gcc/testsuite/g++.dg/template/abstract-dr337.C13
4 files changed, 25 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2f5f873..20414dc 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2013-03-16 Jason Merrill <jason@redhat.com>
+ DR 337
+ PR c++/17232
+ * pt.c (tsubst) [ARRAY_TYPE]: Use abstract_virtuals_error_sfinae.
+ * typeck2.c (abstract_virtuals_error_sfinae): Call complete_type.
+
DR 657
* pt.c (tsubst_function_type): Call abstract_virtuals_error_sfinae.
(tsubst_arg_types): Likewise.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index cad1c60..ce07fa4 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11653,13 +11653,9 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
error ("creating array of %qT", type);
return error_mark_node;
}
- if (ABSTRACT_CLASS_TYPE_P (type))
- {
- if (complain & tf_error)
- error ("creating array of %qT, which is an abstract class type",
- type);
- return error_mark_node;
- }
+
+ if (abstract_virtuals_error_sfinae (NULL_TREE, type, complain))
+ return error_mark_node;
r = build_cplus_array_type (type, domain);
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index d227a82..dc17776 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -258,6 +258,10 @@ abstract_virtuals_error_sfinae (tree decl, tree type, tsubst_flags_t complain)
return 0;
type = TYPE_MAIN_VARIANT (type);
+ /* In SFINAE context, force instantiation. */
+ if (!(complain & tf_error))
+ complete_type (type);
+
/* If the type is incomplete, we register it within a hash table,
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
diff --git a/gcc/testsuite/g++.dg/template/abstract-dr337.C b/gcc/testsuite/g++.dg/template/abstract-dr337.C
new file mode 100644
index 0000000..de84f90
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/abstract-dr337.C
@@ -0,0 +1,13 @@
+// PR c++/17232 (DR 337)
+
+template<typename T>
+class A {
+ virtual void f() = 0;
+};
+
+template<typename T>
+void g(T (*a)[1]) {} // { dg-error "abstract" }
+
+int main() {
+ g<A<int> >(0); // { dg-error "no matching function" }
+}