diff options
author | Florian Weimer <fweimer@redhat.com> | 2023-12-01 08:10:13 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2023-12-01 08:10:13 +0100 |
commit | 55e94561e97ed0bce4774aa1c6b5d5d82209a379 (patch) | |
tree | 4a0cd634bc0f34f535f67d24ae4a75bf7989e5c2 /gcc/c | |
parent | 2c3db94d9fd07681f8806dae93d555779ff4dfb1 (diff) | |
download | gcc-55e94561e97ed0bce4774aa1c6b5d5d82209a379.zip gcc-55e94561e97ed0bce4774aa1c6b5d5d82209a379.tar.gz gcc-55e94561e97ed0bce4774aa1c6b5d5d82209a379.tar.bz2 |
c: Turn -Wimplicit-function-declaration into a permerror
In the future, it may make sense to avoid cascading errors from
the implicit declaration, especially its assumed int return type.
This change here only changes the kind of the diagnostic, not
its wording or consequences.
gcc/
* doc/invoke.texi (Warning Options): Document changes.
gcc/c/
PR c/91092
PR c/96284
* c-decl.cc (implicit_decl_permerror): Rename from
implicit_decl_warning. Call permerror_opt instead of
pedwarn and warning_at.
(implicitly_declare): Adjust callers.
gcc/testsuite/
* gcc.dg/permerror-default.c (implicit_function_declaration):
Expect the new permerror.
* gcc.dg/permerror-system.c: Likewise.
* c-c++-common/spellcheck-reserved.c (test, test_2): Expect
error instead of warning.
(f): Expect error instead of warning.
* gcc.dg/Wimplicit-function-declaration-c99.c: Compile with
-fpermissive due to expected warning.
* gcc.dg/Wimplicit-function-declaration-c99-2.c: New test.
Copied from gcc.dg/Wimplicit-function-declaration-c99.c.
Expect error.
* gcc.dg/missing-header-fixit-1.c: Compile with -fpermissive
due to expect error.
* gcc.dg/missing-header-fixit-1a.c: New test. Copied from
gcc.dg/missing-header-fixit-1.c, but expect error.
* gcc.dg/missing-header-fixit-2.c: Compile with -fpermissive
due to expect error.
* gcc.dg/missing-header-fixit-2a.c: New test. Copied from
gcc.dg/missing-header-fixit-2.c, but expect error.
* gcc.dg/missing-header-fixit-4.c: Compile with -fpermissive
due to expect error.
* gcc.dg/missing-header-fixit-4a.c: New test. Copied from
gcc.dg/missing-header-fixit-4.c, but expect error.
* gcc.dg/missing-header-fixit-5.c: Compile with -fpermissive
due to expect error.
* gcc.dg/missing-header-fixit-5a.c: New test. Copied from
gcc.dg/missing-header-fixit-5.c, but expect error.
* gcc.dg/pr61852.c: Expect implicit-function-declaration
error instead of warning.
* gcc.dg/spellcheck-identifiers-2.c: Compile with
-fpermissive due to expected warnings.
* gcc.dg/spellcheck-identifiers-2a.c: New test. Copied
from gcc.dg/spellcheck-identifiers-2a.c. Expect errors.
* gcc.dg/spellcheck-identifiers-3.c: Compile with
-fpermissive due to expected warnings.
* gcc.dg/spellcheck-identifiers-3a.c: New test. Copied
from gcc.dg/spellcheck-identifiers-2a.c. Expect errors.
* gcc.dg/spellcheck-identifiers-4.c: Compile with
-fpermissive due to expected warnings.
* gcc.dg/spellcheck-identifiers-4a.c: New test. Copied
from gcc.dg/spellcheck-identifiers-2a.c. Expect error.
* gcc.dg/spellcheck-identifiers.c: Compile with
-fpermissive due to expected warnings.
* gcc.dg/spellcheck-identifiers-1a.c: New test. Copied
from gcc.dg/spellcheck-identifiers.c. Expect errors.
* gcc.target/aarch64/sve/acle/general-c/ld1sh_gather_1.c (f1):
Expect error.
* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_index_1.c:
(f1): Likewise.
* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_index_restricted_1.c:
(f1): Likewise.
* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_1.c:
(f1): Likewise.
* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_2.c:
(f1): Likewise.
* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_3.c:
(f1): Likewise.
* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_4.c:
(f1): Likewise.
* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_5.c:
(f1): Likewise.
* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_1.c:
(f1): Likewise.
* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_2.c:
(f1): Likewise.
* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_3.c:
(f1): Likewise.
* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_4.c:
(f1): Likewise.
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/c-decl.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index cf1df82..4d17f05 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -3493,12 +3493,12 @@ pushdecl (tree x) } -/* Issue a warning about implicit function declaration. ID is the function +/* Issue a permerror about implicit function declaration. ID is the function identifier, OLDDECL is a declaration of the function in a different scope, or NULL_TREE. */ static void -implicit_decl_warning (location_t loc, tree id, tree olddecl) +implicit_decl_permerror (location_t loc, tree id, tree olddecl) { if (!warn_implicit_function_declaration) return; @@ -3515,14 +3515,14 @@ implicit_decl_warning (location_t loc, tree id, tree olddecl) { gcc_rich_location richloc (loc); richloc.add_fixit_replace (suggestion); - warned = pedwarn (&richloc, OPT_Wimplicit_function_declaration, - "implicit declaration of function %qE;" - " did you mean %qs?", - id, suggestion); + warned = permerror_opt (&richloc, OPT_Wimplicit_function_declaration, + "implicit declaration of function %qE;" + " did you mean %qs?", + id, suggestion); } else - warned = pedwarn (loc, OPT_Wimplicit_function_declaration, - "implicit declaration of function %qE", id); + warned = permerror_opt (loc, OPT_Wimplicit_function_declaration, + "implicit declaration of function %qE", id); } else if (const char *suggestion = hint.suggestion ()) { @@ -3812,7 +3812,7 @@ implicitly_declare (location_t loc, tree functionid) then recycle the old declaration but with the new type. */ if (!C_DECL_IMPLICIT (decl)) { - implicit_decl_warning (loc, functionid, decl); + implicit_decl_permerror (loc, functionid, decl); C_DECL_IMPLICIT (decl) = 1; } if (fndecl_built_in_p (decl)) @@ -3865,7 +3865,7 @@ implicitly_declare (location_t loc, tree functionid) DECL_EXTERNAL (decl) = 1; TREE_PUBLIC (decl) = 1; C_DECL_IMPLICIT (decl) = 1; - implicit_decl_warning (loc, functionid, 0); + implicit_decl_permerror (loc, functionid, 0); asmspec_tree = maybe_apply_renaming_pragma (decl, /*asmname=*/NULL); if (asmspec_tree) set_user_assembler_name (decl, TREE_STRING_POINTER (asmspec_tree)); |