aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/cpp/tr-warn2.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/cpp/tr-warn2.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/cpp/tr-warn2.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/cpp/tr-warn2.c b/gcc-4.9/gcc/testsuite/gcc.dg/cpp/tr-warn2.c
new file mode 100644
index 000000000..85b624761
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/cpp/tr-warn2.c
@@ -0,0 +1,18 @@
+/* K+R rejects use of function-like macros in non-function context.
+ ANSI C explicitly permits this (the macro is not expanded).
+
+ We should not warn about this during pre-expansion of arguments,
+ since traditional preprocessors don't do pre-expansion, and we get
+ the warning anyway during the re-scan pass if and only if it is
+ appropriate. */
+
+/* { dg-do preprocess } */
+/* { dg-options -Wtraditional } */
+
+#define f(x) x
+#define g(x) x / 2
+#define h(a, b) a(b)
+f(g) (3) /* { dg-bogus "must be used with arguments" } */
+f 2 /* { dg-warning "must be used with arguments" } */
+f(g) 3 /* { dg-warning "must be used with arguments" } */
+h(f, 3) /* { dg-bogus "must be used with arguments" } */