Message ID | 20150302185606.GC347@x4 |
---|---|
State | New |
Headers | show |
On 03/02/15 11:56, Markus Trippelsdorf wrote: > On 2015.03.02 at 18:53 +0100, Marek Polacek wrote: >> On Mon, Mar 02, 2015 at 06:22:49PM +0100, Markus Trippelsdorf wrote: >>> --- a/libcpp/lex.c >>> +++ b/libcpp/lex.c >>> @@ -519,6 +519,7 @@ init_vectorized_lexer (void) >>> and VSX unaligned loads (when VSX is available). This is otherwise >>> the same as the pre-GCC 5 version. */ >>> >>> +__attribute__ ((no_sanitize_undefined)) >>> static const uchar * >>> search_line_fast (const uchar *s, const uchar *end ATTRIBUTE_UNUSED) >>> { >> >> I don't think you can use the __attribute__ just like that. If adding >> such an attribute is the correct thing to do, then we should probably >> define a macro in include/ansidecl.h, with a proper GCC_VERSION guard. > > Ok. Here is an updated version: > > 2015-03-02 Markus Trippelsdorf <markus@trippelsdorf.de> > > include/ > PR target/65261 > * ansidecl.h (ATTRIBUTE_NO_SANITIZE_UNDEFINED): New macro. > > libcpp/ > PR target/65261 > * lex.c (search_line_fast): Silence ubsan errors. OK for the trunk. jeff
diff --git a/include/ansidecl.h b/include/ansidecl.h index 0fb23bba792d..04d75c33f747 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -276,6 +276,15 @@ So instead we use the macro below and test it against specific values. */ # endif /* GNUC >= 4.3 */ #endif /* ATTRIBUTE_HOT */ +/* Attribute 'no_sanitize_undefined' was valid as of gcc 4.9. */ +#ifndef ATTRIBUTE_NO_SANITIZE_UNDEFINED +# if (GCC_VERSION >= 4009) +# define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__ ((no_sanitize_undefined)) +# else +# define ATTRIBUTE_NO_SANITIZE_UNDEFINED +# endif /* GNUC >= 4.9 */ +#endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */ + /* We use __extension__ in some places to suppress -pedantic warnings about GCC extensions. This feature didn't work properly before gcc 2.8. */ diff --git a/libcpp/lex.c b/libcpp/lex.c index 4638510166fa..0dc473711833 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -519,6 +519,7 @@ init_vectorized_lexer (void) and VSX unaligned loads (when VSX is available). This is otherwise the same as the pre-GCC 5 version. */ +ATTRIBUTE_NO_SANITIZE_UNDEFINED static const uchar * search_line_fast (const uchar *s, const uchar *end ATTRIBUTE_UNUSED) {