genattrtab: avoid NULL-deref on error
authorJim Meyering <meyering@redhat.com>
Tue, 24 Apr 2012 12:07:30 +0000 (12:07 +0000)
committerJim Meyering <meyering@gcc.gnu.org>
Tue, 24 Apr 2012 12:07:30 +0000 (12:07 +0000)
* genattrtab.c (gen_attr): Avoid NULL-deref after diagnosing
absence of an define_enum call.

From-SVN: r186761

gcc/ChangeLog
gcc/genattrtab.c

index f02bf71..fb6aea6 100644 (file)
@@ -1,3 +1,8 @@
+2012-02-24  Jim Meyering  <meyering@redhat.com>
+
+       * genattrtab.c (gen_attr): Avoid NULL-deref after diagnosing
+       absence of an define_enum call.
+
 2012-04-24  Richard Guenther  <rguenther@suse.de>
 
        * tree-vect-loop-manip.c (vect_do_peeling_for_loop_bound): If
index 4a4c2a2..bfbe3e8 100644 (file)
@@ -1,6 +1,6 @@
 /* Generate code from machine description to compute values of attributes.
    Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012
    Free Software Foundation, Inc.
    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 
@@ -2993,8 +2993,9 @@ gen_attr (rtx exp, int lineno)
       if (!et || !et->md_p)
        error_with_line (lineno, "No define_enum called `%s' defined",
                         attr->name);
-      for (ev = et->values; ev; ev = ev->next)
-       add_attr_value (attr, ev->name);
+      if (et)
+       for (ev = et->values; ev; ev = ev->next)
+         add_attr_value (attr, ev->name);
     }
   else if (*XSTR (exp, 1) == '\0')
     attr->is_numeric = 1;