aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp')
-rw-r--r--gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c44
-rw-r--r--gcc/testsuite/gcc.dg/cpp/paste12-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/paste12.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/paste14-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/cpp/paste14.c4
5 files changed, 50 insertions, 6 deletions
diff --git a/gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c b/gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c
new file mode 100644
index 0000000..47d4b23
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c
@@ -0,0 +1,44 @@
+/* N3457 - The __COUNTER__ predefined macro */
+/* { dg-do run } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+#ifndef __COUNTER__
+#error "__COUNTER__ not defined"
+#endif
+
+#define A(X) X + X
+static_assert (A(__COUNTER__) == 0);
+#define B(X)
+B(__COUNTER__)
+static_assert (__COUNTER__ == 1);
+#define C(...) __VA_OPT__()
+C(__COUNTER__)
+static_assert (__COUNTER__ == 3);
+#define D(...) __VA_OPT__(a)
+int D(__COUNTER__) = 1;
+static_assert (__COUNTER__ == 5);
+#define E(X) #X
+const char *b = E(__COUNTER__);
+#define F(X) a##X
+int F(__COUNTER__) = 2;
+static_assert (__COUNTER__ == 6);
+#define G(X) b##X = X
+int G(__COUNTER__);
+static_assert (__COUNTER__ == 8);
+#if !defined(__COUNTER__) || (__COUNTER__ + 1 != __COUNTER__ + 0)
+#error "Unexpected __COUNTER__ behavior")
+#endif
+static_assert (__COUNTER__ == 11);
+
+extern int strcmp (const char *, const char *);
+extern void abort ();
+
+int
+main ()
+{
+ if (a != 1
+ || strcmp (b, "__COUNTER__")
+ || a__COUNTER__ != 2
+ || b__COUNTER__ != 7)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/paste12-2.c b/gcc/testsuite/gcc.dg/cpp/paste12-2.c
index 6e2e4f1..f46645a 100644
--- a/gcc/testsuite/gcc.dg/cpp/paste12-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/paste12-2.c
@@ -6,6 +6,6 @@
/* Test correct diagnostics when pasting in #include.
Source: PR preprocessor/6780. */
-#define inc2(a,b) <##a.b> /* { dg-error "pasting \"<\" and \"stdio\" does not" } */
+#define inc2(a,b) <##a.b> /* { dg-error "pasting '<' and 'stdio' does not" } */
#define INC(X) inc2(X,h)
#include INC(stdio)
diff --git a/gcc/testsuite/gcc.dg/cpp/paste12.c b/gcc/testsuite/gcc.dg/cpp/paste12.c
index 3e0f7b9..f6b3696 100644
--- a/gcc/testsuite/gcc.dg/cpp/paste12.c
+++ b/gcc/testsuite/gcc.dg/cpp/paste12.c
@@ -8,4 +8,4 @@
#define inc2(a,b) <##a.b>
#define INC(X) inc2(X,h)
-#include INC(stdio) /* { dg-error "pasting \"<\" and \"stdio\" does not" } */
+#include INC(stdio) /* { dg-error "pasting '<' and 'stdio' does not" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/paste14-2.c b/gcc/testsuite/gcc.dg/cpp/paste14-2.c
index 3b23ada..bb51999 100644
--- a/gcc/testsuite/gcc.dg/cpp/paste14-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/paste14-2.c
@@ -4,8 +4,8 @@
{ dg-do preprocess }
*/
-#define foo - ## >> /* { dg-error "pasting \"-\" and \">>\"" } */
+#define foo - ## >> /* { dg-error "pasting '-' and '>>'" } */
foo
-#define bar = ## == /* { dg-error "pasting \"=\" and \"==\"" } */
+#define bar = ## == /* { dg-error "pasting '=' and '=='" } */
bar
diff --git a/gcc/testsuite/gcc.dg/cpp/paste14.c b/gcc/testsuite/gcc.dg/cpp/paste14.c
index 043d5e5..d60b328 100644
--- a/gcc/testsuite/gcc.dg/cpp/paste14.c
+++ b/gcc/testsuite/gcc.dg/cpp/paste14.c
@@ -5,6 +5,6 @@
*/
#define foo - ## >>
-foo /* { dg-error "pasting \"-\" and \">>\"" } */
+foo /* { dg-error "pasting '-' and '>>'" } */
#define bar = ## ==
-bar /* { dg-error "pasting \"=\" and \"==\"" } */
+bar /* { dg-error "pasting '=' and '=='" } */