diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc index 5ca333a9ed6..56d60768749 100644 --- a/gcc/analyzer/region-model-manager.cc +++ b/gcc/analyzer/region-model-manager.cc @@ -1770,6 +1770,13 @@ dump_untracked_region (const decl_region *decl_reg) tree decl = decl_reg->get_decl (); if (TREE_CODE (decl) != VAR_DECL) return; + /* For now, don't emit the status of decls in the constant pool, to avoid + differences in DejaGnu test results between targets that use these vs + those that don't. + (Eventually these decls should probably be untracked and we should test + for that, but that's not stage 4 material). */ + if (DECL_IN_CONSTANT_POOL (decl)) + return; warning_at (DECL_SOURCE_LOCATION (decl), 0, "track %qD: %s", decl, (decl_reg->tracked_p () ? "yes" : "no")); diff --git a/gcc/testsuite/gcc.dg/analyzer/untracked-1.c b/gcc/testsuite/gcc.dg/analyzer/untracked-1.c index d07c2975670..9f3a639db5c 100644 --- a/gcc/testsuite/gcc.dg/analyzer/untracked-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/untracked-1.c @@ -1,5 +1,7 @@ /* { dg-additional-options "-fdump-analyzer-untracked" } */ +#include "analyzer-decls.h" + struct st { const char *m_filename; @@ -39,6 +41,16 @@ void test_3 (void) extern_fn (&s3); } +void test_3a (void) +{ + struct st s3a = { "foo.c", 42 }; /* { dg-warning "track 's3a': yes" } */ + __analyzer_eval (s3a.m_filename[0] == 'f'); /* { dg-warning "TRUE" } */ + __analyzer_eval (s3a.m_line == 42); /* { dg-warning "TRUE" } */ + extern_fn (&s3a); + __analyzer_eval (s3a.m_filename[0] == 'f'); /* { dg-warning "UNKNOWN" } */ + __analyzer_eval (s3a.m_line == 42); /* { dg-warning "UNKNOWN" } */ +} + extern void called_by_test_4 (int *); int test_4 (void) @@ -103,3 +115,17 @@ void test_13 (void) { extern_fn_char_ptr (__func__); /* { dg-warning "track '__func__': no" } */ } + +char t14_global_unused[100]; /* { dg-warning "track 't14_global_unused': yes" } */ +static char t14_static_unused[100]; /* { dg-warning "track 't14_static_unused': yes" } */ +char t14_global_used[100]; /* { dg-warning "track 't14_global_used': yes" } */ +static char t14_static_used[100]; /* { dg-warning "track 't14_static_used': yes" } */ +void test_14 (void) +{ + extern_fn_char_ptr (t14_global_unused); + extern_fn_char_ptr (t14_static_unused); + extern_fn_char_ptr (t14_global_used); + __analyzer_eval (t14_global_used[0] == '\0'); /* { dg-warning "UNKNOWN" } */ + extern_fn_char_ptr (t14_static_used); + __analyzer_eval (t14_static_used[0] == '\0'); /* { dg-warning "UNKNOWN" } */ +}