Skip to content

Commit b3fbbbd

Browse files
committed
update diagnostic messages
1 parent a2b4193 commit b3fbbbd

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7409,11 +7409,11 @@ def warn_c23_compat_utf8_string : Warning<
74097409
def note_cxx20_c23_compat_utf8_string_remove_u8 : Note<
74107410
"remove 'u8' prefix to avoid a change of behavior; "
74117411
"Clang encodes unprefixed narrow string literals as UTF-8">;
7412-
def warn_c23_compat_restrict_pointers_to_array : Warning<
7413-
"'restrict' qualifier on pointers to arrays is incompatible with C17 and earlier">,
7412+
def warn_c23_compat_restrict_on_array_of_pointers : Warning<
7413+
"'restrict' qualifier on an array of pointers is incompatible with C standards before C23">,
74147414
InGroup<CPre23Compat>, DefaultIgnore;
7415-
def ext_restrict_pointers_to_array_c23 : Extension<
7416-
"'restrict' qualifier on pointers to arrays is a C23 extension">, InGroup<C23>;
7415+
def ext_restrict_on_array_of_pointers_c23 : Extension<
7416+
"'restrict' qualifier on an array of pointers is a C23 extension">, InGroup<C23>;
74177417
def err_array_init_different_type : Error<
74187418
"cannot initialize array %diff{of type $ with array of type $|"
74197419
"with different type of array}0,1">;

clang/lib/Sema/SemaType.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,9 +1621,9 @@ QualType Sema::BuildQualifiedType(QualType T, SourceLocation Loc,
16211621
Diag(Loc, DiagID) << EltTy;
16221622
Qs.removeRestrict();
16231623
} else {
1624-
if (!getLangOpts().C23 && (T->isArrayType() || EltTy->isArrayType())) {
1625-
Diag(Loc, diag::ext_restrict_pointers_to_array_c23);
1626-
Diag(Loc, diag::warn_c23_compat_restrict_pointers_to_array);
1624+
if (!getLangOpts().C23 && T->isArrayType()) {
1625+
Diag(Loc, diag::ext_restrict_on_array_of_pointers_c23);
1626+
Diag(Loc, diag::warn_c23_compat_restrict_on_array_of_pointers);
16271627
}
16281628
}
16291629
}

clang/test/Sema/pre-c2x-restrict-qualifier.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
// RUN: %clang_cc1 -std=c17 -fsyntax-only -Wpre-c2x-compat -verify=pre-c2x-compat %s
44

55
typedef int (*T1)[2];
6-
restrict T1 t1; // pedantic-warning {{'restrict' qualifier on pointers to arrays is a C23 extension}} \
7-
// pre-c2x-compat-warning {{'restrict' qualifier on pointers to arrays is incompatible with C17 and earlier}}
6+
restrict T1 t1;
87

98
typedef int *T2[2];
10-
restrict T2 t2; // pedantic-warning {{'restrict' qualifier on pointers to arrays is a C23 extension}} \
11-
// pre-c2x-compat-warning {{'restrict' qualifier on pointers to arrays is incompatible with C17 and earlier}}
9+
restrict T2 t2; // pedantic-warning {{'restrict' qualifier on an array of pointers is a C23 extension}} \
10+
// pre-c2x-compat-warning {{'restrict' qualifier on an array of pointers is incompatible with C standards before C23}}
1211

1312
typedef int *T3[2][2];
14-
restrict T3 t3; // pedantic-warning {{'restrict' qualifier on pointers to arrays is a C23 extension}} \
15-
// pre-c2x-compat-warning {{'restrict' qualifier on pointers to arrays is incompatible with C17 and earlier}}
13+
restrict T3 t3; // pedantic-warning {{'restrict' qualifier on an array of pointers is a C23 extension}} \
14+
// pre-c2x-compat-warning {{'restrict' qualifier on an array of pointers is incompatible with C standards before C23}}
1615

1716
typedef int (*t4)(); // pedantic-warning {{a function declaration without a prototype is deprecated in all versions of C}}
1817
typedef t4 t5[2];

clang/test/Sema/types.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
// RUN: %clang_cc1 %s -fblocks -pedantic -verify -triple=powerpc64-ibm-aix-xcoff
77

88
typedef int (*T)[2];
9-
restrict T x; // expected-warning {{'restrict' qualifier on pointers to arrays is a C23 extension}}
9+
restrict T x;
1010

1111
typedef int *S[2];
12-
restrict S y; // expected-warning {{'restrict' qualifier on pointers to arrays is a C23 extension}}
12+
restrict S y; // expected-warning {{'restrict' qualifier on an array of pointers is a C23 extension}}
1313

1414
// int128_t is available.
1515
int a(void) {

0 commit comments

Comments
 (0)