Message ID | d858d93a-dfec-1c54-ca5f-37e5953d29e7@mentor.com |
---|---|
State | New |
Headers | show |
Series | [1/7,libsanitizer,committed] Remove semicolon after do {} while (0) in macro body | expand |
On Sun, Nov 05, 2017 at 11:05:02AM +0100, Tom de Vries wrote: > > this patch removes a semicolon after "do {} while (0)" in match macros. The patch contains this part. > This allows the macros to be used in if-then-elses without curly braces. The patch does not contain any changes that support this statement. Is there a follow-on patch to remove curly braces?
On 11/05/2017 03:32 PM, Steve Kargl wrote: > On Sun, Nov 05, 2017 at 11:05:02AM +0100, Tom de Vries wrote: >> >> this patch removes a semicolon after "do {} while (0)" in match macros. > > The patch contains this part. > >> This allows the macros to be used in if-then-elses without curly braces. > > The patch does not contain any changes that support this statement. I'm not listing two changes here, but a change and a consequence. I'm merely pointing out that this compiles: ... $ cat do-while-0.c #define BLA do {} while (0); void foo (void) { if (1) { BLA; } else ; } $ gcc do-while-0.c -S $ ... but this does not: ... $ cat do-while-0.2.c #define BLA do {} while (0); void foo (void) { if (1) BLA; else ; } $ gcc do-while-0.2.c -S do-while-0.2.c: In function ‘foo’: do-while-0.2.c:8:3: error: ‘else’ without a previous ‘if’ else ^ $ ... and then again this does: ... $ cat do-while-0.3.c #define BLA do {} while (0) void foo (void) { if (1) BLA; else ; } $ gcc do-while-0.3.c -S $ ... Thanks, - Tom
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index e4deff9..d025c91 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -132,7 +132,7 @@ use_modules (void) return st; \ else \ undo_new_statement (); \ - } while (0); + } while (0) /* This is a specialist version of decode_statement that is used @@ -606,7 +606,7 @@ decode_statement (void) return st; \ else \ undo_new_statement (); \ - } while (0); + } while (0) static gfc_statement decode_oacc_directive (void) @@ -728,7 +728,7 @@ decode_oacc_directive (void) } \ else \ undo_new_statement (); \ - } while (0); + } while (0) /* Like match, but don't match anything if not -fopenmp and if spec_only, goto do_spec_only without actually matching. */ @@ -746,7 +746,7 @@ decode_oacc_directive (void) } \ else \ undo_new_statement (); \ - } while (0); + } while (0) /* Like match, but set a flag simd_matched if keyword matched. */ #define matchds(keyword, subr, st) \ @@ -759,7 +759,7 @@ decode_oacc_directive (void) } \ else \ undo_new_statement (); \ - } while (0); + } while (0) /* Like match, but don't match anything if not -fopenmp. */ #define matchdo(keyword, subr, st) \ @@ -774,7 +774,7 @@ decode_oacc_directive (void) } \ else \ undo_new_statement (); \ - } while (0); + } while (0) static gfc_statement decode_omp_directive (void)
Hi, this patch removes a semicolon after "do {} while (0)" in match macros. This allows the macros to be used in if-then-elses without curly braces. Thanks, - Tom 2017-11-02 Tom de Vries <tom@codesourcery.com> PR other/82784 * parse.c (match, matcha, matchs, matcho, matchds, matchdo): Remove semicolon after "do {} while (0)". Signed-off-by: Tom de Vries <tom@codesourcery.com> --- gcc/fortran/parse.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)