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  <wh...@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 via email to