Message ID | CAE+MWFv1LXf7KBMMRCcwvD9ux4wd4yVbjBc=0KtKxkWwUVUc0w@mail.gmail.com |
---|---|
State | New |
Headers | show |
Series | Warn for ignored ASM labels on typdef declarations | expand |
This patch is missing testcases, which need to be added to the testsuite for any such new feature, and when submitting a patch you should say explicitly in what configuration it was bootstrapped and tested without regressions. Also, it's always incorrect to use -Wpedantic as the option controlling a warning that's not a warning about something not being part of the standard (since asm specifiers aren't part of the standard at all, it's thus wrong for -Wpedantic to control any diagnostic about them other than for them being used at all).
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index f0198ec..e9c0a72 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_Wpedantic, "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..88b4b94 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_Wpedantic, "asm-specifier is ignored for " + "typedef declarations"); + } if (type != error_mark_node && MAYBE_CLASS_TYPE_P (type) && DECL_NAME (decl))