This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Backport fix for PR c++/28284 back to 4.1 branch
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: simartin at users dot sourceforge dot net, mark at codesourcery dot com
- Date: Fri, 01 Dec 2006 23:45:33 +0100 (CET)
- Subject: [patch] Backport fix for PR c++/28284 back to 4.1 branch
Mark's patch for PR 29106 ported the bug in PR 28284 to the 4.1 branch.
The following patch backports Siomon's fix for PR 28284 from
http://gcc.gnu.org/ml/gcc-patches/2006-08/msg00099.html
back to the 4.1 branch.
Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for 4.1 branch?
Regards,
Volker
:ADDPATCH C++:
2006-12-01 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
Backport:
2006-08-27 Simon Martin <simartin@users.sourceforge.net>
PR c++/28284
* pt.c (fold_non_dependent_expr): Make sure expr is not dereferenced if it
is NULL.
===================================================================
--- gcc/gcc/cp/pt.c (revision 116469)
+++ gcc/gcc/cp/pt.c (working copy)
@@ -3387,6 +3387,9 @@ redeclare_class_template (tree type, tre
tree
fold_non_dependent_expr (tree expr)
{
+ if (expr == NULL_TREE)
+ return NULL_TREE;
+
/* If we're in a template, but EXPR isn't value dependent, simplify
it. We're supposed to treat:
===================================================================
2006-12-01 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
Backport:
2006-08-27 Simon Martin <simartin@users.sourceforge.net>
PR c++/28284
* g++.dg/template/pr28284.C: New test.
===================================================================
--- gcc/gcc/testsuite/g++.dg/template/pr28284.C 2003-09-23 19:59:22 +0200
+++ gcc/gcc/testsuite/g++.dg/template/pr28284.C 2006-11-18 07:47:02 +0100
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+template<int> struct A
+{
+ static const int i=x; /* { dg-error "was not declared in this scope" } */
+ static const int j, k;
+};
+
+template<int N> const int A<N>::j = i;
+template<int N> const int A<N>::k = j;
+
+A<0> a;
===================================================================