gcc-patches@gcc.gnu.org
[Top] [All Lists]

Re: [PATCH] Fix PR c++/28284: ICE with invalid static const variable

Subject: Re: [PATCH] Fix PR c++/28284: ICE with invalid static const variable
From: Simon Martin
Date: Sun, 27 Aug 2006 14:51:21 +0200
Hi again.

> > I'd prefer to check for NULL in fold_non_dependent_expr, rather than in
> > the caller.
>
> Here's the revised patch, bootstrapped and regtested on i686-pc-linux-gnu.
> Could you please apply it if it is OK?
I've just figured out that the testcase I provided with a "cpp" extension was 
not taken into account when regtesting. I've therefore changed the extension 
to "C", which fixes the problem. Here's the (hopefully) final version of this 
patch.

Sorry for the inconvenience.

Best regards,
Simon
2006-08-27  Simon Martin  <simartin@xxxxxxxxxxxxxxxxxxxxx>

        PR c++/28284
        * pt.c (fold_non_dependent_expr): Make sure expr is not dereferenced if 
it
        is NULL.
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c (revision 116469)
+++ 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-08-27  Simon Martin  <simartin@xxxxxxxxxxxxxxxxxxxxx>

        PR c++/28284
        * g++.dg/template/pr28284.C: New test.
/* { 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;
<Prev in Thread] Current Thread [Next in Thread>