]> gcc.gnu.org Git - gcc.git/commitdiff
PR c/69911 Check main_input_filename and DECL_SOURCE_FILE are not NULL.
authorMark Wielaard <mjw@redhat.com>
Tue, 23 Feb 2016 11:47:19 +0000 (11:47 +0000)
committerMark Wielaard <mark@gcc.gnu.org>
Tue, 23 Feb 2016 11:47:19 +0000 (11:47 +0000)
DECL_SOURCE_FILE can be NULL (for example when DECL_ARTIFICIAL).
So make sure to check before comparing against main_input_filename.

gcc/ChangeLog

PR c/69911
* cgraphunit.c (check_global_declaration): Check main_input_filename
and DECL_SOURCE_FILE are not NULL.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r233627

gcc/ChangeLog
gcc/cgraphunit.c

index e416c463c34a78409490caf23e293281a2cc9f33..2c77b39666d31ddc1c903fb77f62a5bafb01071c 100644 (file)
@@ -1,3 +1,10 @@
+2016-02-23  Mark Wielaard  <mjw@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/69911
+       * cgraphunit.c (check_global_declaration): Check main_input_filename
+       and DECL_SOURCE_FILE are not NULL.
+
 2016-02-23  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/69666
index 27a073a63be1df1f1a6cd7245f7c95de584d1f04..8b3fddc435ebb2b18306066ca88e718099f0cf76 100644 (file)
@@ -917,6 +917,7 @@ walk_polymorphic_call_targets (hash_set<void *> *reachable_call_targets,
 static void
 check_global_declaration (symtab_node *snode)
 {
+  const char *decl_file;
   tree decl = snode->decl;
 
   /* Warn about any function declared static but not defined.  We don't
@@ -944,8 +945,10 @@ check_global_declaration (symtab_node *snode)
        || (((warn_unused_variable && ! TREE_READONLY (decl))
            || (warn_unused_const_variable > 0 && TREE_READONLY (decl)
                && (warn_unused_const_variable == 2
-                   || filename_cmp (main_input_filename,
-                                    DECL_SOURCE_FILE (decl)) == 0)))
+                   || (main_input_filename != NULL
+                       && (decl_file = DECL_SOURCE_FILE (decl)) != NULL
+                       && filename_cmp (main_input_filename,
+                                        decl_file) == 0))))
           && TREE_CODE (decl) == VAR_DECL))
       && ! DECL_IN_SYSTEM_HEADER (decl)
       && ! snode->referred_to_p (/*include_self=*/false)
This page took 0.076891 seconds and 5 git commands to generate.