forked from OSchip/llvm-project
Replace some custom C11 extension warnings with the generic warning.
llvm-svn: 370066
This commit is contained in:
parent
a393238422
commit
1d93522056
|
@ -119,8 +119,6 @@ def warn_microsoft_qualifiers_ignored : Warning<
|
|||
"qualifiers after comma in declarator list are ignored">,
|
||||
InGroup<IgnoredAttributes>;
|
||||
|
||||
def ext_c11_generic_selection : Extension<
|
||||
"generic selections are a C11-specific feature">, InGroup<C11>;
|
||||
def err_duplicate_default_assoc : Error<
|
||||
"duplicate default generic association">;
|
||||
def note_previous_default_assoc : Note<
|
||||
|
@ -129,8 +127,6 @@ def note_previous_default_assoc : Note<
|
|||
def ext_c11_feature : Extension<
|
||||
"'%0' is a C11 extension">, InGroup<C11>;
|
||||
|
||||
def ext_c11_noreturn : Extension<
|
||||
"_Noreturn functions are a C11-specific feature">, InGroup<C11>;
|
||||
def err_c11_noreturn_misplaced : Error<
|
||||
"'_Noreturn' keyword must precede function declarator">;
|
||||
|
||||
|
@ -374,8 +370,6 @@ def err_unexpected_token_in_nested_name_spec : Error<
|
|||
"'%0' cannot be a part of nested name specifier; did you mean ':'?">;
|
||||
def err_bool_redeclaration : Error<
|
||||
"redeclaration of C++ built-in type 'bool'">;
|
||||
def ext_c11_static_assert : Extension<
|
||||
"_Static_assert is a C11-specific feature">, InGroup<C11>;
|
||||
def warn_cxx98_compat_static_assert : Warning<
|
||||
"static_assert declarations are incompatible with C++98">,
|
||||
InGroup<CXX98Compat>, DefaultIgnore;
|
||||
|
|
|
@ -3626,7 +3626,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
}
|
||||
case tok::kw__Noreturn:
|
||||
if (!getLangOpts().C11)
|
||||
Diag(Loc, diag::ext_c11_noreturn);
|
||||
Diag(Tok, diag::ext_c11_feature) << Tok.getName();
|
||||
isInvalid = DS.setFunctionSpecNoreturn(Loc, PrevSpec, DiagID);
|
||||
break;
|
||||
|
||||
|
|
|
@ -862,7 +862,7 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){
|
|||
"Not a static_assert declaration");
|
||||
|
||||
if (Tok.is(tok::kw__Static_assert) && !getLangOpts().C11)
|
||||
Diag(Tok, diag::ext_c11_static_assert);
|
||||
Diag(Tok, diag::ext_c11_feature) << Tok.getName();
|
||||
if (Tok.is(tok::kw_static_assert))
|
||||
Diag(Tok, diag::warn_cxx98_compat_static_assert);
|
||||
|
||||
|
|
|
@ -2733,11 +2733,10 @@ ExprResult Parser::ParseStringLiteralExpression(bool AllowUserDefinedLiteral) {
|
|||
/// \endverbatim
|
||||
ExprResult Parser::ParseGenericSelectionExpression() {
|
||||
assert(Tok.is(tok::kw__Generic) && "_Generic keyword expected");
|
||||
SourceLocation KeyLoc = ConsumeToken();
|
||||
|
||||
if (!getLangOpts().C11)
|
||||
Diag(KeyLoc, diag::ext_c11_generic_selection);
|
||||
Diag(Tok, diag::ext_c11_feature) << Tok.getName();
|
||||
|
||||
SourceLocation KeyLoc = ConsumeToken();
|
||||
BalancedDelimiterTracker T(*this, tok::l_paren);
|
||||
if (T.expectAndConsume())
|
||||
return ExprError();
|
||||
|
|
|
@ -15,4 +15,4 @@ _Noreturn int; // expected-error {{'_Noreturn' can only appear on functions}} ex
|
|||
_Noreturn struct S; // expected-error {{'_Noreturn' can only appear on functions}}
|
||||
_Noreturn enum E { e }; // expected-error {{'_Noreturn' can only appear on functions}}
|
||||
|
||||
// CHECK-EXT: _Noreturn functions are a C11-specific feature
|
||||
// CHECK-EXT: '_Noreturn' is a C11 extension
|
||||
|
|
|
@ -1,40 +1,43 @@
|
|||
// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -std=c99 -pedantic -fsyntax-only -verify=expected,ext %s
|
||||
|
||||
void g(void);
|
||||
|
||||
void foo(int n) {
|
||||
(void) _Generic(0,
|
||||
(void) _Generic(0, // ext-warning {{'_Generic' is a C11 extension}}
|
||||
struct A: 0, // expected-error {{type 'struct A' in generic association incomplete}}
|
||||
void(): 0, // expected-error {{type 'void ()' in generic association not an object type}}
|
||||
int[n]: 0); // expected-error {{type 'int [n]' in generic association is a variably modified type}}
|
||||
|
||||
(void) _Generic(0,
|
||||
(void) _Generic(0, // ext-warning {{'_Generic' is a C11 extension}}
|
||||
void (*)(): 0, // expected-note {{compatible type 'void (*)()' specified here}}
|
||||
void (*)(void): 0); // expected-error {{type 'void (*)(void)' in generic association compatible with previously specified type 'void (*)()'}}
|
||||
|
||||
(void) _Generic((void (*)()) 0, // expected-error {{controlling expression type 'void (*)()' compatible with 2 generic association types}}
|
||||
(void) _Generic((void (*)()) 0, // expected-error {{controlling expression type 'void (*)()' compatible with 2 generic association types}} \
|
||||
// ext-warning {{'_Generic' is a C11 extension}}
|
||||
void (*)(int): 0, // expected-note {{compatible type 'void (*)(int)' specified here}}
|
||||
void (*)(void): 0); // expected-note {{compatible type 'void (*)(void)' specified here}}
|
||||
|
||||
(void) _Generic(0, // expected-error {{controlling expression type 'int' not compatible with any generic association type}}
|
||||
(void) _Generic(0, // expected-error {{controlling expression type 'int' not compatible with any generic association type}} \
|
||||
// ext-warning {{'_Generic' is a C11 extension}}
|
||||
char: 0, short: 0, long: 0);
|
||||
|
||||
int a1[_Generic(0, int: 1, short: 2, float: 3, default: 4) == 1 ? 1 : -1];
|
||||
int a2[_Generic(0, default: 1, short: 2, float: 3, int: 4) == 4 ? 1 : -1];
|
||||
int a3[_Generic(0L, int: 1, short: 2, float: 3, default: 4) == 4 ? 1 : -1];
|
||||
int a4[_Generic(0L, default: 1, short: 2, float: 3, int: 4) == 1 ? 1 : -1];
|
||||
int a5[_Generic(0, int: 1, short: 2, float: 3) == 1 ? 1 : -1];
|
||||
int a6[_Generic(0, short: 1, float: 2, int: 3) == 3 ? 1 : -1];
|
||||
int a1[_Generic(0, int: 1, short: 2, float: 3, default: 4) == 1 ? 1 : -1]; // ext-warning {{'_Generic' is a C11 extension}}
|
||||
int a2[_Generic(0, default: 1, short: 2, float: 3, int: 4) == 4 ? 1 : -1]; // ext-warning {{'_Generic' is a C11 extension}}
|
||||
int a3[_Generic(0L, int: 1, short: 2, float: 3, default: 4) == 4 ? 1 : -1]; // ext-warning {{'_Generic' is a C11 extension}}
|
||||
int a4[_Generic(0L, default: 1, short: 2, float: 3, int: 4) == 1 ? 1 : -1]; // ext-warning {{'_Generic' is a C11 extension}}
|
||||
int a5[_Generic(0, int: 1, short: 2, float: 3) == 1 ? 1 : -1]; // ext-warning {{'_Generic' is a C11 extension}}
|
||||
int a6[_Generic(0, short: 1, float: 2, int: 3) == 3 ? 1 : -1]; // ext-warning {{'_Generic' is a C11 extension}}
|
||||
|
||||
int a7[_Generic("test", char *: 1, default: 2) == 1 ? 1 : -1];
|
||||
int a8[_Generic(g, void (*)(void): 1, default: 2) == 1 ? 1 : -1];
|
||||
int a7[_Generic("test", char *: 1, default: 2) == 1 ? 1 : -1]; // ext-warning {{'_Generic' is a C11 extension}}
|
||||
int a8[_Generic(g, void (*)(void): 1, default: 2) == 1 ? 1 : -1]; // ext-warning {{'_Generic' is a C11 extension}}
|
||||
|
||||
const int i = 12;
|
||||
int a9[_Generic(i, int: 1, default: 2) == 1 ? 1 : -1];
|
||||
int a9[_Generic(i, int: 1, default: 2) == 1 ? 1 : -1]; // ext-warning {{'_Generic' is a C11 extension}}
|
||||
|
||||
// This is expected to not trigger any diagnostics because the controlling
|
||||
// expression is not evaluated.
|
||||
(void)_Generic(*(int *)0, int: 1);
|
||||
(void)_Generic(*(int *)0, int: 1); // ext-warning {{'_Generic' is a C11 extension}}
|
||||
}
|
||||
|
||||
int __attribute__((overloadable)) test (int);
|
||||
|
@ -42,5 +45,5 @@ double __attribute__((overloadable)) test (double);
|
|||
char testc(char);
|
||||
|
||||
void PR30201(void) {
|
||||
_Generic(4, char:testc, default:test)(4);
|
||||
_Generic(4, char:testc, default:test)(4); // ext-warning {{'_Generic' is a C11 extension}}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,30 @@
|
|||
// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -xc++ -std=c++11 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -std=c99 -pedantic -fsyntax-only -verify=expected,ext %s
|
||||
// RUN: %clang_cc1 -xc++ -std=c++11 -pedantic -fsyntax-only -verify=expected,ext %s
|
||||
|
||||
_Static_assert("foo", "string is nonzero");
|
||||
_Static_assert("foo", "string is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
#ifndef __cplusplus
|
||||
// expected-error@-2 {{static_assert expression is not an integral constant expression}}
|
||||
#endif
|
||||
|
||||
_Static_assert(1, "1 is nonzero");
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}}
|
||||
_Static_assert(1, "1 is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}} \
|
||||
// ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
|
||||
void foo(void) {
|
||||
_Static_assert(1, "1 is nonzero");
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}}
|
||||
_Static_assert(1, "1 is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}} \
|
||||
// ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
}
|
||||
|
||||
_Static_assert(1, invalid); // expected-error {{expected string literal for diagnostic message in static_assert}}
|
||||
_Static_assert(1, invalid); // expected-error {{expected string literal for diagnostic message in static_assert}} \
|
||||
// ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
|
||||
struct A {
|
||||
int a;
|
||||
_Static_assert(1, "1 is nonzero");
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}}
|
||||
_Static_assert(1, "1 is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}} \
|
||||
// ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -36,7 +41,12 @@ struct A {
|
|||
_Static_assert(sizeof(T1) == sizeof(T2), "type size mismatch"); \
|
||||
}
|
||||
|
||||
typedef UNION(unsigned, struct A) U1;
|
||||
UNION(char[2], short) u2 = { .one = { 'a', 'b' } };
|
||||
typedef UNION(char, short) U3; // expected-error {{static_assert failed due to requirement 'sizeof(char) == sizeof(short)' "type size mismatch"}}
|
||||
typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}}
|
||||
typedef UNION(unsigned, struct A) U1; // ext-warning 3 {{'_Static_assert' is a C11 extension}}
|
||||
UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // ext-warning 3 {{'_Static_assert' is a C11 extension}}
|
||||
#if defined(__cplusplus)
|
||||
// ext-warning@-2 {{designated initializers are a C99 feature}}
|
||||
#endif
|
||||
typedef UNION(char, short) U3; // expected-error {{static_assert failed due to requirement 'sizeof(char) == sizeof(short)' "type size mismatch"}} \
|
||||
// ext-warning 3 {{'_Static_assert' is a C11 extension}}
|
||||
typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
|
||||
// ext-warning 3 {{'_Static_assert' is a C11 extension}}
|
||||
|
|
Loading…
Reference in New Issue