Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -985,6 +985,9 @@ // A warning group for warnings about using C99 features as extensions. def C99 : DiagGroup<"c99-extensions", [C99Designator]>; +// A warning group for warnings about using C2x features as extensions. +def C2x : DiagGroup<"c2x-extensions">; + // A warning group for warnings about GCC extensions. def GNU : DiagGroup<"gnu", [GNUAlignofExpression, GNUAnonymousStruct, GNUAutoType, Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -275,7 +275,9 @@ "%0 cannot be the name of a parameter">; def err_bad_parameter_name_template_id : Error< "parameter name cannot have template arguments">; -def err_parameter_name_omitted : Error<"parameter name omitted">; +def ext_parameter_name_ommitted_c2x : ExtWarn< + "omitting the parameter name in a function definition is a C2x extension">, + InGroup; def err_anyx86_interrupt_attribute : Error< "%select{x86|x86-64}0 'interrupt' attribute only applies to functions that " "have %select{a 'void' return type|" Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -12860,11 +12860,12 @@ // C99 6.9.1p5: If the declarator includes a parameter type list, the // declaration of each parameter shall include an identifier. - if (CheckParameterNames && - Param->getIdentifier() == nullptr && - !Param->isImplicit() && - !getLangOpts().CPlusPlus) - Diag(Param->getLocation(), diag::err_parameter_name_omitted); + if (CheckParameterNames && Param->getIdentifier() == nullptr && + !Param->isImplicit() && !getLangOpts().CPlusPlus) { + // Diagnose this as an extension in C17 and earlier. + if (!getLangOpts().C2x) + Diag(Param->getLocation(), diag::ext_parameter_name_ommitted_c2x); + } // C99 6.7.5.3p12: // If the function declarator is not part of a definition of that Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -14645,11 +14645,12 @@ if (ExplicitSignature) { for (unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) { ParmVarDecl *Param = ExplicitSignature.getParam(I); - if (Param->getIdentifier() == nullptr && - !Param->isImplicit() && - !Param->isInvalidDecl() && - !getLangOpts().CPlusPlus) - Diag(Param->getLocation(), diag::err_parameter_name_omitted); + if (Param->getIdentifier() == nullptr && !Param->isImplicit() && + !Param->isInvalidDecl() && !getLangOpts().CPlusPlus) { + // Diagnose this as an extension in C17 and earlier. + if (!getLangOpts().C2x) + Diag(Param->getLocation(), diag::ext_parameter_name_ommitted_c2x); + } Params.push_back(Param); } Index: clang/test/Sema/block-args.c =================================================================== --- clang/test/Sema/block-args.c +++ clang/test/Sema/block-args.c @@ -31,8 +31,8 @@ // radar 7528255 void f0() { - ^(int, double d, char) {}(1, 1.34, 'a'); // expected-error {{parameter name omitted}} \ - // expected-error {{parameter name omitted}} + ^(int, double d, char) {}(1, 1.34, 'a'); // expected-warning {{omitting the parameter name in a function definition is a C2x extension}} \ + // expected-warning {{omitting the parameter name in a function definition is a C2x extension}} } // rdar://problem/8962770 Index: clang/test/Sema/c89.c =================================================================== --- clang/test/Sema/c89.c +++ clang/test/Sema/c89.c @@ -45,7 +45,7 @@ typedef int sometype; int a(sometype, y) {return 0;} /* expected-warning {{declaration specifier missing, defaulting to 'int'}} \ - expected-error {{parameter name omitted}}*/ + expected-warning {{omitting the parameter name in a function definition is a C2x extension}}*/ Index: clang/test/Sema/function.c =================================================================== --- clang/test/Sema/function.c +++ clang/test/Sema/function.c @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic +// RUN: %clang_cc1 %s -fsyntax-only -verify -verify=c2x -pedantic +// RUN: %clang_cc1 %s -fsyntax-only -std=c2x -verify -pedantic // PR1892, PR11354 void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-warning {{(aka 'double (*restrict)[5]')}} @@ -30,7 +31,7 @@ void t11(){t10(1);} // expected-warning{{too many arguments}} // PR3208 -void t12(int) {} // expected-error{{parameter name omitted}} +void t12(int) {} // c2x-warning{{omitting the parameter name in a function definition is a C2x extension}} // PR2790 void t13() { @@ -80,7 +81,8 @@ fn_t t17; // PR4049 -unknown_type t18(void*) { // expected-error {{unknown type name 'unknown_type'}} expected-error{{parameter name omitted}} +unknown_type t18(void*) { // expected-error {{unknown type name 'unknown_type'}} \ + // c2x-warning {{omitting the parameter name in a function definition is a C2x extension}} } unknown_type t19(int* P) { // expected-error {{unknown type name 'unknown_type'}}