re PR sanitizer/60535 (Link failure with -flto and -fsanitize=undefined)

PR sanitizer/60535
	* ubsan.c (ubsan_type_descriptor, ubsan_create_data): Call
	varpool_finalize_decl instead of rest_of_decl_compilation.
lto/
	* lto-lang.c (lto_init): Add NAME_TYPE for int128_integer_type_node
	and complex_{float,{,long_}double}_type_node.
testsuite/
	* c-c++-common/ubsan/null-1.c: Don't skip if -flto.
	* c-c++-common/ubsan/null-2.c: Likewise.
	* c-c++-common/ubsan/null-3.c: Likewise.
	* c-c++-common/ubsan/null-4.c: Likewise.
	* c-c++-common/ubsan/null-5.c: Likewise.
	* c-c++-common/ubsan/null-6.c: Likewise.
	* c-c++-common/ubsan/null-7.c: Likewise.
	* c-c++-common/ubsan/null-8.c: Likewise.
	* c-c++-common/ubsan/null-9.c: Likewise.
	* c-c++-common/ubsan/null-10.c: Likewise.
	* c-c++-common/ubsan/null-11.c: Likewise.
	* c-c++-common/ubsan/overflow-1.c: Likewise.
	* c-c++-common/ubsan/overflow-2.c: Likewise.
	* c-c++-common/ubsan/overflow-add-1.c: Likewise.
	* c-c++-common/ubsan/overflow-add-2.c: Likewise.
	* c-c++-common/ubsan/overflow-int128.c: Likewise.
	* c-c++-common/ubsan/overflow-mul-1.c: Likewise.
	* c-c++-common/ubsan/overflow-mul-2.c: Likewise.
	* c-c++-common/ubsan/overflow-mul-3.c: Likewise.
	* c-c++-common/ubsan/overflow-mul-4.c: Likewise.
	* c-c++-common/ubsan/overflow-negate-1.c: Likewise.
	* c-c++-common/ubsan/overflow-negate-2.c: Likewise.
	* c-c++-common/ubsan/overflow-sub-1.c: Likewise.
	* c-c++-common/ubsan/overflow-sub-2.c: Likewise.
	* c-c++-common/ubsan/pr59333.c: Likewise.
	* c-c++-common/ubsan/pr59503.c: Likewise.
	* c-c++-common/ubsan/pr59667.c: Likewise.
	* c-c++-common/ubsan/undefined-1.c: Likewise.
	* g++.dg/ubsan/pr59250.C: Likewise.
	* g++.dg/ubsan/pr59306.C: Likewise.

From-SVN: r208651
This commit is contained in:
Jakub Jelinek 2014-03-18 15:56:23 +01:00
parent 4ca40f5284
commit 415e2e6b2c
35 changed files with 56 additions and 34 deletions

View File

@ -1,3 +1,9 @@
2014-03-18 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/60535
* ubsan.c (ubsan_type_descriptor, ubsan_create_data): Call
varpool_finalize_decl instead of rest_of_decl_compilation.
2014-03-18 Richard Biener <rguenther@suse.de> 2014-03-18 Richard Biener <rguenther@suse.de>
* df-problems.c (df_rd_confluence_n): Avoid bitmap_copy * df-problems.c (df_rd_confluence_n): Avoid bitmap_copy

View File

@ -1,7 +1,13 @@
2014-03-18 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/60535
* lto-lang.c (lto_init): Add NAME_TYPE for int128_integer_type_node
and complex_{float,{,long_}double}_type_node.
2014-03-08 Paulo Matos <paulo@matos-sorge.com> 2014-03-08 Paulo Matos <paulo@matos-sorge.com>
* lto-lang.c (lto_init): Pass flag_short_double to * lto-lang.c (lto_init): Pass flag_short_double to
build_common_tree_nodes. build_common_tree_nodes.
2014-02-14 Jan Hubicka <hubicka@ucw.cz> 2014-02-14 Jan Hubicka <hubicka@ucw.cz>

View File

@ -1222,6 +1222,11 @@ lto_init (void)
NAME_TYPE (long_double_type_node, "long double"); NAME_TYPE (long_double_type_node, "long double");
NAME_TYPE (void_type_node, "void"); NAME_TYPE (void_type_node, "void");
NAME_TYPE (boolean_type_node, "bool"); NAME_TYPE (boolean_type_node, "bool");
NAME_TYPE (complex_float_type_node, "complex float");
NAME_TYPE (complex_double_type_node, "complex double");
NAME_TYPE (complex_long_double_type_node, "complex long double");
if (int128_integer_type_node)
NAME_TYPE (int128_integer_type_node, "__int128");
#undef NAME_TYPE #undef NAME_TYPE
/* Initialize LTO-specific data structures. */ /* Initialize LTO-specific data structures. */

