From patchwork Wed Apr 18 21:51:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Hawkins X-Patchwork-Id: 900402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-476587-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=virginia.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ITYggdj2"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40RG6L3Khbz9s19 for ; Thu, 19 Apr 2018 07:51:35 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=kju2KGXfV8TZYZPGtwtTqYvk3q5MEz8T+euVa1ZJEQfYmV XH10BoFgeMggGcObmwuQRzUwPz8ZN0Yc6ofjpTe1S6aZnr0KKLA5zs22TvTKXmXL lVnZqOS7MdNnd/bO7pJcwRRmvJ4mfLaCuuCy66XV+em0zrXl2QKEAN2hYdSdo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=2maQ6h289Nnd62B2uAnsPZKPOqs=; b=ITYggdj2AeojQelPTcxe tRDqK9l+RhITuWjl4I591unLr1eizv4gIFLK7s4tDZdEDFMdIMAGkFz+Cxji4qdZ 8ILmY1yeCaSKhk4hQb5tvTl3rmEgDUXoBRFtv54QvHXs918ONNAIB8FmtxnE+j+F 90mAXEIGtmBOlKFUB3kijfU= Received: (qmail 79286 invoked by alias); 18 Apr 2018 21:51:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 79276 invoked by uid 89); 18 Apr 2018 21:51:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f196.google.com Received: from mail-qt0-f196.google.com (HELO mail-qt0-f196.google.com) (209.85.216.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Apr 2018 21:51:27 +0000 Received: by mail-qt0-f196.google.com with SMTP id h4-v6so3446852qtn.13 for ; Wed, 18 Apr 2018 14:51:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=SVbFsbqpiNZ2WVOBu+9p/8aSdfIwrpw8Vw0DeNdgu/k=; b=Y6E3BFR9QihLjU2MZs8k85axZmfjfMCW4oKsTBgXMZYpmw87Vw+kwFr9ZORqLbmfef CpzpWUEr5O2kYkEbKjsAa0A+Faqf9AMyx1W7/zowZfIdV+qs4VIf/+pSSdqMmYP92aHm n2UGlUoShL7vqf+oM4B5ZPezredHIvKqjOdcMNC40m2uF01u/tgkncVaS2bhVCybsS4b Uw9DNTkDif8lLNPB7oVgCstbqEK6OCzKDMEAhcsz0JCgK6PSKn06YwUvUXX318nVCdYq izNrkcSMhdkt0omVXEC1zAhJHhu9FFk42Th8jOkhZ/p2VcHff9dOE/Kuf8oJ9KGkNw6O myQQ== X-Gm-Message-State: ALQs6tDBWQ9CovdkKWuK2lHFfqII8puS8pIeKSjsQnu7okFzGputOaTW weisYkHEeWNrQ7r4/imt2J3zHi9Wn7EAcovHsH3RasXo X-Google-Smtp-Source: AB8JxZqFAlO2s8HDaohpLaAs0+L2F7fykJo5WrYo/kuLURNCW3BTJ81em+Q3fKBY4tP6R1kZQix0ihYq2/Vg+N+5ZlA= X-Received: by 2002:ac8:70d3:: with SMTP id g19-v6mr3676816qtp.393.1524088284941; Wed, 18 Apr 2018 14:51:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.22.9 with HTTP; Wed, 18 Apr 2018 14:51:24 -0700 (PDT) From: Will Hawkins Date: Wed, 18 Apr 2018 17:51:24 -0400 Message-ID: Subject: [PATCH] Warn for ignored ASM labels on typdef declarations To: gcc-patches@gcc.gnu.org Hello everyone! First, let me ask for your patience -- this is the first patch I am submitting to gcc. I tried very hard to follow the proper procedure, but I am sure that I've missed something. According to https://gcc.gnu.org/onlinedocs/gcc/Asm-Labels.html#Asm-Labels asm labels have no effect on anything other than variable and function declarations. When an asm label is included on a typedef, the compiler happily goes along but does not indicate anything to the user. For instance, when parsing typedef struct {} x asm ("X"); the compiler silently discards the asm label. This patch will generate a warning (at -Wpedantic) for such a situation. This is in Bugzilla as 85444. Again, I hope that I have done all the proper formatting so that it is inline with all the contribution guidelines. Thank you for your patience! Will 2018-04-18 Will Hawkins * 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 { 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))