forked from OSchip/llvm-project
Silence -Wstrict-prototype diagnostics in C2x mode
This also disables the diagnostic when the user passes -fno-knr-functions.
This commit is contained in:
parent
7abfaa0a81
commit
ef87865b98
|
@ -149,14 +149,17 @@ Improvements to Clang's diagnostics
|
|||
now only diagnose deprecated declarations and definitions of functions
|
||||
without a prototype where the behavior in C2x will remain correct. This
|
||||
diagnostic remains off by default but is now enabled via ``-pedantic`` due to
|
||||
it being a deprecation warning. ``-Wdeprecated-non-prototype`` will diagnose
|
||||
cases where the deprecated declarations or definitions of a function without
|
||||
a prototype will change behavior in C2x. Additionally, it will diagnose calls
|
||||
which pass arguments to a function without a prototype. This warning is
|
||||
enabled only when the ``-Wdeprecated-non-prototype`` option is enabled at the
|
||||
function declaration site, which allows a developer to disable the diagnostic
|
||||
for all callers at the point of declaration. This diagnostic is grouped under
|
||||
the ``-Wstrict-prototypes`` warning group, but is enabled by default.
|
||||
it being a deprecation warning. ``-Wstrict-prototypes`` has no effect in C2x
|
||||
or when ``-fno-knr-functions`` is enabled. ``-Wdeprecated-non-prototype``
|
||||
will diagnose cases where the deprecated declarations or definitions of a
|
||||
function without a prototype will change behavior in C2x. Additionally, it
|
||||
will diagnose calls which pass arguments to a function without a prototype.
|
||||
This warning is enabled only when the ``-Wdeprecated-non-prototype`` option
|
||||
is enabled at the function declaration site, which allows a developer to
|
||||
disable the diagnostic for all callers at the point of declaration. This
|
||||
diagnostic is grouped under the ``-Wstrict-prototypes`` warning group, but is
|
||||
enabled by default. ``-Wdeprecated-non-prototype`` has no effect in C2x or
|
||||
when ``-fno-knr-functions`` is enabled.
|
||||
- Clang now appropriately issues an error in C when a definition of a function
|
||||
without a prototype and with no arguments is an invalid redeclaration of a
|
||||
function with a prototype. e.g., ``void f(int); void f() {}`` is now properly
|
||||
|
|
|
@ -5564,7 +5564,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
|
|||
// of the parameters is supplied.
|
||||
// See ActOnFinishFunctionBody() and MergeFunctionDecl() for handling of
|
||||
// function declarations whose behavior changes in C2x.
|
||||
if (!LangOpts.CPlusPlus) {
|
||||
if (!LangOpts.requiresStrictPrototypes()) {
|
||||
bool IsBlock = false;
|
||||
for (const DeclaratorChunk &DeclType : D.type_objects()) {
|
||||
switch (DeclType.Kind) {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -Wstrict-prototypes -verify -std=c2x %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -Wstrict-prototypes -verify -fno-knr-functions %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
void foo();
|
||||
void bar() {}
|
||||
|
||||
void baz(void);
|
||||
void baz() {}
|
Loading…
Reference in New Issue