[cfe-commits] r147473 - /cfe/trunk/test/Preprocessor/warn-disabled-macro-expansion.c
Matthieu Monrocq
matthieu.monrocq at gmail.com
Wed Jan 4 11:53:51 PST 2012
Le 3 janvier 2012 21:13, Abramo Bagnara <abramo.bagnara at gmail.com> a écrit :
> Author: abramo
> Date: Tue Jan 3 14:13:03 2012
> New Revision: 147473
>
> URL: http://llvm.org/viewvc/llvm-project?rev=147473&view=rev
> Log:
> Added testcases for -Wdisabled-macro-expansion.
>
> Added:
> cfe/trunk/test/Preprocessor/warn-disabled-macro-expansion.c
>
> Added: cfe/trunk/test/Preprocessor/warn-disabled-macro-expansion.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/warn-disabled-macro-expansion.c?rev=147473&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Preprocessor/warn-disabled-macro-expansion.c (added)
> +++ cfe/trunk/test/Preprocessor/warn-disabled-macro-expansion.c Tue Jan 3
> 14:13:03 2012
> @@ -0,0 +1,27 @@
> +// RUN: %clang_cc1 %s -E -Wdisabled-macro-expansion -verify
> +
> +#define p p
> +
> +#define a b
> +#define b a
> +
> +#define f(a) a
> +
> +#define g(b) a
> +
> +#define h(x) i(x)
> +#define i(y) i(y)
> +
> +#define c(x) x(0)
> +
> +p // expected-warning {{recursive macro}}
> +
> +a // expected-warning {{recursive macro}}
> +
> +f(2)
> +
> +g(3) // expected-warning {{recursive macro}}
> +
> +h(0) // expected-warning {{recursive macro}}
> +
> +c(c) // expected-warning {{recursive macro}}
>
>
>
> Hi Abramo,
Do you think it would be possible, sometimes, to detect those cases not at
the point of expansion but at the point of definition (to avoid multiple
warnings per translation unit).
For example:
#define p p
#define i(x) i(0)
are clearly recursive
And with
#define a b
#define b a
The second definition clearly introduces recursivity.
I do not know, of course, if this is easy...
-- Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120104/1ef8cb78/attachment.html>
More information about the cfe-commits
mailing list