llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Oleksandr T. (a-tarasyuk) <details> <summary>Changes</summary> Fixes #<!-- -->92847 --- > Types other than pointer types whose referenced type is an object type and (possibly multi-dimensional) array types with such pointer types as element type shall not be restrict-qualified. --- Full diff: https://github.com/llvm/llvm-project/pull/120896.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Sema/SemaType.cpp (+3-1) - (modified) clang/test/Sema/types.c (+5-5) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 6b9e1109f3906e..52daea9b8eb2b6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -332,6 +332,7 @@ C Language Changes ------------------ - Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic. +- Clang now allows ``restrict`` qualifier for array types with pointer elements (#GH92847). C2y Feature Support ^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 83464c50b4b238..e84daeee679a57 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1595,12 +1595,14 @@ QualType Sema::BuildQualifiedType(QualType T, SourceLocation Loc, QualType ProblemTy; if (T->isAnyPointerType() || T->isReferenceType() || - T->isMemberPointerType()) { + T->isMemberPointerType() || T->isArrayType()) { QualType EltTy; if (T->isObjCObjectPointerType()) EltTy = T; else if (const MemberPointerType *PTy = T->getAs<MemberPointerType>()) EltTy = PTy->getPointeeType(); + else if (T->isArrayType()) + EltTy = Context.getBaseElementType(T); else EltTy = T->getPointeeType(); diff --git a/clang/test/Sema/types.c b/clang/test/Sema/types.c index e0a6ba4f0691b9..4c90634b7ce284 100644 --- a/clang/test/Sema/types.c +++ b/clang/test/Sema/types.c @@ -9,20 +9,20 @@ typedef int (*T)[2]; restrict T x; typedef int *S[2]; -restrict S y; // expected-error {{restrict requires a pointer or reference ('S' (aka 'int *[2]') is invalid)}} - - +restrict S y; // int128_t is available. int a(void) { __int128_t s; __uint128_t t; -} +} // expected-warning {{non-void function does not return a value}} + // but not a keyword int b(void) { int __int128_t; int __uint128_t; -} +} // expected-warning {{non-void function does not return a value}} + // __int128 is a keyword int c(void) { __int128 i; `````````` </details> https://github.com/llvm/llvm-project/pull/120896 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits