Skip to content

Commit 295df25

Browse files
committed
[Clang] allow restrict qualifier for array types with pointer types as element types
1 parent 4451431 commit 295df25

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ C Language Changes
332332
------------------
333333

334334
- Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic.
335+
- Clang now allows ``restrict`` qualifier for array types with pointer elements (#GH92847).
335336

336337
C2y Feature Support
337338
^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaType.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,12 +1595,14 @@ QualType Sema::BuildQualifiedType(QualType T, SourceLocation Loc,
15951595
QualType ProblemTy;
15961596

15971597
if (T->isAnyPointerType() || T->isReferenceType() ||
1598-
T->isMemberPointerType()) {
1598+
T->isMemberPointerType() || T->isArrayType()) {
15991599
QualType EltTy;
16001600
if (T->isObjCObjectPointerType())
16011601
EltTy = T;
16021602
else if (const MemberPointerType *PTy = T->getAs<MemberPointerType>())
16031603
EltTy = PTy->getPointeeType();
1604+
else if (T->isArrayType())
1605+
EltTy = Context.getBaseElementType(T);
16041606
else
16051607
EltTy = T->getPointeeType();
16061608

clang/test/Sema/types.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ typedef int (*T)[2];
99
restrict T x;
1010

1111
typedef int *S[2];
12-
restrict S y; // expected-error {{restrict requires a pointer or reference ('S' (aka 'int *[2]') is invalid)}}
13-
14-
12+
restrict S y;
1513

1614
// int128_t is available.
1715
int a(void) {
1816
__int128_t s;
1917
__uint128_t t;
20-
}
18+
} // expected-warning {{non-void function does not return a value}}
19+
2120
// but not a keyword
2221
int b(void) {
2322
int __int128_t;
2423
int __uint128_t;
25-
}
24+
} // expected-warning {{non-void function does not return a value}}
25+
2626
// __int128 is a keyword
2727
int c(void) {
2828
__int128 i;

0 commit comments

Comments
 (0)