public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Will Hawkins <whh8b@virginia.edu>
To: Joseph Myers <joseph@codesourcery.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Warn for ignored ASM labels on typdef declarations PR 85444 (v.2)
Date: Sat, 28 Apr 2018 23:07:00 -0000	[thread overview]
Message-ID: <CAE+MWFtFXrsFg6nrxePpKBMRovG59QG_hFjw4KYKqQVMHQ=Yhw@mail.gmail.com> (raw)

Thanks to Mr. Meyers for his comments. Here is an updated version of
the patch. Test cases are included this time.

Tested with 'make bootstrap' on x86_64-pc-linux-gnu. Results from make
-k check available upon request.

I hope that this one is better! Thanks again for everyone's patience!

Will


2018-04-18  Will Hawkins  <whh8b@virginia.edu>

  PR c,c++/85444
  * gcc/c/c-decl.c: Warn about ignored asm label for
  typedef declaration
  * gcc/cp/decl.c: Warn about ignored asm label for
  typedef declaration
  * gcc/testsuite/gcc.dg/asm-pr85444.c: c testcase.
  * gcc/testsuite/g++.dg/asm-pr85444.C: c++ testcase.

diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index f0198ec..f18bb7d 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -5166,7 +5166,11 @@ finish_decl (tree decl, location_t init_loc, tree init,
       if (!DECL_FILE_SCOPE_P (decl)
       && variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
     add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
-
+      if (asmspec_tree != NULL_TREE)
+    {
+      warning (OPT_Wignored_qualifiers, "asm-specifier is ignored in "
+           "typedef declaration");
+    }
       rest_of_decl_compilation (decl, DECL_FILE_SCOPE_P (decl), 0);
     }

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 44a152b..32c2dfa 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7069,6 +7069,11 @@ cp_finish_decl (tree decl, tree init, bool
init_const_expr_p,
   /* Take care of TYPE_DECLs up front.  */
   if (TREE_CODE (decl) == TYPE_DECL)
     {
+      if (asmspec_tree != NULL_TREE)
+    {
+      warning (OPT_Wignored_qualifiers, "asm-specifier is ignored for "
+           "typedef declarations");
+    }
       if (type != error_mark_node
       && MAYBE_CLASS_TYPE_P (type) && DECL_NAME (decl))
     {
diff --git a/gcc/testsuite/g++.dg/asm-pr85444.C
b/gcc/testsuite/g++.dg/asm-pr85444.C
new file mode 100644
index 0000000..9e4b6c6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asm-pr85444.C
@@ -0,0 +1,13 @@
+/* Fix Bugzilla 8544 -- asm specifier on typedef silently ignored.
+   { dg-do compile }
+   { dg-options "-Wignored-qualifiers" } */
+
+typedef struct
+{
+  int a;
+} x asm ("X"); /* { dg-warning "asm-specifier is ignored" } */
+
+int main()
+{
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/asm-pr85444.c
b/gcc/testsuite/gcc.dg/asm-pr85444.c
new file mode 100644
index 0000000..9e4b6c6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asm-pr85444.c
@@ -0,0 +1,13 @@
+/* Fix Bugzilla 8544 -- asm specifier on typedef silently ignored.
+   { dg-do compile }
+   { dg-options "-Wignored-qualifiers" } */
+
+typedef struct
+{
+  int a;
+} x asm ("X"); /* { dg-warning "asm-specifier is ignored" } */
+
+int main()
+{
+  return 0;
+}

             reply	other threads:[~2018-04-28 21:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-28 23:07 Will Hawkins [this message]
2018-04-30 12:17 ` Joseph Myers
2018-04-30 19:19   ` Will Hawkins
2018-04-30 20:37     ` Joseph Myers

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='CAE+MWFtFXrsFg6nrxePpKBMRovG59QG_hFjw4KYKqQVMHQ=Yhw@mail.gmail.com' \
    --to=whh8b@virginia.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    /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).