* Re: [PATCH] Warn for ignored ASM labels on typdef declarations PR 85444 (v.2)
@ 2018-04-28 23:07 Will Hawkins
2018-04-30 12:17 ` Joseph Myers
0 siblings, 1 reply; 4+ messages in thread
From: Will Hawkins @ 2018-04-28 23:07 UTC (permalink / raw)
To: Joseph Myers; +Cc: gcc-patches
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;
+}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Warn for ignored ASM labels on typdef declarations PR 85444 (v.2)
2018-04-28 23:07 [PATCH] Warn for ignored ASM labels on typdef declarations PR 85444 (v.2) Will Hawkins
@ 2018-04-30 12:17 ` Joseph Myers
2018-04-30 19:19 ` Will Hawkins
0 siblings, 1 reply; 4+ messages in thread
From: Joseph Myers @ 2018-04-30 12:17 UTC (permalink / raw)
To: Will Hawkins; +Cc: gcc-patches
On Sat, 28 Apr 2018, Will Hawkins wrote:
> + {
> + warning (OPT_Wignored_qualifiers, "asm-specifier is ignored in "
> + "typedef declaration");
This does not match the documented semantics of -Wignored-qualifiers. I
don't think it's appropriate to expand those semantics to include this
warning either.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Warn for ignored ASM labels on typdef declarations PR 85444 (v.2)
2018-04-30 12:17 ` Joseph Myers
@ 2018-04-30 19:19 ` Will Hawkins
2018-04-30 20:37 ` Joseph Myers
0 siblings, 1 reply; 4+ messages in thread
From: Will Hawkins @ 2018-04-30 19:19 UTC (permalink / raw)
To: Joseph Myers; +Cc: gcc-patches
On Mon, Apr 30, 2018 at 7:51 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Sat, 28 Apr 2018, Will Hawkins wrote:
>
>> + {
>> + warning (OPT_Wignored_qualifiers, "asm-specifier is ignored in "
>> + "typedef declaration");
>
> This does not match the documented semantics of -Wignored-qualifiers. I
> don't think it's appropriate to expand those semantics to include this
> warning either.
>
I agree! It was, however, the closest of all the categories that I
could find that seemed to match the warning that I am trying to emit.
I will go back and review the categories and see if there is something
that I missed.
I am certainly not asking you to "do my homework" for me, but does
anyone have suggestions for a category that might house this warning?
Thanks!
Will
> --
> Joseph S. Myers
> joseph@codesourcery.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Warn for ignored ASM labels on typdef declarations PR 85444 (v.2)
2018-04-30 19:19 ` Will Hawkins
@ 2018-04-30 20:37 ` Joseph Myers
0 siblings, 0 replies; 4+ messages in thread
From: Joseph Myers @ 2018-04-30 20:37 UTC (permalink / raw)
To: Will Hawkins; +Cc: gcc-patches
On Mon, 30 Apr 2018, Will Hawkins wrote:
> I agree! It was, however, the closest of all the categories that I
> could find that seemed to match the warning that I am trying to emit.
> I will go back and review the categories and see if there is something
> that I missed.
If there isn't a suitable warning option for a new warning, that means you
need to add (with documentation) a new warning option (which might then be
enabled by -Wall or -Wextra if appropriate; and, once in GCC, should have
release notes added to gcc-9/changes.html on the website).
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-04-30 19:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-28 23:07 [PATCH] Warn for ignored ASM labels on typdef declarations PR 85444 (v.2) Will Hawkins
2018-04-30 12:17 ` Joseph Myers
2018-04-30 19:19 ` Will Hawkins
2018-04-30 20:37 ` Joseph Myers
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).