diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-10-05 21:03:28 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-10-05 21:03:28 +0200 |
commit | 875825211ba723311fa12b2c8aaa7c808bfa972f (patch) | |
tree | ee83b0609b3dd177b1acb9736c0be5f27ba694f6 /gcc/ubsan.c | |
parent | 8b7033e0e1d10099b5c531a9a3b960fded60e24c (diff) | |
download | gcc-875825211ba723311fa12b2c8aaa7c808bfa972f.zip gcc-875825211ba723311fa12b2c8aaa7c808bfa972f.tar.gz gcc-875825211ba723311fa12b2c8aaa7c808bfa972f.tar.bz2 |
re PR sanitizer/66343 ("Error: .Lubsan_type3 already defined" with UBSan and precompiled headers)
PR sanitizer/66343
* ubsan.c (ubsan_ids): New GTY(()) array.
(ubsan_type_descriptor, ubsan_create_data): Use ubsan_ids
instead of static local counters.
* gcc.dg/pch/pr66343-1.c: New test.
* gcc.dg/pch/pr66343-1.hs: New file.
* gcc.dg/pch/pr66343-2.c: New test.
* gcc.dg/pch/pr66343-2.hs: New file.
From-SVN: r240803
Diffstat (limited to 'gcc/ubsan.c')
-rw-r--r-- | gcc/ubsan.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/gcc/ubsan.c b/gcc/ubsan.c index d3bd8e3..059c6aa 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -314,6 +314,10 @@ get_ubsan_type_info_for_type (tree type) return 0; } +/* Counters for internal labels. ubsan_ids[0] for Lubsan_type, + ubsan_ids[1] for Lubsan_data labels. */ +static GTY(()) unsigned int ubsan_ids[2]; + /* Helper routine that returns ADDR_EXPR of a VAR_DECL of a type descriptor. It first looks into the hash table; if not found, create the VAR_DECL, put it into the hash table and return the @@ -461,10 +465,9 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style pstyle) TREE_STATIC (str) = 1; char tmp_name[32]; - static unsigned int type_var_id_num; - ASM_GENERATE_INTERNAL_LABEL (tmp_name, "Lubsan_type", type_var_id_num++); + ASM_GENERATE_INTERNAL_LABEL (tmp_name, "Lubsan_type", ubsan_ids[0]++); decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (tmp_name), - dtype); + dtype); TREE_STATIC (decl) = 1; TREE_PUBLIC (decl) = 0; DECL_ARTIFICIAL (decl) = 1; @@ -564,8 +567,7 @@ ubsan_create_data (const char *name, int loccnt, const location_t *ploc, ...) /* Now, fill in the type. */ char tmp_name[32]; - static unsigned int ubsan_var_id_num; - ASM_GENERATE_INTERNAL_LABEL (tmp_name, "Lubsan_data", ubsan_var_id_num++); + ASM_GENERATE_INTERNAL_LABEL (tmp_name, "Lubsan_data", ubsan_ids[1]++); tree var = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (tmp_name), ret); TREE_STATIC (var) = 1; |