From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 0C2553856092 for ; Tue, 5 Sep 2023 11:08:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0C2553856092 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-401ec23be82so25191885e9.0 for ; Tue, 05 Sep 2023 04:08:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1693912092; x=1694516892; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qGM9L2lZRnMN/SOH1kMzauAsiNjMIZhwCbThpWQLYgo=; b=OkHKnwUoUQ8OPvlT7oOlWPQ7LqwvoylMwcbvLnVPGdZlw9HZYCy9Kz+G+lWCCWX4f0 Iuirc5ZHVtHsHpAt66MEKXdUJwHxKJDtUn9pXnTHG28q75xakc7S14fTv1bJuMw+KAT2 sthtPsvmHUY2BEoWtDl2utEFjoKaFOk6eKUvnTmo14+f46aub9Aqt136gvRAlbCHWkbi bcRu/yo63Q1gx6LQxD5hH2mTXiIGwAo3sUxzzkn1gurG576VIjgf3hvKt7SbDGuSwpAC xplz1lbim/c3Vho49gxYN9aWJG3KxOicPo8A2sMtRI2TZzs0cRoJM6C/Y4eLy3cHGokt xW8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693912092; x=1694516892; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qGM9L2lZRnMN/SOH1kMzauAsiNjMIZhwCbThpWQLYgo=; b=N7Cm+BgjGKgjxikA/jCjJyx9cDzlECs+7SFyx5o4D6hidvpu0KlFSEZRYm19njguqx Tsf8u7raHLPjJalIkdoX7CIgHODhvilyp7KeDlYc6nf+0I73eArj7RbvuqBO/tn5Y++f dqyUSd70SCnsIPPsGxy39+5hSR8Mug9CXAFjUKVyoRRm+qR1HZxxl1BMMJuxzTBQ3BE6 /3Jf77bsMcgONZwqWW1UIhGgaNRWcCCzFMSoahh3NcGOROh6/B2HpzBe8weoUFvKGooW WfSf2HgNJK8/ha7AUJhqCBejgTxrtiRBOg/LeOfdVlkwHQY7pLDN+s3So2Mz+pN6Kmkd osoQ== X-Gm-Message-State: AOJu0YwVzI2/S9onX15SmXXoUWljrJxzbYPbBZEbk6ErTQ02LDkdKMQO bbfmImYMj//a2dv4v/c7tLnMoryyU0wXN8XEL9//2Q== X-Google-Smtp-Source: AGHT+IFK2xAtpacPp8zArY3s57n/Cb8PR2ydkgYAp3JJxeXLjtMjT57ANU7xTfctc3lfA7kKLscxFA== X-Received: by 2002:a7b:c411:0:b0:3fe:f45:772d with SMTP id k17-20020a7bc411000000b003fe0f45772dmr9513832wmi.28.1693912091934; Tue, 05 Sep 2023 04:08:11 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:20fc:79e4:455c:1075]) by smtp.gmail.com with ESMTPSA id 6-20020a05600c028600b003feea62440bsm16547191wmk.43.2023.09.05.04.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 04:08:11 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED] ada: Spurious warning about negative modular literal Date: Tue, 5 Sep 2023 13:08:10 +0200 Message-Id: <20230905110810.562697-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Steve Baird If -gnatw.m is enabled, the compiler generates a warning if a unary minus operator of a modular type is applied to an integer literal. This warning was being incorrectly generated in some cases where no integer literal is present in the source code. gcc/ada/ * sem_res.adb (Resolve_Unary_Op): In deciding whether to emit a warning about a modular type's unary minus operator being applied to an integer literal, ignore integer literals for which Comes_From_Source is False. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_res.adb | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 9755e4d14a6..c708d04fc32 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -12671,6 +12671,7 @@ package body Sem_Res is if Warn_On_Suspicious_Modulus_Value and then Nkind (N) = N_Op_Minus and then Nkind (R) = N_Integer_Literal + and then Comes_From_Source (R) and then Is_Modular_Integer_Type (B_Typ) and then Nkind (Parent (N)) not in N_Qualified_Expression | N_Type_Conversion -- 2.40.0