From patchwork Wed Oct 9 22:47:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1995131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OJrJdYRs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XP7Tg70TWz1xvW for ; Thu, 10 Oct 2024 09:53:27 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6438E38650DB for ; Wed, 9 Oct 2024 22:53:23 +0000 (GMT) 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.129.124]) by sourceware.org (Postfix) with ESMTP id B1E753858417 for ; Wed, 9 Oct 2024 22:52:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1E753858417 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 B1E753858417 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=1728514374; cv=none; b=vbnrzeQ25tIAFP2r796JWbGcF3yO3b1GkD7J25soh+sacpHClp57Dwjt+yDGRxQyfDBUhrLySD+ugFrvckDVaVgkGyVLzaxn8ckeuohru+J7rRaK6R7AjXp7m46QmBA5bU1uOGbXcwzP/QSj+zWg0Aw/xqJSnQ9NQmdsS2QjiGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728514374; c=relaxed/simple; bh=Kb96j8DUoWQn6dTgScqFNYEknaPJDrtEPyvzSNRStIs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=vJF6RjpqcsW+Thi6F7PuhNHImZqv7tSxt1iHwvwyfOyKZ07TQ1NU4V7hNTJQwMgU63ZpPp3SDLFSXDBWjKffJTY/ed+WukNUTWSECdveGLFEyhomfD4JpdKILBztqbALRY90ZLFHe9KGSvSY6JTHNzC5l37UJrwmAE+5btxFKDI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728514372; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sc1XMAhPTKmZ4omEwFKILRPz4LzyOj1gQzrpEMKr/hY=; b=OJrJdYRsXN90z18dXTUljk1kCN/zg032DcroRMhrsoJh1wLeiAXauumj60boUeX3A/M+9l 0oGAyEMPAwb3Nm2bYQR7zz7gDUJPglz1OsJq4K8MD30rkx4IGb/DjoNgZl455CJwpBBB4h aWGUD6sc+da8xxEkTmhhBISFsSslsf4= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-jGawFLxfMsW1F9u-05FKSA-1; Wed, 09 Oct 2024 18:52:50 -0400 X-MC-Unique: jGawFLxfMsW1F9u-05FKSA-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7ac9b08cb77so56801385a.1 for ; Wed, 09 Oct 2024 15:52:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728514370; x=1729119170; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sc1XMAhPTKmZ4omEwFKILRPz4LzyOj1gQzrpEMKr/hY=; b=VDBjTPzfmRzFo4u/4qJ+DgJiHRC4rN0pVt3xGICtIaLPdShz76Fex5HItgMgTfT45H lYaGvmEGK7NrxU9x+ejugZZlMX2SxaNvLIhnvcoNwy0K+nhx1Ln0qDXKnyqJO1HUA6hC ZhrkNyEfKFsfoTJlAio1q0wUcnHW6MiGNxHbsisP07aB3C1WnBBty68QSKA61JswZ4F8 mz7dUjReHb1yv5u1WKAd2zHRDKyt1uGKDwCrqSBEI+FQnScOkTkLpoQsNhEKdrghl2RF bzGEHLjas9OTr9vtwqNJLfxZBSKvBtOMBy6MhSmyaz5XhbEzz7uvv5b5kiGi41fHE9hv QKHg== X-Gm-Message-State: AOJu0Yzvs5NeKqNjUo2vz2Lv/IDewII94AdQDU95F12n7eQDIdXLKKPR TKR1u0QFGq2XLYTP6cvVFgPvn7UB4d9ij+GpBr7QA8+YJLN2JNkdcAErMYMC0fFEKjyUjGDA/0b T3ybb0536q9mZXt70xkMxnY4x9GqHi2H7HLfwqwzCv0Nw9NybwAOv9qCYBX6pZh0hylKfgNTf+t sFRSn/PcqWUitlau2xogMCBRTXhK3HtTIz3VQ= X-Received: by 2002:a05:620a:462a:b0:7a9:aae5:331 with SMTP id af79cd13be357-7b07953e8f3mr462073285a.21.1728514370099; Wed, 09 Oct 2024 15:52:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/7CMQIzcfUuYufrvRhbW/cb4FSflFVEBr+XOkIIy5jkfUAOdMc9guBjWvrKbHTNSMoYg2Rg== X-Received: by 2002:a05:620a:462a:b0:7a9:aae5:331 with SMTP id af79cd13be357-7b07953e8f3mr462070485a.21.1728514369489; Wed, 09 Oct 2024 15:52:49 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b1148dc71dsm1531285a.34.2024.10.09.15.52.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 15:52:48 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [PATCH RFC 1/4] c-family: add -fsearch-include-path Date: Wed, 9 Oct 2024 18:47:53 -0400 Message-ID: <20241009225246.2770766-1-jason@redhat.com> X-Mailer: git-send-email 2.46.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-pc-linux-gnu. Any thoughts? -- 8< -- The C++ modules code has a -fmodule-header option to specify looking up headers to compile to header units on the usual include paths. I'd like to have the same functionality for full C++20 modules such as module std, which could also live on the include path. But this behavior doesn't seem necessarily connected to modules, so I'm proposing a general C/C++ option to specify the behavior of looking in the include path for the input files specified on the command line. Other ideas for the name of the option are very welcome. gcc/ChangeLog: * doc/cppopts.texi: Document -fsearch-include-path. gcc/c-family/ChangeLog: * c.opt: Add -fsearch-include-path. * c-opts.cc (c_common_post_options): Handle it. gcc/cp/ChangeLog: * module.cc (module_preprocess_options): Don't override it. --- gcc/doc/cppopts.texi | 11 +++++++++++ gcc/doc/invoke.texi | 5 +++++ gcc/c-family/c.opt | 7 +++++++ gcc/c-family/c-opts.cc | 13 +++++++++++++ gcc/cp/module.cc | 3 ++- 5 files changed, 38 insertions(+), 1 deletion(-) base-commit: dcee0b6547211a428b75adb03a461285fed0f20d diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi index 5b5b0848ae8..e3686b63337 100644 --- a/gcc/doc/cppopts.texi +++ b/gcc/doc/cppopts.texi @@ -270,6 +270,17 @@ When preprocessing, do not shorten system header paths with canonicalization. @item -fmax-include-depth=@var{depth} Set the maximum depth of the nested #include. The default is 200. +@opindex fsearch-include-path +@item -fsearch-include-path +Look for input files on the #include path, not just the current +directory. This is particularly useful with C++20 modules, for which +both header units and module interface units need to be compiled +directly: + +@smallexample +g++ -c -std=c++20 -fmodules-ts -fsearch-include-path bits/stdc++.h std.cppm +@end smallexample + @opindex ftabstop @item -ftabstop=@var{width} Set the distance between tab stops. This helps the preprocessor report diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index c0c8bf1c29a..c69d032323e 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -38042,6 +38042,11 @@ installed. Specifying the language as one of these variants also inhibits output of the object file, as header files have no associated object file. +Alternately, or for a module interface unit in an installed location, +you can use @option{-fsearch-include-path} to specify that the main +source file should be found on the include path rather than the +current directory. + Header units can be used in much the same way as precompiled headers (@pxref{Precompiled Headers}), but with fewer restrictions: an #include that is translated to a header unit import can appear at any diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 1f2e72a0bb7..0aada1c3080 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -2237,6 +2237,13 @@ frtti C++ ObjC++ Optimization Var(flag_rtti) Init(1) Generate run time type descriptor information. +fsearch-include-path +C ObjC C++ ObjC++ +Look for the main source file on the include path. + +fsearch-include-path= +C++ ObjC++ Joined RejectNegative Undocumented + fshort-enums C ObjC C++ ObjC++ LTO Optimization Var(flag_short_enums) Use the narrowest integer type possible for enumeration types. diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index 510e0870140..2798b4d295f 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -769,6 +769,19 @@ c_common_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, cpp_opts->traditional = 1; break; + case OPT_fsearch_include_path: + cpp_opts->main_search = CMS_user; + break; + + case OPT_fsearch_include_path_: + if (!strcmp (arg, "user")) + cpp_opts->main_search = CMS_user; + else if (!strcmp (arg, "system")) + cpp_opts->main_search = CMS_system; + else + error ("invalid argument %qs to %<-fsearch-include-path%>", arg); + break; + case OPT_v: verbose = true; break; diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 2dc59ce8a12..e58c057a96e 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -21069,7 +21069,8 @@ module_preprocess_options (cpp_reader *reader) } auto *opt = cpp_get_options (reader); opt->module_directives = true; - opt->main_search = cpp_main_search (flag_header_unit); + if (opt->main_search == CMS_none) + opt->main_search = cpp_main_search (flag_header_unit); } } From patchwork Wed Oct 9 22:47:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1995130 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Cu6c0wd0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XP7Tg5q3bz1xtv for ; Thu, 10 Oct 2024 09:53:26 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A6E5385EC13 for ; Wed, 9 Oct 2024 22:53:23 +0000 (GMT) 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.129.124]) by sourceware.org (Postfix) with ESMTP id 89653385841E for ; Wed, 9 Oct 2024 22:52:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 89653385841E 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 89653385841E 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=1728514376; cv=none; b=PRxsAt3P31H7326luqLTqqO52lDD7KVKKeRP1cPdZWvUuAAfqAheU1VEklxeRzmguD9ilL1AK15L5yBcBMHhVQwEOyYdIsG9kTXAJhZAZ9tsYky/FGryO9Tj7BqJSHa2CWv8LTkpOYB/i+xj2OPuwviYKrbnTbHfLNBT0AQ4U9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728514376; c=relaxed/simple; bh=Q4CFVyzidCHCkXrRHqIeEmD2CjEOLY0aSDZbkpJbf3A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kiWMHvmeWjR/H/jIcMWItm5JfBkXfjVwWF41dnbOjVt0EBg+EJuaPqVT0Jt3S+87fcDT0VQjSjgj4frNiu4ZbRT+cNgr9Vtlwwa2Gd3OreSYhaeCpA9soyoVg4fP28wGpt5KQBPqNrKpkwfLwgmYhgI07ooGlzQYkueEj5AsrPA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728514373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kf781uwJvFuQqYkjnzXpH873z0LMGgYQJK7H62BQzGE=; b=Cu6c0wd07Zx5UkEyRCHToROAsnv1wyjaB6MM0SsAgT76DuGcEuCq/bpfhMDGXAULFc6gLT /u9/+ydxrEChJ5k8wpU7Iafuq/uqUOh6ceOwCuS5WIuO5JiQj21HC4oc5lobTsYHZzjwLR bFzw9PeVeaMRkfCMOZGFwYRoo9tLOV8= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-mWb7Fz12NcCbrEUHbMerNA-1; Wed, 09 Oct 2024 18:52:52 -0400 X-MC-Unique: mWb7Fz12NcCbrEUHbMerNA-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7a9af65cf73so22921585a.0 for ; Wed, 09 Oct 2024 15:52:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728514371; x=1729119171; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kf781uwJvFuQqYkjnzXpH873z0LMGgYQJK7H62BQzGE=; b=ukYvYQbY/Ky2Deryfc2e0qo4wfzxz5OURhQ4LPbxCFL/5kcjwIeXCvbg9z2GJ2mGcA bA7YwfKl1mNZwWKPYfrZg5oRogshRB4CPSzPT2SY0aNjk3+Vo1Qp4PrnMqFNVtg/ok+j pAoLkpu4/Rptc8gpuStxlgbI/raNzZSqtH2QNnhW9qUWRhNzOIkJYDuCnLywAvUtwRpc Ygjeymr5oYULlHVRg2sEICs/fNgFUMGkvkLL+AdYphUunJJ98kMInvhlBppSSOyJ4lrq msZ97M/HlXC3aeceXCj3YqYUsJiE6coJz4LszdfB1PKokA3l5L54DElnMuBXc76jYPRp Cfjw== X-Gm-Message-State: AOJu0Yxq0RP6s6kqdye+wlwCF3KaKxsxN/H+r0OFzaRf4cXdIdOLNg5I TKGwGpH2mkiHG1yvWZUWNDEfGoNWTwNRa0qM/JQz0UYMEI37hIz1IfAH5/CiloeKn4ngarXbpuY 5HwKAg5Dr5JcUmiCktFCB+FCdkjderp73JQi0wnYZHXZ9d6tDib1ixJw23TkhSMGm6yTeXm9lSN 7B/yDpiR/pWA/pddjiFi/LSIMN4Nb2iI+Aelw= X-Received: by 2002:a05:620a:1a8e:b0:7a9:bd5b:eb61 with SMTP id af79cd13be357-7b07954a316mr655743085a.27.1728514371170; Wed, 09 Oct 2024 15:52:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsdIHhxwVJ2J9XCqwLva/4xBZy2SGFNVfnlYydtuTq0ay8paSDSPb76v9wBzk74A5IKkvYjA== X-Received: by 2002:a05:620a:1a8e:b0:7a9:bd5b:eb61 with SMTP id af79cd13be357-7b07954a316mr655737385a.27.1728514370352; Wed, 09 Oct 2024 15:52:50 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b1148dc71dsm1531285a.34.2024.10.09.15.52.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 15:52:49 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [PATCH RFC 2/4] c++: add internal --header flag Date: Wed, 9 Oct 2024 18:47:54 -0400 Message-ID: <20241009225246.2770766-2-jason@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241009225246.2770766-1-jason@redhat.com> References: <20241009225246.2770766-1-jason@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-pc-linux-gnu. Any other ideas for how to communicate headerness to the front-end? -- 8< -- C++20 modules support has depended on the driver seeing the -fmodules-ts flag in order to implicitly add other flags. This won't work when we start enabling modules support by default; it's better to leave it up to the front-end to decide what behaviors are implied by modules. But for header units to be generated properly, we still need some way for the driver to communicate to the front-end that we're dealing with a header. We could almost exploit the --output-pch flag for this, but that doesn't help with preprocessed output, including during -save-temps. So this patch adds an internal --header flag for communication between the driver and the front-end. Users are not expected to pass this flag themselves. The patch then removes all -fmodules-ts checks from C++ lang-spec.h in favor of a few lines in c_common_post_options. It also replaces -fmodule-header= with -fsearch-include-path= and adds --header as appropriate. Instead of implying -fdirectives-only when preprocessing a header unit, this patch implies only -dD, which seems like enough to transmit the macro definitions to the eventual header unit CMI. Before this change, legacy-3_b.H got neither -fdirectives-only nor -dD because lang-specs was only checking for -fmodules-ts, not -fmodule-header. After this change it has -dD active, so I needed to add some blank lines as suggested by the comment, and adjust the expected line numbers accordingly. gcc/ChangeLog: * doc/invoke.texi: Update module header preprocessing guidance. gcc/c-family/ChangeLog: * c.opt: Add --header. * c-opts.cc (c_common_post_options): Use it to enable modules header unit mode. gcc/cp/ChangeLog: * lang-specs.h: Use --header and -fsearch-include-path instead of -fmodule-header and checking -fmodules-ts. * module.cc (init_modules): Update PCH comment. (handle_module_option): -fmodule-header implies --header. gcc/testsuite/ChangeLog: * g++.dg/modules/legacy-3_b.H: Adjust for -dD. --- gcc/doc/invoke.texi | 15 ++++---- gcc/c-family/c.opt | 3 ++ gcc/cp/lang-specs.h | 42 ++++++++--------------- gcc/c-family/c-opts.cc | 12 +++++++ gcc/cp/module.cc | 4 +-- gcc/testsuite/g++.dg/modules/legacy-3_b.H | 6 +++- 6 files changed, 46 insertions(+), 36 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index c69d032323e..b27e85bc38a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -38235,14 +38235,17 @@ does not require macro expansion, so it is not necessary to use @option{-MD}. See also @option{-fdeps-*} for an alternate format for module dependency information. -The @option{-save-temps} option uses @option{-fdirectives-only} for -preprocessing, and preserve the macro definitions in the preprocessed -output. Usually you also want to use this option when explicitly -preprocessing a header-unit, or consuming such preprocessed output: +Preprocessing a header with modules enabled implicitly enables +@option{-dD} so that if the preprocessed output is then compiled to +produce a header unit, the macro definitions are included. In that +second compilation you also need to tell the compiler that it's a +preprocessed header; the simplest way to do that is compiling the +@samp{.ii} file (which implies @option{-x c++-cpp-output}) with +@option{-fmodule-header}. @smallexample -g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii -g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii +g++ -fmodules-ts -E my-header.hh -o my-header.ii +g++ -c -fmodule-header my-header.ii @end smallexample @node C++ Compiled Module Interface diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 0aada1c3080..6056dbde4b4 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -76,6 +76,9 @@ C ObjC C++ ObjC++ Separate Alias(-embed-dir=) MissingArgError(missing path after -embed-directory= C ObjC C++ ObjC++ Joined Alias(-embed-dir=) MissingArgError(missing path after %qs) +-header +C ObjC C++ ObjC++ Undocumented Var(flag_header) + -imacros C ObjC C++ ObjC++ Separate Alias(imacros) MissingArgError(missing filename after %qs) diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h index e5651567a2d..b6ed85c399c 100644 --- a/gcc/cp/lang-specs.h +++ b/gcc/cp/lang-specs.h @@ -46,63 +46,51 @@ along with GCC; see the file COPYING3. If not see {".c++m", "@c++", 0, 0, 0}, {".ccm", "@c++", 0, 0, 0}, {"@c++-header", - "%{E|M|MM:cc1plus -E %{fmodules-ts:-fdirectives-only -fmodule-header}" + "%{E|M|MM:cc1plus -E --header" " %(cpp_options) %2 %(cpp_debug_options)}" "%{!E:%{!M:%{!MM:" - " %{save-temps*|no-integrated-cpp:cc1plus -E" - " %{fmodules-ts:-fdirectives-only -fmodule-header}" + " %{save-temps*|no-integrated-cpp:cc1plus -E --header" " %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}" " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed" - " %{fmodules-ts:-fdirectives-only}" " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}" " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}" - " %{fmodules-ts:-fmodule-header %{fpreprocessed:-fdirectives-only}}" - " %(cc1_options) %2" + " %(cc1_options) %2 --header" " %{!fsyntax-only:" " %{!S:-o %g.s}" - " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:" - " %{!o*:--output-pch %w%i.gch}%W{o*:--output-pch %w%*}}}}%{!S:%V}}" + " %{!fdump-ada-spec*:" + " %{!o*:--output-pch %w%i.gch}%W{o*:--output-pch %w%*}}%{!S:%V}}" "}}}", CPLUSPLUS_CPP_SPEC, 0, 0}, {"@c++-system-header", - "%{E|M|MM:cc1plus -E" - " %{fmodules-ts:-fdirectives-only -fmodule-header=system}" + "%{E|M|MM:cc1plus -E --header -fsearch-include-path=system" " %(cpp_options) %2 %(cpp_debug_options)}" "%{!E:%{!M:%{!MM:" - " %{save-temps*|no-integrated-cpp:cc1plus -E" - " %{fmodules-ts:-fdirectives-only -fmodule-header=system}" + " %{save-temps*|no-integrated-cpp:cc1plus -E --header" " %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}" " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed" - " %{fmodules-ts:-fdirectives-only}" " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}" " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}" - " %{fmodules-ts:-fmodule-header=system" - " %{fpreprocessed:-fdirectives-only}}" - " %(cc1_options) %2" + " %(cc1_options) %2 --header -fsearch-include-path=system" " %{!fsyntax-only:" " %{!S:-o %g.s}" - " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:" - " %{!o*:--output-pch %w%i.gch}%W{o*:--output-pch %w%*}}}}%{!S:%V}}" + " %{!fdump-ada-spec*:" + " %{!o*:--output-pch %w%i.gch}%W{o*:--output-pch %w%*}}%{!S:%V}}" "}}}", CPLUSPLUS_CPP_SPEC, 0, 0}, {"@c++-user-header", - "%{E|M|MM:cc1plus -E" - " %{fmodules-ts:-fdirectives-only -fmodule-header=user}" + "%{E|M|MM:cc1plus -E --header -fsearch-include-path=user" " %(cpp_options) %2 %(cpp_debug_options)}" "%{!E:%{!M:%{!MM:" - " %{save-temps*|no-integrated-cpp:cc1plus -E" - " %{fmodules-ts:-fdirectives-only -fmodule-header=user}" + " %{save-temps*|no-integrated-cpp:cc1plus -E --header" " %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}" " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed" - " %{fmodules-ts:-fdirectives-only}" " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}" " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}" - " %{fmodules-ts:-fmodule-header=user %{fpreprocessed:-fdirectives-only}}" - " %(cc1_options) %2" + " %(cc1_options) %2 --header -fsearch-include-path=user" " %{!fsyntax-only:" " %{!S:-o %g.s}" - " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:" - " %{!o*:--output-pch %w%i.gch}%W{o*:--output-pch %w%*}}}}%{!S:%V}}" + " %{!fdump-ada-spec*:" + " %{!o*:--output-pch %w%i.gch}%W{o*:--output-pch %w%*}}%{!S:%V}}" "}}}", CPLUSPLUS_CPP_SPEC, 0, 0}, {"@c++", diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index 2798b4d295f..c7115e63ce7 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -1209,6 +1209,18 @@ c_common_post_options (const char **pfilename) error ("too many filenames given; type %<%s %s%> for usage", progname, "--help"); + if (flag_modules && flag_header) + { + flag_header_unit = true; + /* Ignore --output-pch. */ + pch_file = NULL; + + /* Preserve macros so that they go in the header unit when we feed + the preprocessed output back to the compiler. */ + if (flag_preprocess_only) + flag_dump_macros = 'D'; + } + if (flag_preprocess_only) { /* Open the output now. We must do so even if flag_no_output is diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index e58c057a96e..c43aa9dc324 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -20524,8 +20524,7 @@ maybe_add_global (tree val, unsigned &crc) void init_modules (cpp_reader *reader) { - /* PCH should not be reachable because of lang-specs, but the - user could have overriden that. */ + /* We should have cleared this in c_common_post_options. */ if (pch_file) fatal_error (input_location, "C++ modules are incompatible with precompiled headers"); @@ -21030,6 +21029,7 @@ handle_module_option (unsigned code, const char *str, int) case OPT_fmodule_header: flag_header_unit = hdr; + flag_header = 1; flag_modules = 1; return true; diff --git a/gcc/testsuite/g++.dg/modules/legacy-3_b.H b/gcc/testsuite/g++.dg/modules/legacy-3_b.H index 3bf819db661..145bfbbddd1 100644 --- a/gcc/testsuite/g++.dg/modules/legacy-3_b.H +++ b/gcc/testsuite/g++.dg/modules/legacy-3_b.H @@ -5,6 +5,10 @@ // Enough blank lines to force a line sync before the legacy import + + + + // this should be diverted, if it isn't the above #define will break us #include "legacy-3_a.H" int move (int X = __LINE__); // Capture __LINE__ in a non-definition @@ -12,5 +16,5 @@ int move (int X = __LINE__); // Capture __LINE__ in a non-definition // this should not be diverted #include "legacy-3.h" -// { dg-final { scan-file legacy-3_b.i {\n# 9 "[^\n]*legacy-3_b.H"\nimport "[^\n]*legacy-3_a.H" \[\[__translated\]\];\nint move \(int X = 10\);\n} } } +// { dg-final { scan-file legacy-3_b.i {\n# 13 "[^\n]*legacy-3_b.H"\nimport "[^\n]*legacy-3_a.H" \[\[__translated\]\];\nint move \(int X = 14\);\n} } } From patchwork Wed Oct 9 22:47:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1995133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Xn6HFj/r; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XP7Vm21GWz1xtv for ; Thu, 10 Oct 2024 09:54:24 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D200385DDF3 for ; Wed, 9 Oct 2024 22:54:22 +0000 (GMT) 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.129.124]) by sourceware.org (Postfix) with ESMTP id 055273858433 for ; Wed, 9 Oct 2024 22:52:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 055273858433 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 055273858433 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=1728514377; cv=none; b=to50BywqjLH7u24XjnW7o14PCQPCCgP938zZ/tLsklfIe5vVsZglwu++k6PRqJDOGV6juA7/t83Qc1sMNO1ALuOBn7TBRyC4L04Xq8zrB6rfyc39rlu8NmlBp+I4e4E72k+qO4gkAdhSL/Vo1BvGfyFUCpKByJwXKd8Tg8AWT10= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728514377; c=relaxed/simple; bh=jf+CXnAjvwInBApPXL9bMc9tuAzxGkJbhJtNBBIwv4s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=x5FMG8tMwWH1OB5KcKZh5B3ZLuA9dAWv2FwwrcQz4/2EIl4B3w50YcDo5uJaspg8cTvFuArH7DT3v0HjPirDOqn69zLfHs/TtXPizW+/FMpuHrbdrfEh8M8Kq79BNRny1y9g+YD9xpbUfv1bwrwM+jy+e9xsjCFKZEPzvmi9DMA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728514374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2iQdSbHW+Kx/hBK3Dm5PQQxuSwh+/We6afhTXEQp4to=; b=Xn6HFj/rnsm1t8KBVwOZm/a2pQB1qQATLzTiWOsOWPst0RmztEWS7OPh2dLfWnj9mDQkdS mujxuiVgx0X57IJ2GwDaoZDhwnhskG4Js9OLXPip87IvEHrLazAgxQDX8ysX6mIQn0RHlR 8elCu9mimj9h35ZLCh2ypj4c08vvqFw= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-41-3roR1RDdPXa6qLmhVpNIYw-1; Wed, 09 Oct 2024 18:52:53 -0400 X-MC-Unique: 3roR1RDdPXa6qLmhVpNIYw-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7a9a74d39b5so46469385a.2 for ; Wed, 09 Oct 2024 15:52:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728514372; x=1729119172; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2iQdSbHW+Kx/hBK3Dm5PQQxuSwh+/We6afhTXEQp4to=; b=mGan1mWtXm76X3AmfCnuQSTkSorA9BTqAUSGXaDvWGmClekijY2sqdYZ2p2cImxa0z fh+ohzkWovRsQGWvpgG+LJKwwaBPvsN7gHS7EyZNB/IRpky0oiC03jUu+ZBrUZz6UJLu gUg3UqX9J/3RLxZPCRPoNZ7wPSHHTZgFjIzdqJ+62Kux9BKulV3cOTgQa3lN2J08UTU8 GDANNKDh6F03zqLZDSn5rhzhp1aj2J7qMPKFkYOtL4NgfF84jNv/Z/11nXir5hxrT19k kW11LrfSAJmT3jcAx4yDtYDdazz77t264rIUj6G+zhUarnqw0Wj61oa92uPqNhsX51mQ RlPw== X-Gm-Message-State: AOJu0Yy/8ArjF3fO4Xst+k3bqONW99GmsLQKtmhIiotpv04dXNxUZsll pfiqd35fO2URpaE8CmiikETvRzBOa/Hr15pAIikKFG0lUFoUAduT1YV0gISziPdRB4545IMdZTJ l+GjEtVOFI2nDHzMTRn7ARHZDS1HOToKaJMu/7yA+peEnE9irtnx5/CYMsMBFzVlGFYuMWVzzFT B0i93jepW3vi0qjdL4Ml8lb6+icj209HIcYN8= X-Received: by 2002:a05:620a:1983:b0:79d:6dd8:f420 with SMTP id af79cd13be357-7b111ccb74amr271025885a.7.1728514371981; Wed, 09 Oct 2024 15:52:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGL1Ykl7SaIoQHBEosH00Vz/VNu0J+GWcPKM0gR7AQJQ0Gm0O2++l6pAAeoh8cgaDvVCA9TAw== X-Received: by 2002:a05:620a:1983:b0:79d:6dd8:f420 with SMTP id af79cd13be357-7b111ccb74amr271021685a.7.1728514371222; Wed, 09 Oct 2024 15:52:51 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b1148dc71dsm1531285a.34.2024.10.09.15.52.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 15:52:50 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/4] libcpp: avoid extra spaces in module preprocessing Date: Wed, 9 Oct 2024 18:47:55 -0400 Message-ID: <20241009225246.2770766-3-jason@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241009225246.2770766-1-jason@redhat.com> References: <20241009225246.2770766-1-jason@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-pc-linux-gnu, will apply to trunk with the rest of this patch series. -- 8< -- Within the compiler, module keywords "import", "module", and "export" that are recognized as part of module directives gain an extra trailing space to distinguish them from other non-keyword uses of those words in the code. But when dumping preprocessed output, printing those spaces creates a gratuitous inconsistency with non-modules preprocessing, as revealed by several of the g++.dg/modules/cpp* tests if modules are enabled by default in C++20 mode. libcpp/ChangeLog: * lex.cc (cpp_output_token): Omit terminal space from name. gcc/testsuite/ChangeLog: * g++.dg/modules/cpp-2_c.C: Expect only one space after import. * g++.dg/modules/cpp-5_c.C * g++.dg/modules/dep-2.C * g++.dg/modules/dir-only-2_b.C * g++.dg/modules/pr99050_b.C * g++.dg/modules/inc-xlate-1_b.H * g++.dg/modules/legacy-3_b.H * g++.dg/modules/legacy-3_c.H: Likewise. --- gcc/testsuite/g++.dg/modules/cpp-2_c.C | 2 +- gcc/testsuite/g++.dg/modules/cpp-5_c.C | 2 +- gcc/testsuite/g++.dg/modules/dep-2.C | 2 +- gcc/testsuite/g++.dg/modules/dir-only-2_b.C | 10 +++++----- gcc/testsuite/g++.dg/modules/pr99050_b.C | 2 +- libcpp/lex.cc | 7 +++++-- gcc/testsuite/g++.dg/modules/inc-xlate-1_b.H | 2 +- gcc/testsuite/g++.dg/modules/legacy-3_b.H | 2 +- gcc/testsuite/g++.dg/modules/legacy-3_c.H | 2 +- 9 files changed, 17 insertions(+), 14 deletions(-) diff --git a/gcc/testsuite/g++.dg/modules/cpp-2_c.C b/gcc/testsuite/g++.dg/modules/cpp-2_c.C index c6e02b7800a..2a79031eb34 100644 --- a/gcc/testsuite/g++.dg/modules/cpp-2_c.C +++ b/gcc/testsuite/g++.dg/modules/cpp-2_c.C @@ -11,7 +11,7 @@ import nope; #endif think -// { dg-final { scan-file cpp-2_c.i {cpp-2_c.C"\n\n\n\nmodule bob;\n#pragma GCC unused\nimport "[^\n]*\./cpp-2_b.H" \[\[ CLOSE ]];\nimport "[^\n]*cpp-2_a.H" \[\[ ]];\n} } } +// { dg-final { scan-file cpp-2_c.i {cpp-2_c.C"\n\n\n\nmodule bob;\n#pragma GCC unused\nimport "[^\n]*\./cpp-2_b.H" \[\[ CLOSE ]];\nimport "[^\n]*cpp-2_a.H" \[\[ ]];\n} } } // { dg-final { scan-file cpp-2_c.i "int i;" } } // { dg-final { scan-file-not cpp-2_c.i "import *nope;" } } // { dg-final { scan-file cpp-2_c.i "THIS IS STDIO\n" } } diff --git a/gcc/testsuite/g++.dg/modules/cpp-5_c.C b/gcc/testsuite/g++.dg/modules/cpp-5_c.C index e0a78a516ae..7f75a228cda 100644 --- a/gcc/testsuite/g++.dg/modules/cpp-5_c.C +++ b/gcc/testsuite/g++.dg/modules/cpp-5_c.C @@ -7,4 +7,4 @@ import "cpp-5_a.H"; Q -// { dg-final { scan-file cpp-5_c.i {\nimport "[^\n]*cpp-5_a.H";\n\n0\n} } } +// { dg-final { scan-file cpp-5_c.i {\nimport "[^\n]*cpp-5_a.H";\n\n0\n} } } diff --git a/gcc/testsuite/g++.dg/modules/dep-2.C b/gcc/testsuite/g++.dg/modules/dep-2.C index 2dccab3554d..3c869755785 100644 --- a/gcc/testsuite/g++.dg/modules/dep-2.C +++ b/gcc/testsuite/g++.dg/modules/dep-2.C @@ -9,4 +9,4 @@ module m:part; // { dg-final { scan-file dep-2.d {\ngcm.cache/m:part\.gcm:| dep-2\.o} } } // { dg-final { scan-file dep-2.d {\n\.PHONY: m:part\.c\+\+-module} } } -// { dg-final { scan-file dep-2.i {\nmodule m:part;\n} } } +// { dg-final { scan-file dep-2.i {\nmodule m:part;\n} } } diff --git a/gcc/testsuite/g++.dg/modules/dir-only-2_b.C b/gcc/testsuite/g++.dg/modules/dir-only-2_b.C index 1009ae5b3a2..b1ef9b95e58 100644 --- a/gcc/testsuite/g++.dg/modules/dir-only-2_b.C +++ b/gcc/testsuite/g++.dg/modules/dir-only-2_b.C @@ -21,8 +21,8 @@ export module bob; export import q; -// { dg-final { scan-file dir-only-2_b.i {// a comment\nmodule ;\nfrob} } } -// { dg-final { scan-file dir-only-2_b.i {frob\nexport\nimport foo;\nimport 7;} } } -// { dg-final { scan-file dir-only-2_b.i {import "[^\n]*/dir-only-2_a.H";\nimport "[^\n]*/dir-only-2_a.H";\nX} } } -// { dg-final { scan-file dir-only-2_b.i {export module bob;\n\nexport import q;} } } -// { dg-final { scan-file dir-only-2_b.i {import sing;\n\n\n// comment} } } +// { dg-final { scan-file dir-only-2_b.i {// a comment\nmodule;\nfrob} } } +// { dg-final { scan-file dir-only-2_b.i {frob\nexport\nimport foo;\nimport 7;} } } +// { dg-final { scan-file dir-only-2_b.i {import "[^\n]*/dir-only-2_a.H";\nimport "[^\n]*/dir-only-2_a.H";\nX} } } +// { dg-final { scan-file dir-only-2_b.i {export module bob;\n\nexport import q;} } } +// { dg-final { scan-file dir-only-2_b.i {import sing;\n\n\n// comment} } } diff --git a/gcc/testsuite/g++.dg/modules/pr99050_b.C b/gcc/testsuite/g++.dg/modules/pr99050_b.C index 439e216eb16..f2c95631321 100644 --- a/gcc/testsuite/g++.dg/modules/pr99050_b.C +++ b/gcc/testsuite/g++.dg/modules/pr99050_b.C @@ -4,4 +4,4 @@ int main () {} -// { dg-final { scan-file pr99050_b.i {import "[^\n]*99050_a.H" \[\[__translated\]\];\n} } } +// { dg-final { scan-file pr99050_b.i {import "[^\n]*99050_a.H" \[\[__translated\]\];\n} } } diff --git a/libcpp/lex.cc b/libcpp/lex.cc index 4025e5cd3d9..57c339a753a 100644 --- a/libcpp/lex.cc +++ b/libcpp/lex.cc @@ -4444,14 +4444,17 @@ cpp_output_token (const cpp_token *token, FILE *fp) { size_t i; const unsigned char * name = NODE_NAME (token->val.node.node); - - for (i = 0; i < NODE_LEN (token->val.node.node); i++) + unsigned len = NODE_LEN (token->val.node.node); + + for (i = 0; i < len; i++) if (name[i] & ~0x7F) { unsigned char buffer[10]; i += utf8_to_ucn (buffer, name + i) - 1; fwrite (buffer, 1, 10, fp); } + else if (name[i] == ' ' && i == len - 1) + /* Omit terminal space in "export ". */; else fputc (NODE_NAME (token->val.node.node)[i], fp); } diff --git a/gcc/testsuite/g++.dg/modules/inc-xlate-1_b.H b/gcc/testsuite/g++.dg/modules/inc-xlate-1_b.H index 50b27efa7ef..872ebf3de98 100644 --- a/gcc/testsuite/g++.dg/modules/inc-xlate-1_b.H +++ b/gcc/testsuite/g++.dg/modules/inc-xlate-1_b.H @@ -18,4 +18,4 @@ extern "C" { #endif #endif -// { dg-final { scan-file inc-xlate-1_b.i {import "[^\n]*inc-xlate-1_a.H" \[\[__translated\]\];\n} } } +// { dg-final { scan-file inc-xlate-1_b.i {import "[^\n]*inc-xlate-1_a.H" \[\[__translated\]\];\n} } } diff --git a/gcc/testsuite/g++.dg/modules/legacy-3_b.H b/gcc/testsuite/g++.dg/modules/legacy-3_b.H index 145bfbbddd1..52eecd72c68 100644 --- a/gcc/testsuite/g++.dg/modules/legacy-3_b.H +++ b/gcc/testsuite/g++.dg/modules/legacy-3_b.H @@ -16,5 +16,5 @@ int move (int X = __LINE__); // Capture __LINE__ in a non-definition // this should not be diverted #include "legacy-3.h" -// { dg-final { scan-file legacy-3_b.i {\n# 13 "[^\n]*legacy-3_b.H"\nimport "[^\n]*legacy-3_a.H" \[\[__translated\]\];\nint move \(int X = 14\);\n} } } +// { dg-final { scan-file legacy-3_b.i {\n# 13 "[^\n]*legacy-3_b.H"\nimport "[^\n]*legacy-3_a.H" \[\[__translated\]\];\nint move \(int X = 14\);\n} } } diff --git a/gcc/testsuite/g++.dg/modules/legacy-3_c.H b/gcc/testsuite/g++.dg/modules/legacy-3_c.H index 56b81722997..63c9bcf7078 100644 --- a/gcc/testsuite/g++.dg/modules/legacy-3_c.H +++ b/gcc/testsuite/g++.dg/modules/legacy-3_c.H @@ -17,7 +17,7 @@ MARK3 __LINE__ // this should not be translated #include "legacy-3.h" -// { dg-final { scan-file legacy-3_c.i {MARK1 8\nimport "[^\n]*legacy-3_a.H" \[\[__translated\]\];\nMARK2 10\n} } } +// { dg-final { scan-file legacy-3_c.i {MARK1 8\nimport "[^\n]*legacy-3_a.H" \[\[__translated\]\];\nMARK2 10\n} } } // We should have stopped. // { dg-final { scan-file legacy-3_c.i {move} } } // { dg-final { scan-file legacy-3_c.i {MARK2 13\n\nMARK3 15\n} } } From patchwork Wed Oct 9 22:47:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1995132 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SaX5vSIk; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XP7Tt6CX5z1xtv for ; Thu, 10 Oct 2024 09:53:38 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E8D138650E9 for ; Wed, 9 Oct 2024 22:53:37 +0000 (GMT) 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.129.124]) by sourceware.org (Postfix) with ESMTP id 962EF385E459 for ; Wed, 9 Oct 2024 22:52:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 962EF385E459 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 962EF385E459 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=1728514383; cv=none; b=JVW+SzIgkrtbHdF6dfV3ry2V2hf6aBgDDYT1bvSDlSSJGlsSXWmpJUq1QWs9g2iH9Ac9kqc7MVKNJ0ghdM1wpKDdRr7ERcX0uS/+sDd92fuxj6oqDMV5mAkb/yGnpfxwtW2NkSw5K6c+OZSzXdYr3fTXkHclWu4UVRKkJl+Tcxg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728514383; c=relaxed/simple; bh=SUUTjDhKwUcUDdiuEitLOJTuIUmfoB88x4iZKC3Y7Lk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AgyVSbQZsnhOdne80DDj7/Mgz66f8b8jEeiV21HruQvvN8rUoyC5qdzSmNSwpp8MP6BrxTlwT8TZqvFatYMd9J8Baud1wKjvGC8rJZI5iAZd4dNd2eYTXOS/El6dn2SODDvw0SIAsgXQtnZIi/+hSZYZI7o0+OtJEGuxmf+CZ24= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728514378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=imfxclYFSk7KcoFdnHywszw3xgVtFagS8DPCMgAt+ZI=; b=SaX5vSIk7WouFyn/AuJUkofS6UhmLkE48fAN0is6K663oTMK46yk02ANNoswL+P6XyUBLo 3c96bXvOnfROVt28GpqEhQKIr6Qj7w1yLr1DNLo27E+2GQ4Hwp2CosO0Ini2g/2szahLls Gje641C52rGLtE1VmhgzbEoxNHMKYbY= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-101-t4FmDOtQOaKmONxg6oXOBw-1; Wed, 09 Oct 2024 18:52:55 -0400 X-MC-Unique: t4FmDOtQOaKmONxg6oXOBw-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7afcea583caso39500785a.2 for ; Wed, 09 Oct 2024 15:52:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728514373; x=1729119173; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=imfxclYFSk7KcoFdnHywszw3xgVtFagS8DPCMgAt+ZI=; b=xIMQ93ZCKFodW8Jq7wWCDWpGl2D2tmyAVAG6O+AUT1k/eFrxeN0RK2ue/GTpisjBmB g1CDBO1EwopvXCodo7lg4iipNGkIs0RV4a2hBZ5abBDtxasfjd0tavlK5zQPJKa0b12H AWfBvhmBA7Lyr4lpK53FqOuwsn1LVIBQ0Q5dJ+0pGjwcinU2ViiuphUWXTrcqHcyeqdc PHFq4MjCDOFhSTI6WJUlfH7aavYR2I8lKxabd+V3ov3cr1K4GSf+B2/wz3OM6u1cJDbM T5nL6NpvftQfvGwaN7T/GaiprCcFZUrXKppSpFYcqCTFDVVoWzf4HRv4NC1ORKTlYjCe P3LQ== X-Gm-Message-State: AOJu0YyPpgRTEG/Zx6weKPl/b2tyIIc9PZUICid6qMMaxnqqssbxxrt2 /I06ZpVbzEvivKMg+EQ7Z2aJxu6vgo6s2sjXv8ikYcaxI1Bmq0NBR+x343QzP6HZ84cGJAXmse4 jeZ0FxmtG9whGKI1EiP4rHM/o4t19eIoyF5qKahKZq9cQslaiMGjLmU1V80JF/+9HICJK8OOjcv yW8vDX8bHmJD2p1Ep8uKrOohXub2irGmj+qi0= X-Received: by 2002:a05:620a:4453:b0:79f:15ca:b782 with SMTP id af79cd13be357-7b07955194dmr413350485a.35.1728514372504; Wed, 09 Oct 2024 15:52:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbh7/Aim9f93hkzqfQ1ebj7is5A5+YpGK0RO1owBYnFkJgG8KcvYhfTJ48A2CYcvMvo/gUyw== X-Received: by 2002:a05:620a:4453:b0:79f:15ca:b782 with SMTP id af79cd13be357-7b07955194dmr413347885a.35.1728514371825; Wed, 09 Oct 2024 15:52:51 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b1148dc71dsm1531285a.34.2024.10.09.15.52.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 15:52:51 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [PATCH 4/4] c++: enable modules by default in c++20 Date: Wed, 9 Oct 2024 18:47:56 -0400 Message-ID: <20241009225246.2770766-4-jason@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241009225246.2770766-1-jason@redhat.com> References: <20241009225246.2770766-1-jason@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-pc-linux-gnu, will apply to trunk with the rest of the patch series. -- 8< -- At this point there doesn't seem to be much reason not to have modules support enabled by default in C++20, and it's good get more test coverage to find corner case bugs like some I fixed recently. It also seems to make more sense to use the spelling -fmodules rather than -fmodules-ts, much like we moved from -fconcepts-ts to -fconcepts. The old spelling is still accepted for backward compatibility. gcc/ChangeLog: * doc/invoke.texi: Modules are now enabled by default in C++20. Change advertised flag from -fmodules-ts to -fmodules. gcc/c-family/ChangeLog: * c.opt: Change advertised flag from -fmodules-ts to -fmodules. * c-opts.cc (c_common_post_options): Enable modules by default in C++20. gcc/testsuite/ChangeLog: * g++.dg/template/error25.C: Adjust 'export' diagnostic. * g++.old-deja/g++.benjamin/tem05.C: Likewise. * g++.old-deja/g++.pt/export1.C: Likewise. * g++.dg/pch/pch.exp: Specify -fno-modules. --- gcc/doc/invoke.texi | 32 +++++++++---------- gcc/c-family/c.opt | 10 +++--- gcc/c-family/c-opts.cc | 6 +++- gcc/testsuite/g++.dg/template/error25.C | 2 +- .../g++.old-deja/g++.benjamin/tem05.C | 8 ++--- gcc/testsuite/g++.old-deja/g++.pt/export1.C | 2 +- gcc/testsuite/g++.dg/pch/pch.exp | 2 +- 7 files changed, 32 insertions(+), 30 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index b27e85bc38a..29fd99fff92 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -223,7 +223,7 @@ in the following sections. -fno-implicit-templates -fno-implicit-inline-templates -fno-implement-inlines --fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts +-fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules -fmodule-implicit-inline -fno-module-lazy -fmodule-mapper=@var{specification} @@ -3501,14 +3501,12 @@ To save space, do not emit out-of-line copies of inline functions controlled by @code{#pragma implementation}. This causes linker errors if these functions are not inlined everywhere they are called. -@opindex fmodules-ts -@opindex fno-modules-ts -@item -fmodules-ts -@itemx -fno-modules-ts -Enable support for C++20 modules (@pxref{C++ Modules}). The -@option{-fno-modules-ts} is usually not needed, as that is the -default. Even though this is a C++20 feature, it is not currently -implicitly enabled by selecting that standard version. +@opindex fmodules +@opindex fno-modules +@item -fmodules +@itemx -fno-modules +Enable support for C++20 modules (@pxref{C++ Modules}). This flag is +enabled by default for C++20 and above. @opindex fmodule-header @item -fmodule-header @@ -38004,9 +38002,9 @@ affected by how you partition header files into header units. @end table -Modular compilation is @emph{not} enabled with just the -@option{-std=c++20} option. You must explicitly enable it with the -@option{-fmodules-ts} option. It is independent of the language +Modular compilation is enabled with the @option{-std=c++20} option. +You can also enable or disable it explicitly with the +@option{-fmodules} option. It is independent of the language version selected, although in pre-C++20 versions, it is of course an extension. @@ -38024,7 +38022,7 @@ Acyclic Graph (DAG). You must build imports before the importer. Header files may themselves be compiled to header units, which are a transitional ability aiming at faster compilation. The @option{-fmodule-header} option is used to enable this, and implies -the @option{-fmodules-ts} option. These CMIs are named by the fully +the @option{-fmodules} option. These CMIs are named by the fully resolved underlying header file, and thus may be a complete pathname containing subdirectories. If the header file is found at an absolute pathname, the CMI location is still relative to a CMI root directory. @@ -38033,7 +38031,7 @@ As header files often have no suffix, you commonly have to specify a @option{-x} option to tell the compiler the source is a header file. You may use @option{-x c++-header}, @option{-x c++-user-header} or @option{-x c++-system-header}. When used in conjunction with -@option{-fmodules-ts}, these all imply an appropriate +@option{-fmodules}, these all imply an appropriate @option{-fmodule-header} option. The latter two variants use the user or system include path to search for the file specified. This allows you to, for instance, compile standard library header files as @@ -38056,8 +38054,8 @@ the bits/stdc++.h header used for libstdc++ precompiled headers you can @smallexample -g++ -fmodules-ts -x c++-system-header -c bits/stdc++.h -g++ -fmodules-ts -include bits/stdc++.h mycode.C +g++ -fmodules -x c++-system-header -c bits/stdc++.h +g++ -fmodules -include bits/stdc++.h mycode.C @end smallexample and any standard library #includes in mycode.C will be skipped, @@ -38244,7 +38242,7 @@ preprocessed header; the simplest way to do that is compiling the @option{-fmodule-header}. @smallexample -g++ -fmodules-ts -E my-header.hh -o my-header.ii +g++ -fmodules -E my-header.hh -o my-header.ii g++ -c -fmodule-header my-header.ii @end smallexample diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 6056dbde4b4..ade49b8cb65 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1997,12 +1997,12 @@ flax-vector-conversions C ObjC C++ ObjC++ Var(flag_lax_vector_conversions) Allow implicit conversions between vectors with differing numbers of subparts and/or differing element types. -fmodules-ts -C++ ObjC++ Var(flag_modules) Integer Init(0) -Enable C++ modules-ts (experimental). +fmodules +C++ ObjC++ Var(flag_modules) Integer +Enable C++20 Modules (experimental). -fno-modules -C++ ObjC++ Undocumented RejectNegative Var(flag_modules,0) Integer +fmodules-ts +C++ ObjC++ Alias(fmodules) Undocumented ;; undocumented fmodule-header diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index c7115e63ce7..4be6259979d 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -1183,7 +1183,11 @@ c_common_post_options (const char **pfilename) /* C++20 is the final version of concepts. We still use -fconcepts to know when concepts are enabled. */ if (cxx_dialect >= cxx20) - flag_concepts = 1; + { + flag_concepts = 1; + if (!OPTION_SET_P (flag_modules)) + flag_modules = true; + } /* Enable lifetime extension of range based for temporaries for C++23. Diagnose -std=c++23 -fno-range-for-ext-temps. */ diff --git a/gcc/testsuite/g++.dg/template/error25.C b/gcc/testsuite/g++.dg/template/error25.C index 77b59cd7ca2..6aaf67471b5 100644 --- a/gcc/testsuite/g++.dg/template/error25.C +++ b/gcc/testsuite/g++.dg/template/error25.C @@ -12,5 +12,5 @@ extern void f2 (); template<> extern void f2 (); // { dg-error "explicit template specialization cannot have a storage class" } -export template // { dg-warning "keyword 'export'" } +export template // { dg-message "'export'" } static void* f3 (); diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C index 7b6b955383b..81fb5c4c069 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C @@ -18,7 +18,7 @@ // 1 // template definition -export template // { dg-warning "" } +export template // { dg-message "export" } bool templ_one(T a) { if (a > 0) return true; @@ -41,15 +41,15 @@ public: template bool compare_ge(T2 test); }; -export template // { dg-warning "" } +export template // { dg-message "export" } const bool X_one::is_specialized = false; -export template // { dg-warning "" } +export template // { dg-message "export" } unsigned short X_one::ret_id() { return id; } -export template // { dg-warning "" } +export template // { dg-message "export" } bool compare_ge(T2 test) { if (test > type) // { dg-error "" } .* return true; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/export1.C b/gcc/testsuite/g++.old-deja/g++.pt/export1.C index 53e7e9b160c..e79785424d2 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/export1.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/export1.C @@ -15,4 +15,4 @@ return 0; } template class Y; -export template class X; // { dg-warning "" } export not implemented +export template class X; // { dg-message "export" } export not implemented diff --git a/gcc/testsuite/g++.dg/pch/pch.exp b/gcc/testsuite/g++.dg/pch/pch.exp index a443e8fc392..5e3e9b1fdd2 100644 --- a/gcc/testsuite/g++.dg/pch/pch.exp +++ b/gcc/testsuite/g++.dg/pch/pch.exp @@ -31,7 +31,7 @@ set old_dg_do_what_default "${dg-do-what-default}" foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.C]] { # We don't try to use the loop-optimizing options, since they are highly # unlikely to make any difference to PCH. - dg-pch $subdir $test [list "-g" "-O2 -g" "-O2"] ".H" + dg-flags-pch $subdir $test "-fno-modules" [list "-g" "-O2 -g" "-O2"] ".H" } set dg-do-what-default "$old_dg_do_what_default"