aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@gcc.gnu.org>2017-11-17 08:42:28 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2017-11-17 08:42:28 +0100
commitfa30ba9949962eda041475d98c74675e84538eae (patch)
tree5d5c5ec8c3a8e85248284f28745aa7617bd49439 /gcc
parentcaed5c92712701509413c579fb004faa965e4004 (diff)
downloadgcc-fa30ba9949962eda041475d98c74675e84538eae.zip
gcc-fa30ba9949962eda041475d98c74675e84538eae.tar.gz
gcc-fa30ba9949962eda041475d98c74675e84538eae.tar.bz2
re PR testsuite/82997 (gcc.dg/cpp/sysmac1.c and gcc.dg/cpp/macsyntx.c fail starting with r254707)
PR testsuite/82997 * gcc.dg/cpp/macsyntx.c (var1, rest): Don't expect "requires at least one" warning. * gcc.dg/cpp/sysmac1.c (foo): Likewise. * gcc.dg/cpp/macsyntx2.c: New test. * gcc.dg/cpp/sysmac3.c: New test. * gcc.dg/cpp/sysmac3.h: New file. From-SVN: r254857
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog2
-rw-r--r--gcc/testsuite/ChangeLog12
-rw-r--r--gcc/testsuite/gcc.dg/cpp/macsyntx.c8
-rw-r--r--gcc/testsuite/gcc.dg/cpp/macsyntx2.c72
-rw-r--r--gcc/testsuite/gcc.dg/cpp/sysmac1.c4
-rw-r--r--gcc/testsuite/gcc.dg/cpp/sysmac3.c26
-rw-r--r--gcc/testsuite/gcc.dg/cpp/sysmac3.h10
7 files changed, 126 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9352b48..165c5c9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,4 @@
-2017-11-15 Qing Zhao <qing.zhao@oracle.com>
+2017-11-15 Qing Zhao <qing.zhao@oracle.com>
PR middle-end/78809
* gimple-fold.c (gimple_fold_builtin_string_compare): Add handling
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d597fe6..941b0c0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,4 +1,14 @@
-2017-11-15 Qing Zhao <qing.zhao@oracle.com <mailto:qing.zhao@oracle.com>>
+2017-11-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR testsuite/82997
+ * gcc.dg/cpp/macsyntx.c (var1, rest): Don't expect
+ "requires at least one" warning.
+ * gcc.dg/cpp/sysmac1.c (foo): Likewise.
+ * gcc.dg/cpp/macsyntx2.c: New test.
+ * gcc.dg/cpp/sysmac3.c: New test.
+ * gcc.dg/cpp/sysmac3.h: New file.
+
+2017-11-15 Qing Zhao <qing.zhao@oracle.com>
PR middle-end/78809
* gcc.dg/strcmpopt_1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/cpp/macsyntx.c b/gcc/testsuite/gcc.dg/cpp/macsyntx.c
index 146dced..a6c8e11 100644
--- a/gcc/testsuite/gcc.dg/cpp/macsyntx.c
+++ b/gcc/testsuite/gcc.dg/cpp/macsyntx.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc. */
+/* Copyright (C) 2000-2017 Free Software Foundation, Inc. */
/* { dg-do preprocess } */
/* { dg-options "-pedantic -std=gnu99" } */
@@ -51,15 +51,15 @@ one(ichi\
two(ichi) /* { dg-error "requires 2" } */
var0() /* OK. */
var0(ichi) /* OK. */
-var1() /* { dg-warning "requires at least one" } */
-var1(ichi) /* { dg-warning "requires at least one" } */
+var1() /* { dg-bogus "requires at least one" } */
+var1(ichi) /* { dg-bogus "requires at least one" } */
var1(ichi, ni) /* OK. */
/* This tests two oddities of GNU rest args - omitting a comma is OK,
and backtracking a token on pasting an empty rest args. */
#define rest(x, y...) x ## y /* { dg-warning "ISO C" } */
rest(ichi,) /* OK. */
-rest(ichi) /* { dg-warning "requires at least one" } */
+rest(ichi) /* { dg-bogus "requires at least one" } */
#if 23 != rest(2, 3) /* OK, no warning. */
#error 23 != 23 !!
#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/macsyntx2.c b/gcc/testsuite/gcc.dg/cpp/macsyntx2.c
new file mode 100644
index 0000000..1fbd115
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/macsyntx2.c
@@ -0,0 +1,72 @@
+/* Copyright (C) 2000-2017 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+/* { dg-options "-pedantic -std=c99" } */
+
+/* Tests macro syntax, for both definition and invocation, including:-
+
+ o Full range of macro definition semantics.
+ o No. of arguments supplied to function-like macros.
+ o Odd GNU rest args behavior.
+ o Macro arguments do not flow into the rest of the file. */
+
+
+/* Test basic macro definition syntax. The macros are all called
+ "foo" deliberately to provoke an (excess) redefinition warning in
+ case the macros succeed in being entered in the macro hash table
+ despite being an error.
+
+ Split a couple of the lines to check that the errors appear on the
+ right line (i.e. are associated with the correct token). */
+
+#define ; /* { dg-error "identifier" } */
+#define SEMI; /* { dg-warning "space" } */
+#define foo(X /* { dg-error "missing" } */
+#define foo\
+(X,) /* { dg-error "parameter name" } */
+#define foo(, X) /* { dg-error "parameter name" } */
+#define foo(X, X) /* { dg-error "duplicate" } */
+#define foo(X Y) /* { dg-error "comma" } */
+#define foo(() /* { dg-error "may not appear" } */
+#define foo(..., X) /* { dg-error "missing" } */
+#define foo \
+__VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */
+#define goo(__VA_ARGS__) /* { dg-warning "__VA_ARGS__" } */
+#define hoo(...) __VA_ARGS__ /* OK. */
+#define __VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */
+__VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */
+
+/* test # of supplied arguments. */
+#define none()
+#define one(x)
+#define two(x, y)
+#define var0(...)
+#define var1(x, ...)
+none() /* OK. */
+none(ichi) /* { dg-error "passed 1" } */
+one() /* OK. */
+one(ichi) /* OK. */
+one(ichi\
+, ni) /* { dg-error "passed 2" } */
+two(ichi) /* { dg-error "requires 2" } */
+var0() /* OK. */
+var0(ichi) /* OK. */
+var1() /* { dg-warning "requires at least one" } */
+var1(ichi) /* { dg-warning "requires at least one" } */
+var1(ichi, ni) /* OK. */
+
+/* This tests two oddities of GNU rest args - omitting a comma is OK,
+ and backtracking a token on pasting an empty rest args. */
+#define rest(x, y...) x ## y /* { dg-warning "ISO C" } */
+rest(ichi,) /* OK. */
+rest(ichi) /* { dg-warning "requires at least one" } */
+#if 23 != rest(2, 3) /* OK, no warning. */
+#error 23 != 23 !!
+#endif
+
+/* Test that we don't allow arguments to flow into the rest of the
+ file. */
+#define half_invocation do_nowt(2
+#define do_nowt(x) x
+half_invocation ) /* OK. */
+do_nowt (half_invocation)) /* { dg-error "unterminated argument" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/sysmac1.c b/gcc/testsuite/gcc.dg/cpp/sysmac1.c
index 54f161e..acd1365 100644
--- a/gcc/testsuite/gcc.dg/cpp/sysmac1.c
+++ b/gcc/testsuite/gcc.dg/cpp/sysmac1.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc. */
+/* Copyright (C) 2001-2017 Free Software Foundation, Inc. */
/* { dg-do preprocess } */
/* { dg-options "-std=gnu99 -pedantic -Wtraditional -ftrack-macro-expansion=0" } */
@@ -22,5 +22,5 @@
(str); /* { dg-warning "used with arguments" } */
(sys_str); /* { dg-bogus "used with arguments" } */
-foo (one_arg); /* { dg-warning "requires at least one" } */
+foo (one_arg); /* { dg-bogus "requires at least one" } */
sys_foo (one_arg); /* { dg-bogus "requires at least one" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/sysmac3.c b/gcc/testsuite/gcc.dg/cpp/sysmac3.c
new file mode 100644
index 0000000..a0e264d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/sysmac3.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 2001-2017 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+/* { dg-options "-std=c99 -pedantic -Wtraditional -ftrack-macro-expansion=0" } */
+
+/* Tests diagnostics are suppressed for some macros defined in system
+ headers. */
+
+/* Source: Neil Booth, 15 Jan 2001. */
+
+#include "sysmac3.h"
+
+#define uint 1U
+#define str(x) x
+#define foo(x, y...) bar(x, y) /* { dg-warning "named variadic macros" } */
+
+#if uint /* { dg-warning "traditional C rejects" } */
+#endif
+#if sys_uint /* { dg-bogus "traditional C rejects" } */
+#endif
+
+(str); /* { dg-warning "used with arguments" } */
+(sys_str); /* { dg-bogus "used with arguments" } */
+
+foo (one_arg); /* { dg-warning "requires at least one" } */
+sys_foo (one_arg); /* { dg-bogus "requires at least one" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/sysmac3.h b/gcc/testsuite/gcc.dg/cpp/sysmac3.h
new file mode 100644
index 0000000..46077de
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/sysmac3.h
@@ -0,0 +1,10 @@
+/* Indented to avoid "suggest hiding ..." warnings. */
+ #pragma GCC system_header
+
+#define sys_uint 1U
+#define sys_str(x) x
+#define sys_foo(x, y...) bar (x, y)
+
+#define sys_uint 1U
+#define sys_fl 1.0f
+#define sys_ld 1.0L