From: Andrew Haley Date: Thu, 3 Jul 2008 10:13:48 +0000 (+0000) Subject: re PR preprocessor/33305 (We should warn about empty macro arguments) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d92007910f9e9033056d558dd4a49e4828cc0067;p=gcc.git re PR preprocessor/33305 (We should warn about empty macro arguments) 2008-07-03 Andrew Haley PR preprocessor/33305 * gcc.dg/cpp/avoidpaste1.c: Use dg-options "-ansi" to avoid "-pedantic". * gcc.dg/cpp/avoidpaste2.c: Likewise * gcc.dg/cpp/20000519-1.c: Likewise. * g++.dg/ext/gnu-inline-global-reject.C: Likewise. * gcc.dg/cpp/c99-empty-macro-args.c: New test. * gcc.dg/cpp/c90-empty-macro-args.c: New test. From-SVN: r137411 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3feefc8985a..cc23a06e70c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2008-07-03 Andrew Haley + + PR preprocessor/33305 + * gcc.dg/cpp/avoidpaste1.c: Use dg-options "-ansi" to avoid + "-pedantic". + * gcc.dg/cpp/avoidpaste2.c: Likewise + * gcc.dg/cpp/20000519-1.c: Likewise. + * g++.dg/ext/gnu-inline-global-reject.C: Likewise. + * gcc.dg/cpp/c99-empty-macro-args.c: New test. + * gcc.dg/cpp/c90-empty-macro-args.c: New test. + 2008-07-03 Richard Guenther PR c++/36128 diff --git a/gcc/testsuite/g++.dg/ext/gnu-inline-global-reject.C b/gcc/testsuite/g++.dg/ext/gnu-inline-global-reject.C index 2f2b8f29a08..d9e26609550 100644 --- a/gcc/testsuite/g++.dg/ext/gnu-inline-global-reject.C +++ b/gcc/testsuite/g++.dg/ext/gnu-inline-global-reject.C @@ -4,6 +4,7 @@ */ /* { dg-do compile } */ +/* { dg-options " -ansi -Wno-long-long" } */ #include "gnu-inline-common.h" diff --git a/gcc/testsuite/gcc.dg/cpp/20000519-1.c b/gcc/testsuite/gcc.dg/cpp/20000519-1.c index 82ab3a26861..7cd7daa3ad2 100644 --- a/gcc/testsuite/gcc.dg/cpp/20000519-1.c +++ b/gcc/testsuite/gcc.dg/cpp/20000519-1.c @@ -1,6 +1,7 @@ /* Regression test for preprocessor crash. Reported by Mathias Froehlich . */ /* { dg-do preprocess } */ +/* { dg-options "-ansi" } */ #define foo #define __CAT__(a,b,c,d) a##b##c##d diff --git a/gcc/testsuite/gcc.dg/cpp/avoidpaste1.c b/gcc/testsuite/gcc.dg/cpp/avoidpaste1.c index d304a744155..3591f9c08ae 100644 --- a/gcc/testsuite/gcc.dg/cpp/avoidpaste1.c +++ b/gcc/testsuite/gcc.dg/cpp/avoidpaste1.c @@ -1,6 +1,7 @@ /* Copyright (C) 2001, 2003 Free Software Foundation, Inc. */ /* { dg-do preprocess } */ +/* { dg-options "-ansi" } */ /* This tests that we avoid accidental pasting only before and after macros and arguments, and not when the tokens are already pasted diff --git a/gcc/testsuite/gcc.dg/cpp/avoidpaste2.c b/gcc/testsuite/gcc.dg/cpp/avoidpaste2.c index 42b549c8d6c..dc5bbc7f270 100644 --- a/gcc/testsuite/gcc.dg/cpp/avoidpaste2.c +++ b/gcc/testsuite/gcc.dg/cpp/avoidpaste2.c @@ -1,6 +1,7 @@ /* Copyright (C) 2001, 2003 Free Software Foundation, Inc. */ /* { dg-do preprocess } */ +/* { dg-options "-ansi" } */ /* This tests that we avoid accidental pasting, as well as gratuitous space insertion, in various nasty places _inside_ a macro's diff --git a/gcc/testsuite/gcc.dg/cpp/c90-empty-macro-args.c b/gcc/testsuite/gcc.dg/cpp/c90-empty-macro-args.c new file mode 100644 index 00000000000..e90f8e6cb69 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/c90-empty-macro-args.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -pedantic" } */ + +#define f(a,b) f2(a,,b) +#define f2(a,b,c) a; b; c; +#define f3(a) a + +#define g() p() + +void p(void) {} + + +void foo(void) +{ + f(p(),p()); /* { dg-warning "macro f2 argument 2: empty macro arguments are undefined" } */ + f2(p(),,p()); /* { dg-warning "macro f2 argument 2: empty macro arguments are undefined" } */ + f3(); /* { dg-warning "macro f3 argument 1: empty macro arguments are undefined" } */ + g(); +} diff --git a/gcc/testsuite/gcc.dg/cpp/c99-empty-macro-args.c b/gcc/testsuite/gcc.dg/cpp/c99-empty-macro-args.c new file mode 100644 index 00000000000..e1e0c61ec29 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/c99-empty-macro-args.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic" } */ + +#define f(a,b) f2(a,,b) +#define f2(a,b,c) a; b; c; +#define f3(a) a + +#define g() p() + +void p(void) {} + + +void foo(void) +{ + f(p(),p()); + f2(p(),,p()); + f3(); + g(); +}