From patchwork Fri Apr 15 01:00:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1617520 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=a9g7GU0O; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KfdNK2qYTz9s07 for ; Fri, 15 Apr 2022 11:02:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B7F393856DD1 for ; Fri, 15 Apr 2022 01:02:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B7F393856DD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1649984556; bh=ZHOJYqIfszIak6h8H0d4IyLM8VGaspoOau6AxaIbV84=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=a9g7GU0Ou1en9e0R833H9TlTCPyVUQ19AMTO6RH8pj1AHwnVc6YM7kZdslfNbPWm9 YmBK+y6n0tA5NsGdifrz3DWuvwD/+kvejIGqYS9KWpdTBYrM0GeFVHqxesCAxJ3WQT WSVk0naDC7r9b2UHC8nfyUynwxUItHveledf7c+A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B11A03856DE9 for ; Fri, 15 Apr 2022 01:00:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B11A03856DE9 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-368-wB7Ve0E4O9CBdbksYKRbSQ-1; Thu, 14 Apr 2022 21:00:53 -0400 X-MC-Unique: wB7Ve0E4O9CBdbksYKRbSQ-1 Received: by mail-qv1-f71.google.com with SMTP id t10-20020ad45bca000000b0044457d2bab0so5782896qvt.22 for ; Thu, 14 Apr 2022 18:00:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZHOJYqIfszIak6h8H0d4IyLM8VGaspoOau6AxaIbV84=; b=54oF6Ro+YAQ+tPbqHzKZlJiBt67YjaVFSSdFJbC9dZ1TAjnqJNzAfFgQI1yJpAFiV3 w3bf/IML0s5ZtthGv5AUIvzB5t2ozvcK17y1esltLqSQJ/W2aR6Jyb3g7SSVpQL3QFih RuUxNwvQEvLr9Nx83wedvGdUXFrnf0Onb+onYIDdcn5koEPzWjOErSJ4Bil/C78mVjFI jq6DTIGzhgQhfhOE6NKexjfXzhDqAVZ4u8rfz+wIG1Pdhf0APH/s9fV7NCGO//S8Paxf hrf18nObyMcsd5i/AFXCsJNLBdWNW3onKNgyWb4cDm7pBHCUcDD74ip8iTaapLhTQv4X 5v+w== X-Gm-Message-State: AOAM531PMf0hqaVxVWNnjDanb9S5JAFUDq3ms/THAq/42lsKZexoH8Z6 22cRppXr4q+TXVe9mcZppCjBXPDtGK1jYycdzf3Kp/e+nCPug9Yy5r2scW1aTl5FxFxznm3Ha2O zk+eF2ggisaDsrzZYKEl9kMfnEiyWSxET0MBA5DtSkdjp9szwumIvJODKMbqjMpf/rQ== X-Received: by 2002:a05:622a:6205:b0:2f1:e9d9:df34 with SMTP id hj5-20020a05622a620500b002f1e9d9df34mr2080172qtb.86.1649984452448; Thu, 14 Apr 2022 18:00:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYaTnps7QzFNdxF1iBIf/1m/L9ekCHOHKGqP8FgdwtAFnyujVaBj2RCtP/UujGZoKRozogFA== X-Received: by 2002:a05:622a:6205:b0:2f1:e9d9:df34 with SMTP id hj5-20020a05622a620500b002f1e9d9df34mr2080146qtb.86.1649984452015; Thu, 14 Apr 2022 18:00:52 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id p17-20020ae9f311000000b0069c2824bd75sm1715170qkg.91.2022.04.14.18.00.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 18:00:50 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: unsigned int32_t enum promotion [PR102804] Date: Thu, 14 Apr 2022 21:00:48 -0400 Message-Id: <20220415010048.3512289-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" There's been an extension for a long time to allow applying 'unsigned' to an int typedef, but that was confusing the integer promotion code. Fixed by forgetting about the typedef in that case. I'm going to make this an unconditional pedwarn in stage 1. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/102804 gcc/cp/ChangeLog: * decl.cc (grokdeclarator): Drop typedef used with 'unsigned'. gcc/testsuite/ChangeLog: * g++.dg/ext/unsigned-typedef1.C: New test. --- gcc/cp/decl.cc | 2 ++ gcc/testsuite/g++.dg/ext/unsigned-typedef1.C | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/unsigned-typedef1.C base-commit: 6364a39907bd68624a30df0c8e380c40d2a646c4 diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index d51fd75b003..2852093d624 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -12243,6 +12243,8 @@ grokdeclarator (const cp_declarator *declarator, pedwarn (loc, OPT_Wpedantic, "%qs specified with %qT", key, type); ok = !flag_pedantic_errors; + type = DECL_ORIGINAL_TYPE (typedef_decl); + typedef_decl = NULL_TREE; } else if (declspecs->decltype_p) error_at (loc, "%qs specified with %", key); diff --git a/gcc/testsuite/g++.dg/ext/unsigned-typedef1.C b/gcc/testsuite/g++.dg/ext/unsigned-typedef1.C new file mode 100644 index 00000000000..360b5f81edf --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/unsigned-typedef1.C @@ -0,0 +1,9 @@ +// PR c++/102804 +// { dg-do compile { target c++11 } } +// { dg-options "-Wpedantic" } + +using int32_t = int; +enum: unsigned int32_t { foo }; // { dg-warning "int32_t" } +int f(int) = delete; +int f(unsigned); +auto x = f(1 ? foo : 1);