From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 850A33857B88 for ; Thu, 15 Feb 2024 21:51:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 850A33857B88 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 850A33857B88 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708033891; cv=none; b=MUQ5PUbuEhsiIJKpNDIMe9LWYY1JQCHugsSyXvCc1BTq3G14oNIXzxk9aGH5MGq8CiE1vc+Bt12VsxwxOBh7aFC1lCDXtlDfTYvMKBE7qCftXi/y9jy4J1XlB6gflQF5mgJQsYMA5X0sOmgJTdYl2MXjs8tH5tzsgdAr8bK37MQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708033891; c=relaxed/simple; bh=gG5vRXJXkGXXm/JuNis8B4Y2ivCFXh6Oq0x65WDh5Cw=; h=DKIM-Signature:From:Date:To:Subject:Message-ID:MIME-Version; b=hLXl+E74Z0NiAnlQIj5PkpOuAJ5eyeoypud2NKMzJ1eYxaxP+2etnaW9il/yXOxxRZ0CK9WsJ/0QiR5alZYcE71GVnzgI0MnESitN589ZX2wY0CUQJjumME8TQmHqGacEslYAxtPBUuFTduNhrKjMxkpLvG4wTFXkMhYaEhihzw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708033889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8wOdc+8VvxZ4cKWgxJh8dQ014WurKQfnIndgUFCXoZ4=; b=UP+v9kUZsYEEXrutEPRb1R+X224N/3sN+PXdePTXbfwRYiaps8Wlp2zi0+XsSWY61/Nqcz AIFrS7ZvbO8XENxnQNEl79k024/obmIn6t66YXJtweNeBf/bSQ3yJ6J0ahdaHc22S757+A 4KVfyDj6FZ0vSMqM04evbcnZbUKOyl0= Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-401-4hEx7NxYN-KbJwDUWoFkPw-1; Thu, 15 Feb 2024 16:51:27 -0500 X-MC-Unique: 4hEx7NxYN-KbJwDUWoFkPw-1 Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-219295e45a9so1375291fac.3 for ; Thu, 15 Feb 2024 13:51:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708033887; x=1708638687; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8wOdc+8VvxZ4cKWgxJh8dQ014WurKQfnIndgUFCXoZ4=; b=cIwZVmNHbBUcVaQd8y4S3m3Y1Tny7C/kTRe979/n0am0YwWCex8u/rxd2Z5eeVRr6n zZNa/vkmeyMhxxBPEiWBR+h0o1DRhK5AQN6aCczEJkD4DMBHufVVTlZV8MeD9WWJwiMy v2iN/vv+RBcdky3/sqflmSlAXK1GSrq/DnTNa2k0ZNeLuaGlIYY2bZGhgIbbogsXVFiz XSazPAMJYnvvpHarFrCs1do2DGghbRRZDmjU+1VH3segmYDXPzIr3z2e4Gd4eLj7eAiq JG4OzjUBfBhzV/dUnaO1BIVOYSkvzg0Y1mcVLr8mQKtjKflm+9ET7Rrk3FHVkGvHlDl6 F7Eg== X-Forwarded-Encrypted: i=1; AJvYcCWsxaGYwm02q2iRzwTbwzfeJQPdIhcf9Wq4/TBGeN8Xfx8XsmG59hQ/YwoNKjfy4jjsf5dx0UWktjx0aREcYgOYRPOxLwgCZA== X-Gm-Message-State: AOJu0YwzreiEguTmjYQwPgsqPPOORxMp9xbJf7PuQjv35thpS2P9WRRj azw8E8PRbvIgFw9bNl+tgZhrkdgJioftSDJDaohOFlEv2Ljm3v29AlucoFnFCDoh6rhfKyUU7fP thjYEgFdxh7ad527xg8rtbsADZ/qr+SLI5nvjBQ0gP233R1z3dPDl6dU= X-Received: by 2002:a05:6871:5213:b0:214:ff12:3dda with SMTP id ht19-20020a056871521300b00214ff123ddamr3392663oac.2.1708033887270; Thu, 15 Feb 2024 13:51:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXEsUcM8J5pWUfiOiEBg+eHlBahZmnoiIFhHP2xbYPW3QjLbB//SU475DdJV7JxS5s7ROVsw== X-Received: by 2002:a05:6871:5213:b0:214:ff12:3dda with SMTP id ht19-20020a056871521300b00214ff123ddamr3392657oac.2.1708033887020; Thu, 15 Feb 2024 13:51:27 -0800 (PST) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id c24-20020a05620a11b800b007872ade6cf1sm959174qkk.71.2024.02.15.13.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 13:51:26 -0800 (PST) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Thu, 15 Feb 2024 16:51:25 -0500 (EST) To: Jason Merrill cc: Patrick Palka , gcc-patches@gcc.gnu.org, nathan@acm.org Subject: Re: [PATCH] c++/modules: relax diagnostic about GMF contents In-Reply-To: <57d9a71a-998a-4ff6-ac0f-d99846fbab47@redhat.com> Message-ID: <197b0a99-5e3f-ed40-271a-6fe86bbeb8df@idea> References: <20240215211019.340428-1-ppalka@redhat.com> <57d9a71a-998a-4ff6-ac0f-d99846fbab47@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-13.4 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_NONE,RCVD_IN_MSPIKE_H2,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: On Thu, 15 Feb 2024, Jason Merrill wrote: > On 2/15/24 16:10, Patrick Palka wrote: > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look > > OK for trunk? > > > > -- >8 -- > > > > Issuing a hard error when the GMF doesn't contain preprocessing > > directives is inconvenient for automated testcase reduction via cvise. > > This patch relaxes this diagnostic into a pedwarn. > > > > gcc/cp/ChangeLog: > > > > * parser.cc (cp_parser_translation_unit): Relax GMF contents > > error into a pedwarn. > > > > gcc/testsuite/ChangeLog: > > > > * g++.dg/modules/friend-6_a.C: Remove now unnecessary > > preprocessing directives from GMF. > > --- > > gcc/cp/parser.cc | 6 +++--- > > gcc/testsuite/g++.dg/modules/friend-6_a.C | 2 -- > > 2 files changed, 3 insertions(+), 5 deletions(-) > > > > diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc > > index 9d0914435fb..e60f0425035 100644 > > --- a/gcc/cp/parser.cc > > +++ b/gcc/cp/parser.cc > > @@ -5253,9 +5253,9 @@ cp_parser_translation_unit (cp_parser* parser) > > if (!warned) > > { > > warned = true; > > - error_at (token->location, > > - "global module fragment contents must be" > > - " from preprocessor inclusion"); > > + pedwarn (token->location, OPT_Wpedantic, > > + "global module fragment contents must be" > > + " from preprocessor inclusion"); > > Relaxing to pedwarn is fine, but I think it should be on by default, not just > with -pedantic. So it should get a new option. Ah, like so? I'm not sure about naming the option Wmodules-gmf-contents vs just Wgmf-contents, or something else... -- >8 -- Subject: [PATCH] c++/modules: relax diagnostic about GMF contents Issuing a hard error when the GMF doesn't contain preprocessing directives is inconvenient for automated testcase reduction via cvise. This patch relaxes this diagnostic into a pedwarn that can be disabled with -Wno-modules-gmf-contents. gcc/c-family/ChangeLog: * c.opt (Wmodules-gmf-contents): New warning. gcc/cp/ChangeLog: * parser.cc (cp_parser_translation_unit): Relax GMF contents error into a pedwarn. gcc/ChangeLog: * doc/invoke.texi (-Wno-modules-gmf-contents): Document. gcc/testsuite/ChangeLog: * g++.dg/modules/friend-6_a.C: Pass -Wno-modules-gmf-contents instead of -Wno-pedantic. Remove now unnecessary preprocessing directives from GMF. --- gcc/c-family/c.opt | 4 ++++ gcc/cp/parser.cc | 6 +++--- gcc/doc/invoke.texi | 7 +++++++ gcc/testsuite/g++.dg/modules/friend-6_a.C | 4 +--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index b7a4a1a68e3..6d5f3199b33 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -993,6 +993,10 @@ Wmissing-variable-declarations C ObjC Var(warn_missing_variable_declarations) Warning Warn about global variables without previous declarations. +Wmodules-gmf-contents +C++ ObjC++ Var(warn_modules_gmf_contents) Warning Init(1) +Warn about the global module fragment not containing only preprocessing directives. + Wmudflap C ObjC C++ ObjC++ WarnRemoved diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 9d0914435fb..eb709fc9e38 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -5253,9 +5253,9 @@ cp_parser_translation_unit (cp_parser* parser) if (!warned) { warned = true; - error_at (token->location, - "global module fragment contents must be" - " from preprocessor inclusion"); + pedwarn (token->location, OPT_Wmodules_gmf_contents, + "global module fragment contents must be" + " from preprocessor inclusion"); } } } diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 511114cde59..e27fda88bc4 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -261,6 +261,7 @@ in the following sections. -Winvalid-constexpr -Winvalid-imported-macros -Wno-invalid-offsetof -Wno-literal-suffix -Wmismatched-new-delete -Wmismatched-tags +-Wno-modules-gmf-contents -Wmultiple-inheritance -Wnamespaces -Wnarrowing -Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor -Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n} @@ -4568,6 +4569,12 @@ unresolved references due to the difference in the mangling of symbols declared with different class-keys. The option can be used either on its own or in conjunction with @option{-Wredundant-tags}. +@opindex Wno-modules-gmf-contents +@opindex Wmodules-gmf-contents +@item -Wno-modules-gmf-contents @r{(C++ and Objective-C++ only)} +Disable the diagnostic for when the global module fragment of a module +unit does not consist only of preprocessor directives. + @opindex Wmultiple-inheritance @opindex Wno-multiple-inheritance @item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)} diff --git a/gcc/testsuite/g++.dg/modules/friend-6_a.C b/gcc/testsuite/g++.dg/modules/friend-6_a.C index 7493e8f262f..429fb460eea 100644 --- a/gcc/testsuite/g++.dg/modules/friend-6_a.C +++ b/gcc/testsuite/g++.dg/modules/friend-6_a.C @@ -1,11 +1,9 @@ -// { dg-additional-options "-fmodules-ts -Wno-pedantic" } +// { dg-additional-options "-fmodules-ts -Wno-modules-gmf-contents" } // { dg-module-cmi friend_6 } module; -# 1 "" 1 template struct Trans_NS___cxx11_basic_string { template friend class basic_stringbuf; }; template struct Trans_NS___cxx11_basic_string; -# 6 "" 2 export module friend_6; -- 2.44.0.rc1.15.g4fc51f00ef