aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-08-19 20:16:01 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-08-19 20:16:01 +0000
commit717a7d5d006f2e88ba48e7d2984a70f7a9731412 (patch)
tree273fa4f96609c1b0301158a2d78367905e2451c1 /gcc
parent5815280853df205cee38d4d9226856e1dba00685 (diff)
downloadgcc-717a7d5d006f2e88ba48e7d2984a70f7a9731412.zip
gcc-717a7d5d006f2e88ba48e7d2984a70f7a9731412.tar.gz
gcc-717a7d5d006f2e88ba48e7d2984a70f7a9731412.tar.bz2
re PR c++/15890 (internal compiler error: in c_expand_expr, at c-common.c:4138)
PR c++/15890 * pt.c (push_template_decl_real): Disallow template allocation functions with fewer than two parameters. PR c++/15890 * g++.dg/template/delete1.C: New test. From-SVN: r86265
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c34
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/delete1.C14
4 files changed, 50 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 85d5038..5f63d12 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2004-08-19 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/15890
+ * pt.c (push_template_decl_real): Disallow template allocation
+ functions with fewer than two parameters.
+
2004-08-19 Nathan Sidwell <nathan@codesourcery.com>
* cp-tree.h (build_shared_int_cst): Remove.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f4e9362..34ea3a6 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -2875,19 +2875,35 @@ push_template_decl_real (tree decl, int is_friend)
else if (TREE_CODE (decl) == TYPE_DECL
&& ANON_AGGRNAME_P (DECL_NAME (decl)))
error ("template class without a name");
- else if (TREE_CODE (decl) == FUNCTION_DECL
- && DECL_DESTRUCTOR_P (decl))
+ else if (TREE_CODE (decl) == FUNCTION_DECL)
{
- /* [temp.mem]
-
- A destructor shall not be a member template. */
- error ("destructor `%D' declared as member template", decl);
- return error_mark_node;
+ if (DECL_DESTRUCTOR_P (decl))
+ {
+ /* [temp.mem]
+
+ A destructor shall not be a member template. */
+ error ("destructor `%D' declared as member template", decl);
+ return error_mark_node;
+ }
+ if (NEW_DELETE_OPNAME_P (DECL_NAME (decl))
+ && (!TYPE_ARG_TYPES (TREE_TYPE (decl))
+ || TYPE_ARG_TYPES (TREE_TYPE (decl)) == void_list_node
+ || !TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl)))
+ || (TREE_CHAIN (TYPE_ARG_TYPES ((TREE_TYPE (decl))))
+ == void_list_node)))
+ {
+ /* [basic.stc.dynamic.allocation]
+
+ An allocation function can be a function
+ template. ... Template allocation functions shall
+ have two or more parameters. */
+ error ("invalid template declaration of `%D'", decl);
+ return decl;
+ }
}
else if ((DECL_IMPLICIT_TYPEDEF_P (decl)
&& CLASS_TYPE_P (TREE_TYPE (decl)))
- || (TREE_CODE (decl) == VAR_DECL && ctx && CLASS_TYPE_P (ctx))
- || TREE_CODE (decl) == FUNCTION_DECL)
+ || (TREE_CODE (decl) == VAR_DECL && ctx && CLASS_TYPE_P (ctx)))
/* OK */;
else
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f4acb93..7e639c1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-08-19 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/15890
+ * g++.dg/template/delete1.C: New test.
+
2004-08-19 Paul Brook <paul@codesourcery.com>
PR fortran/14976
diff --git a/gcc/testsuite/g++.dg/template/delete1.C b/gcc/testsuite/g++.dg/template/delete1.C
new file mode 100644
index 0000000..fc53270
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/delete1.C
@@ -0,0 +1,14 @@
+// PR c++/15890
+
+template < typename T >
+void operator delete ( void* raw ) { // { dg-error "" }
+ delete raw;
+}
+
+class A { };
+
+int main() {
+ A* a = new A;
+ delete a;
+}
+