diff options
author | John McCall <rjmccall@apple.com> | 2011-02-01 23:28:01 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-02-01 23:28:01 +0000 |
commit | 71de91cc09a363acacf94a956164b1391d7b0583 (patch) | |
tree | ea7bf1cc89e1a465b7a747ae604474ad83039a6c | |
parent | 265c325ef3378dcc2c93d16c076a37b9c450237f (diff) | |
download | bcm5719-llvm-71de91cc09a363acacf94a956164b1391d7b0583.tar.gz bcm5719-llvm-71de91cc09a363acacf94a956164b1391d7b0583.zip |
When diagnosing address-space changes, apply array-to-pointer decay first.
llvm-svn: 124702
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 3 | ||||
-rw-r--r-- | clang/test/Sema/address_spaces.c | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ab190276af3..c084bb0a80d 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8690,6 +8690,9 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, DiagKind = diag::ext_typecheck_convert_pointer_void_func; break; case IncompatiblePointerDiscardsQualifiers: { + // Perform array-to-pointer decay if necessary. + if (SrcType->isArrayType()) SrcType = Context.getArrayDecayedType(SrcType); + Qualifiers lhq = SrcType->getPointeeType().getQualifiers(); Qualifiers rhq = DstType->getPointeeType().getQualifiers(); if (lhq.getAddressSpace() != rhq.getAddressSpace()) { diff --git a/clang/test/Sema/address_spaces.c b/clang/test/Sema/address_spaces.c index 38b51b29126..a53bb4da000 100644 --- a/clang/test/Sema/address_spaces.c +++ b/clang/test/Sema/address_spaces.c @@ -39,3 +39,8 @@ void * get_0(void) { return base[0]; // expected-error {{returning '__attribute__((address_space(256))) void *' from a function with result type 'void *' changes address space of pointer}} } +__attribute__((address_space(1))) char test3_array[10]; +void test3(void) { + extern void test3_helper(char *p); // expected-note {{passing argument to parameter 'p' here}} + test3_helper(test3_array); // expected-error {{changes address space of pointer}} +} |