aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-03-08 12:30:36 -0500
committerJason Merrill <jason@gcc.gnu.org>2011-03-08 12:30:36 -0500
commit8c0672ff889f51799324cc4cb2a3f1b396768349 (patch)
tree16319377a1173742eb76ee4f4aade53817cf57db /gcc
parent2c86a82aa431b1fc370290103a95c67bc8602473 (diff)
downloadgcc-8c0672ff889f51799324cc4cb2a3f1b396768349.zip
gcc-8c0672ff889f51799324cc4cb2a3f1b396768349.tar.gz
gcc-8c0672ff889f51799324cc4cb2a3f1b396768349.tar.bz2
re PR c++/47705 (internal compiler error: in convert_nontype_argument, at cp/pt.c:5006)
PR c++/47705 * pt.c (convert_nontype_argument): Don't crash on non-pointer argument to pointer parameter. From-SVN: r170782
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c23
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/g++.dg/template/nontype21.C7
4 files changed, 27 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 319bdf3..e99a53a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2011-03-08 Jason Merrill <jason@redhat.com>
+ PR c++/47705
+ * pt.c (convert_nontype_argument): Don't crash on non-pointer
+ argument to pointer parameter.
+
PR c++/45651
* pt.c (instantiate_decl): Don't clear DECL_INTERFACE_KNOWN on
!TREE_PUBLIC decls.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 48f9382..cda9df8 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5369,15 +5369,20 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
qualification conversion. Let's strip everything. */
else if (TYPE_PTROBV_P (type))
{
- STRIP_NOPS (expr);
- gcc_assert (TREE_CODE (expr) == ADDR_EXPR);
- gcc_assert (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE);
- /* Skip the ADDR_EXPR only if it is part of the decay for
- an array. Otherwise, it is part of the original argument
- in the source code. */
- if (TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == ARRAY_TYPE)
- expr = TREE_OPERAND (expr, 0);
- expr_type = TREE_TYPE (expr);
+ tree sub = expr;
+ STRIP_NOPS (sub);
+ if (TREE_CODE (sub) == ADDR_EXPR)
+ {
+ gcc_assert (TREE_CODE (TREE_TYPE (sub)) == POINTER_TYPE);
+ /* Skip the ADDR_EXPR only if it is part of the decay for
+ an array. Otherwise, it is part of the original argument
+ in the source code. */
+ if (TREE_CODE (TREE_TYPE (TREE_OPERAND (sub, 0))) == ARRAY_TYPE)
+ expr = TREE_OPERAND (sub, 0);
+ else
+ expr = sub;
+ expr_type = TREE_TYPE (expr);
+ }
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 28caa91..bfc0e9d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,7 @@
2011-03-08 Jason Merrill <jason@redhat.com>
+ * g++.dg/template/nontype21.C: New.
+
* g++.dg/template/anon5.C: New.
2011-03-08 Jakub Jelinek <jakub@redhat.com>
diff --git a/gcc/testsuite/g++.dg/template/nontype21.C b/gcc/testsuite/g++.dg/template/nontype21.C
new file mode 100644
index 0000000..c0f5319
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/nontype21.C
@@ -0,0 +1,7 @@
+// PR c++/47705
+
+template<char const * const x> class Something { };
+
+extern char const xyz;
+
+class SomethingElse:public Something<xyz> { }; // { dg-error "const char *" }