aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2024-03-04 21:32:44 -0500
committerPatrick Palka <ppalka@redhat.com>2024-03-04 21:32:44 -0500
commit08edf85f747b9ac1850f9688c8a1bc7c2bf6b4e5 (patch)
tree0ddd922015c6047ae47ebf182eeb178911b47720 /gcc
parent264e3ad419cf71b10e7951a23750ac3507e21df9 (diff)
downloadgcc-08edf85f747b9ac1850f9688c8a1bc7c2bf6b4e5.zip
gcc-08edf85f747b9ac1850f9688c8a1bc7c2bf6b4e5.tar.gz
gcc-08edf85f747b9ac1850f9688c8a1bc7c2bf6b4e5.tar.bz2
c++/modules: relax diagnostic about GMF contents
Issuing a hard error when the GMF doesn't consist only of preprocessing directives happens to be inconvenient for automated testcase reduction via cvise. This patch relaxes this diagnostic into a pedwarn that can be disabled with -Wno-global-module. gcc/c-family/ChangeLog: * c.opt (Wglobal-module): New warning. gcc/cp/ChangeLog: * parser.cc (cp_parser_translation_unit): Relax GMF contents error into a pedwarn. gcc/ChangeLog: * doc/invoke.texi (-Wno-global-module): Document. gcc/testsuite/ChangeLog: * g++.dg/modules/friend-6_a.C: Pass -Wno-global-module instead of -Wno-pedantic. Remove now unnecessary preprocessing directives from GMF. Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-family/c.opt4
-rw-r--r--gcc/cp/parser.cc6
-rw-r--r--gcc/doc/invoke.texi8
-rw-r--r--gcc/testsuite/g++.dg/modules/friend-6_a.C4
4 files changed, 15 insertions, 7 deletions
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index b7a4a1a..56cccf2 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -802,6 +802,10 @@ Wframe-address
C ObjC C++ ObjC++ Var(warn_frame_address) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
Warn when __builtin_frame_address or __builtin_return_address is used unsafely.
+Wglobal-module
+C++ ObjC++ Var(warn_global_module) Warning Init(1)
+Warn about the global module fragment not containing only preprocessing directives.
+
Wif-not-aligned
C ObjC C++ ObjC++ Var(warn_if_not_aligned) Init(1) Warning
Warn when the field in a struct is not aligned.
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index a310b9e..e32acfc 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_Wglobal_module,
+ "global module fragment contents must be"
+ " from preprocessor inclusion");
}
}
}
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index bdf05be..2390d47 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -256,7 +256,7 @@ in the following sections.
-Wdeprecated-copy -Wdeprecated-copy-dtor
-Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion
-Weffc++ -Wno-elaborated-enum-base
--Wno-exceptions -Wextra-semi -Wno-inaccessible-base
+-Wno-exceptions -Wextra-semi -Wno-global-module -Wno-inaccessible-base
-Wno-inherited-variadic-ctor -Wno-init-list-lifetime
-Winvalid-constexpr -Winvalid-imported-macros
-Wno-invalid-offsetof -Wno-literal-suffix
@@ -4774,6 +4774,12 @@ undefined behavior at runtime. This warning is enabled by default.
@item -Wextra-semi @r{(C++, Objective-C++ only)}
Warn about redundant semicolons after in-class function definitions.
+@opindex Wno-global-module
+@opindex Wglobal-module
+@item -Wno-global-module @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 Winaccessible-base
@opindex Wno-inaccessible-base
@item -Wno-inaccessible-base @r{(C++, 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 7493e8f..13f7710 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-global-module" }
// { dg-module-cmi friend_6 }
module;
-# 1 "" 1
template <typename> struct Trans_NS___cxx11_basic_string {
template <typename> friend class basic_stringbuf;
};
template struct Trans_NS___cxx11_basic_string<char>;
-# 6 "" 2
export module friend_6;