public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Lewis Hyatt <lhyatt@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-4747] libcpp: testsuite: Add test for fixed _Pragma bug [PR82335]
Date: Thu, 19 Oct 2023 13:11:23 +0000 (GMT)	[thread overview]
Message-ID: <20231019131123.EF9133858D1E@sourceware.org> (raw)

https://gcc.gnu.org/g:202a214d6859d91af5a95aa989321c5d2173c40a

commit r14-4747-g202a214d6859d91af5a95aa989321c5d2173c40a
Author: Lewis Hyatt <lhyatt@gmail.com>
Date:   Mon Oct 2 14:56:58 2023 -0400

    libcpp: testsuite: Add test for fixed _Pragma bug [PR82335]
    
    This PR was fixed by r12-4797 and r12-5454. Add test coverage from the PR
    that is not represented elsewhere.
    
    gcc/testsuite/ChangeLog:
    
            PR preprocessor/82335
            * c-c++-common/cpp/diagnostic-pragma-3.c: New test.

Diff:
---
 .../c-c++-common/cpp/diagnostic-pragma-3.c         | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-3.c b/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-3.c
new file mode 100644
index 000000000000..459dcec73b32
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-3.c
@@ -0,0 +1,37 @@
+/* This is like diagnostic-pragma-2.c, but handles the case where everything
+   is wrapped inside a macro, which previously caused additional issues tracked
+   in PR preprocessor/82335.  */
+
+/* { dg-do compile } */
+/* { dg-additional-options "-save-temps -Wattributes -Wtype-limits" } */
+
+#define B _Pragma("GCC diagnostic push") \
+          _Pragma("GCC diagnostic ignored \"-Wattributes\"")
+#define E _Pragma("GCC diagnostic pop")
+
+#define X() B int __attribute((unknown_attr)) x; E
+#define Y   B int __attribute((unknown_attr)) y; E
+#define WRAP(x) x
+
+void test1(void)
+{
+  WRAP(X())
+  WRAP(Y)
+}
+
+/* Additional test provided on the PR.  */
+#define PRAGMA(...) _Pragma(#__VA_ARGS__)
+#define PUSH_IGN(X) PRAGMA(GCC diagnostic push) PRAGMA(GCC diagnostic ignored X)
+#define POP() PRAGMA(GCC diagnostic pop)
+#define TEST(X, Y) \
+  PUSH_IGN("-Wtype-limits") \
+  int Y = (__typeof(X))-1 < 0; \
+  POP()
+
+int test2()
+{
+  unsigned x;
+  TEST(x, i1);
+  WRAP(TEST(x, i2))
+  return i1 + i2;
+}

                 reply	other threads:[~2023-10-19 13:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231019131123.EF9133858D1E@sourceware.org \
    --to=lhyatt@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).