Author: rjmccall
Date: Tue Feb  1 17:28:01 2011
New Revision: 124702

URL: http://llvm.org/viewvc/llvm-project?rev=124702&view=rev
Log:
When diagnosing address-space changes, apply array-to-pointer decay first.


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/address_spaces.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=124702&r1=124701&r2=124702&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Feb  1 17:28:01 2011
@@ -8690,6 +8690,9 @@
     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()) {

Modified: cfe/trunk/test/Sema/address_spaces.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address_spaces.c?rev=124702&r1=124701&r2=124702&view=diff
==============================================================================
--- cfe/trunk/test/Sema/address_spaces.c (original)
+++ cfe/trunk/test/Sema/address_spaces.c Tue Feb  1 17:28:01 2011
@@ -39,3 +39,8 @@
   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}}
+}


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to