This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Wrap a macro in do {} while (0) (PR sanitizer/80063)


On Mon, Mar 20, 2017 at 09:37:10AM -0400, Jason Merrill wrote:
> On Mon, Mar 20, 2017 at 9:28 AM, Marek Polacek <polacek@redhat.com> wrote:
> >  #define DEF_SANITIZER_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
> > +  do {                                                                 \
> > +    decl = add_builtin_function ("__builtin_" NAME, TYPE, ENUM,                \
> > +                                BUILT_IN_NORMAL, NAME, NULL_TREE);     \
> > +    set_call_expr_flags (decl, ATTRS);                                 \
> > +    set_builtin_decl (ENUM, decl, true);                               \
> > +  } while (0);
> 
> We leave out the trailing ; in a macro like this.

True, but that wasn't possible in this case, otherwise I got tons of

/home/marek/src/gcc/gcc/asan.c:2570:3: error: expected ‘;’ before ‘do’
   do {         \
   ^
/home/marek/src/gcc/gcc/sanitizer.def:459:1: note: in expansion of macro ‘DEF_SANITIZER_BUILTIN’
 DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT

	Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]