* gcc.dg/cpp/sysmac1.c, sysmac2.c: New testcases.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Wed, 14 Feb 2001 07:39:40 +0000 (07:39 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Wed, 14 Feb 2001 07:39:40 +0000 (07:39 +0000)
From-SVN: r39662

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/sysmac1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/sysmac2.c [new file with mode: 0644]

index 85123ffa4150dd07112f955f7af7ba86f8eac983..d5b4ff1f8e555807f0ff5e30416d3b142ca7cdde 100644 (file)
@@ -1,3 +1,7 @@
+2001-02-14  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * gcc.dg/cpp/sysmac1.c, sysmac2.c: New tests.
+
 2001-02-12  Geoffrey Keating  <geoffk@redhat.com>
 
        * g++.dg/vtgc1.C: Update for new ABI.
diff --git a/gcc/testsuite/gcc.dg/cpp/sysmac1.c b/gcc/testsuite/gcc.dg/cpp/sysmac1.c
new file mode 100644 (file)
index 0000000..9925a71
--- /dev/null
@@ -0,0 +1,32 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.  */
+
+/* { dg-do preprocess } */
+/* { dg-options "-std=gnu99 -pedantic -Wtraditional" } */
+
+/* Tests diagnostics are suppressed for some macros defined in system
+   headers.  */
+
+/* Source: Neil Booth, 15 Jan 2001.  */
+
+#define uint 1U
+#define str(x) x
+#define foo(x, y...) bar(x, ##y) /* { dg-warning "named variadic macros" } */
+
+# 16 "system.h" 1 3            /* { dg-warning "followed by integer" }  */
+
+#define sys_uint 1U
+#define sys_str(x) x
+#define sys_foo(x, y...) bar (x, ##y)
+
+# 22 "bar.c" 2                 /* { dg-warning "expected to return" }  */
+
+#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 rest arguments" } */
+sys_foo (one_arg);             /* { dg-bogus "requires rest arguments" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/sysmac2.c b/gcc/testsuite/gcc.dg/cpp/sysmac2.c
new file mode 100644 (file)
index 0000000..b15b25f
--- /dev/null
@@ -0,0 +1,34 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.  */
+
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -pedantic -Wtraditional" } */
+
+/* Tests diagnostics are suppressed for some macros defined in system
+   headers.  */
+
+/* Source: Neil Booth, 15 Jan 2001.  */
+
+#define uint 1U
+#define fl 1.0f
+#define ld 1.0L
+
+# 16 "system.h" 1 3            /* { dg-warning "followed by integer" }  */
+
+#define sys_uint 1U
+#define sys_fl 1.0f
+#define sys_ld 1.0L
+
+# 22 "bar.c" 2                 /* { dg-warning "expected to return" }  */
+
+int
+main ()
+{
+  int u1 = uint;               /* { dg-warning "traditional C rejects" } */
+  int u2 = sys_uint;           /* { dg-bogus "traditional C rejects" } */
+  float f1 = fl;               /* { dg-warning "traditional C rejects" } */
+  float f2 = sys_fl;           /* { dg-bogus "traditional C rejects" } */
+  long double ld1 = ld;                /* { dg-warning "traditional C rejects" } */
+  long double l2 = sys_ld;     /* { dg-bogus "traditional C rejects" } */
+
+  return 0;
+}