View File

@ -1,3 +1,37 @@
2014-03-18 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/60535
* c-c++-common/ubsan/null-1.c: Don't skip if -flto.
* c-c++-common/ubsan/null-2.c: Likewise.
* c-c++-common/ubsan/null-3.c: Likewise.
* c-c++-common/ubsan/null-4.c: Likewise.
* c-c++-common/ubsan/null-5.c: Likewise.
* c-c++-common/ubsan/null-6.c: Likewise.
* c-c++-common/ubsan/null-7.c: Likewise.
* c-c++-common/ubsan/null-8.c: Likewise.
* c-c++-common/ubsan/null-9.c: Likewise.
* c-c++-common/ubsan/null-10.c: Likewise.
* c-c++-common/ubsan/null-11.c: Likewise.
* c-c++-common/ubsan/overflow-1.c: Likewise.
* c-c++-common/ubsan/overflow-2.c: Likewise.
* c-c++-common/ubsan/overflow-add-1.c: Likewise.
* c-c++-common/ubsan/overflow-add-2.c: Likewise.
* c-c++-common/ubsan/overflow-int128.c: Likewise.
* c-c++-common/ubsan/overflow-mul-1.c: Likewise.
* c-c++-common/ubsan/overflow-mul-2.c: Likewise.
* c-c++-common/ubsan/overflow-mul-3.c: Likewise.
* c-c++-common/ubsan/overflow-mul-4.c: Likewise.
* c-c++-common/ubsan/overflow-negate-1.c: Likewise.
* c-c++-common/ubsan/overflow-negate-2.c: Likewise.
* c-c++-common/ubsan/overflow-sub-1.c: Likewise.
* c-c++-common/ubsan/overflow-sub-2.c: Likewise.
* c-c++-common/ubsan/pr59333.c: Likewise.
* c-c++-common/ubsan/pr59503.c: Likewise.
* c-c++-common/ubsan/pr59667.c: Likewise.
* c-c++-common/ubsan/undefined-1.c: Likewise.
* g++.dg/ubsan/pr59250.C: Likewise.
* g++.dg/ubsan/pr59306.C: Likewise.
2014-03-18 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2014-03-18 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.dg/tls/pr58595.c: Add tls options. * gcc.dg/tls/pr58595.c: Add tls options.

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=null -w" } */ /* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
int int
main (void) main (void)

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=null -w" } */ /* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
int int
main (void) main (void)

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=null -w" } */ /* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
struct S { struct S {
int i; int i;

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=null -w" } */ /* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
int int
main (void) main (void)

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=null -w" } */ /* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
int int
foo (int *p) foo (int *p)

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=null -w" } */ /* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
int int
main (void) main (void)

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=null -w" } */ /* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
typedef volatile const _Complex float *T; typedef volatile const _Complex float *T;

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=null -w" } */ /* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
int int
main (void) main (void)

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=null -w" } */ /* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
int * int *
gao (void) gao (void)

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=null -w" } */ /* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
struct S { struct S {
int i; int i;

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=null -w" } */ /* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
union U { union U {
int i; int i;

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow" } */ /* { dg-options "-fsanitize=signed-integer-overflow" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
#ifndef ASM1 #ifndef ASM1
# define ASM1(a) /* Nothing */ # define ASM1(a) /* Nothing */

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow" } */ /* { dg-options "-fsanitize=signed-integer-overflow" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
#define ASM1(a) asm volatile ("" : "+g" (a)) #define ASM1(a) asm volatile ("" : "+g" (a))
#define ASM2(a, b) asm volatile ("" : "+g" (a), "+g" (b)) #define ASM2(a, b) asm volatile ("" : "+g" (a), "+g" (b))

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */ /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
#define SCHAR_MAX __SCHAR_MAX__ #define SCHAR_MAX __SCHAR_MAX__
#define SHRT_MAX __SHRT_MAX__ #define SHRT_MAX __SHRT_MAX__

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */ /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
#define INT_MAX __INT_MAX__ #define INT_MAX __INT_MAX__
#define INT_MIN (-__INT_MAX__ - 1) #define INT_MIN (-__INT_MAX__ - 1)

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-require-effective-target int128 } */ /* { dg-require-effective-target int128 } */
/* { dg-options "-fsanitize=signed-integer-overflow" } */ /* { dg-options "-fsanitize=signed-integer-overflow" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
/* 2^127 - 1 */ /* 2^127 - 1 */
#define INT128_MAX (__int128) (((unsigned __int128) 1 << ((__SIZEOF_INT128__ * __CHAR_BIT__) - 1)) - 1) #define INT128_MAX (__int128) (((unsigned __int128) 1 << ((__SIZEOF_INT128__ * __CHAR_BIT__) - 1)) - 1)

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */ /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
#define SCHAR_MAX __SCHAR_MAX__ #define SCHAR_MAX __SCHAR_MAX__
#define SHRT_MAX __SHRT_MAX__ #define SHRT_MAX __SHRT_MAX__

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */ /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
#define INT_MAX __INT_MAX__ #define INT_MAX __INT_MAX__
#define LONG_MAX __LONG_MAX__ #define LONG_MAX __LONG_MAX__

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow" } */ /* { dg-options "-fsanitize=signed-integer-overflow" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
__attribute__((noinline, noclone)) long long __attribute__((noinline, noclone)) long long
mul (long long x, long long y) mul (long long x, long long y)

View File

@ -1,6 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow" } */ /* { dg-options "-fsanitize=signed-integer-overflow" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
int int
main () main ()

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */ /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
#define INT_MIN (-__INT_MAX__ - 1) #define INT_MIN (-__INT_MAX__ - 1)
#define LONG_MIN (-__LONG_MAX__ - 1L) #define LONG_MIN (-__LONG_MAX__ - 1L)

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */ /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
#define SCHAR_MIN (-__SCHAR_MAX__ - 1) #define SCHAR_MIN (-__SCHAR_MAX__ - 1)
#define SHRT_MIN (-__SHRT_MAX__ - 1) #define SHRT_MIN (-__SHRT_MAX__ - 1)

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */ /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
#define SCHAR_MAX __SCHAR_MAX__ #define SCHAR_MAX __SCHAR_MAX__
#define SCHAR_MIN (-__SCHAR_MAX__ - 1) #define SCHAR_MIN (-__SCHAR_MAX__ - 1)

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */ /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
#define INT_MAX __INT_MAX__ #define INT_MAX __INT_MAX__
#define INT_MIN (-__INT_MAX__ - 1) #define INT_MIN (-__INT_MAX__ - 1)

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=undefined" } */ /* { dg-options "-fsanitize=undefined" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
long long int __attribute__ ((noinline, noclone)) long long int __attribute__ ((noinline, noclone))
foo (long long int i, long long int j) foo (long long int i, long long int j)

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow" } */ /* { dg-options "-fsanitize=signed-integer-overflow" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
int int
main (void) main (void)

View File

@ -1,7 +1,6 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=undefined" } */ /* { dg-options "-fsanitize=undefined" } */
/* { dg-shouldfail "ubsan" } */ /* { dg-shouldfail "ubsan" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
int int
main (void) main (void)

View File

@ -1,6 +1,5 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fsanitize=undefined" } */ /* { dg-options "-fsanitize=undefined" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
int int
foo (int x, int y) foo (int x, int y)

View File

@ -1,7 +1,6 @@
// PR sanitizer/59250 // PR sanitizer/59250
// { dg-do compile } // { dg-do compile }
// { dg-options "-fsanitize=undefined" } // { dg-options "-fsanitize=undefined" }
// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
struct E { struct E {
int i; int i;

View File

@ -1,6 +1,5 @@
// { dg-do compile } // { dg-do compile }
// { dg-options "-fsanitize=undefined" } // { dg-options "-fsanitize=undefined" }
// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
class A { class A {
void bar (void (A::*) (int)); void bar (void (A::*) (int));

View File

@ -390,7 +390,7 @@ ubsan_type_descriptor (tree type, bool want_pointer_type_p)
TREE_CONSTANT (ctor) = 1; TREE_CONSTANT (ctor) = 1;
TREE_STATIC (ctor) = 1; TREE_STATIC (ctor) = 1;
DECL_INITIAL (decl) = ctor; DECL_INITIAL (decl) = ctor;
rest_of_decl_compilation (decl, 1, 0); varpool_finalize_decl (decl);
/* Save the VAR_DECL into the hash table. */ /* Save the VAR_DECL into the hash table. */
decl_for_type_insert (type, decl); decl_for_type_insert (type, decl);
@ -501,7 +501,7 @@ ubsan_create_data (const char *name, location_t loc,
TREE_CONSTANT (ctor) = 1; TREE_CONSTANT (ctor) = 1;
TREE_STATIC (ctor) = 1; TREE_STATIC (ctor) = 1;
DECL_INITIAL (var) = ctor; DECL_INITIAL (var) = ctor;
rest_of_decl_compilation (var, 1, 0); varpool_finalize_decl (var);
return var; return var;
} }