aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Sema/SemaDecl.cpp6
-rw-r--r--Sema/SemaType.cpp6
-rw-r--r--test/Sema/function.c5
3 files changed, 13 insertions, 4 deletions
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 7443d365a9..5a588397d9 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -936,9 +936,11 @@ Sema::ActOnParamDeclarator(struct DeclaratorChunk::ParamInfo &PI, Scope *FnScope
// we need to consider storing both types (in ParmVarDecl)...
//
QualType parmDeclType = QualType::getFromOpaquePtr(PI.TypeInfo);
- if (const ArrayType *AT = parmDeclType->getAsArrayType())
+ if (const ArrayType *AT = parmDeclType->getAsArrayType()) {
+ // int x[restrict 4] -> int *restrict
parmDeclType = Context.getPointerType(AT->getElementType());
- else if (parmDeclType->isFunctionType())
+ parmDeclType = parmDeclType.getQualifiedType(AT->getIndexTypeQualifier());
+ } else if (parmDeclType->isFunctionType())
parmDeclType = Context.getPointerType(parmDeclType);
ParmVarDecl *New = new ParmVarDecl(PI.IdentLoc, II, parmDeclType,
diff --git a/Sema/SemaType.cpp b/Sema/SemaType.cpp
index c3fa8cd46f..5e9bb3cd82 100644
--- a/Sema/SemaType.cpp
+++ b/Sema/SemaType.cpp
@@ -301,9 +301,11 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
// FIXME: If a source translation tool needs to see the original type,
// then we need to consider storing both types somewhere...
//
- if (const ArrayType *AT = ArgTy->getAsArrayType())
+ if (const ArrayType *AT = ArgTy->getAsArrayType()) {
+ // int x[restrict 4] -> int *restrict
ArgTy = Context.getPointerType(AT->getElementType());
- else if (ArgTy->isFunctionType())
+ ArgTy = ArgTy.getQualifiedType(AT->getIndexTypeQualifier());
+ } else if (ArgTy->isFunctionType())
ArgTy = Context.getPointerType(ArgTy);
// Look for 'void'. void is allowed only as a single argument to a
// function with no other parameters (C99 6.7.5.3p10). We record
diff --git a/test/Sema/function.c b/test/Sema/function.c
new file mode 100644
index 0000000000..751339b79a
--- /dev/null
+++ b/test/Sema/function.c
@@ -0,0 +1,5 @@
+// RUN: clang %s -fsyntax-only
+// PR1892
+void f(double a[restrict][5]); // should promote to restrict ptr.
+void f(double (* restrict a)[5]);
+