aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-12-07 18:08:58 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-12-07 18:08:58 +0000
commit2b5ff1a1471819192ae805b51b888030ecb52914 (patch)
treebc54ea233b0d8a210be893c36c0e1eaacc1fc909
parent33cc2437ae3a609cdc44179931a2909eb48a8200 (diff)
Patch to allow restrict applied to id/Class types.
(fixes radar 7442244). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90773 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaType.cpp12
-rw-r--r--test/SemaObjC/restrict-id-type.m9
2 files changed, 17 insertions, 4 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index e79d9ab721..c52ac75332 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -356,10 +356,14 @@ static QualType ConvertDeclSpecToType(Declarator &TheDeclarator, Sema &TheSema){
// or incomplete types shall not be restrict-qualified." C++ also allows
// restrict-qualified references.
if (TypeQuals & DeclSpec::TQ_restrict) {
- if (Result->isPointerType() || Result->isReferenceType()) {
- QualType EltTy = Result->isPointerType() ?
- Result->getAs<PointerType>()->getPointeeType() :
- Result->getAs<ReferenceType>()->getPointeeType();
+ if (Result->isAnyPointerType() || Result->isReferenceType()) {
+ QualType EltTy;
+ if (Result->isObjCObjectPointerType())
+ EltTy = Result;
+ else
+ EltTy = Result->isPointerType() ?
+ Result->getAs<PointerType>()->getPointeeType() :
+ Result->getAs<ReferenceType>()->getPointeeType();
// If we have a pointer or reference, the pointee must have an object
// incomplete type.
diff --git a/test/SemaObjC/restrict-id-type.m b/test/SemaObjC/restrict-id-type.m
new file mode 100644
index 0000000000..d31c88d911
--- /dev/null
+++ b/test/SemaObjC/restrict-id-type.m
@@ -0,0 +1,9 @@
+// RUN: clang-cc -std=gnu99 -fsyntax-only -verify %s
+
+void f0(restrict id a0) {}
+
+void f1(restrict id *a0) {}
+
+void f2(restrict Class a0) {}
+
+void f3(restrict Class *a0) {}