[llvm-branch-commits] [cfe-branch] r227349 - Merging r227295:

Hans Wennborg hans at hanshq.net
Wed Jan 28 11:18:37 PST 2015


Author: hans
Date: Wed Jan 28 13:18:37 2015
New Revision: 227349

URL: http://llvm.org/viewvc/llvm-project?rev=227349&view=rev
Log:
Merging r227295:
------------------------------------------------------------------------
r227295 | majnemer | 2015-01-27 21:48:06 -0800 (Tue, 27 Jan 2015) | 5 lines

Sema: Ensure that __c11_atomic_fetch_add has a pointer to complete type

Pointer arithmetic is only makes sense if the pointee type is complete.

This fixes PR22361.
------------------------------------------------------------------------

Modified:
    cfe/branches/release_36/   (props changed)
    cfe/branches/release_36/lib/Sema/SemaChecking.cpp
    cfe/branches/release_36/test/Sema/atomic-ops.c

Propchange: cfe/branches/release_36/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 28 13:18:37 2015
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:226008,226049,226136,226282,226624,226707,226754,226863,226877,227062,227220,227251,227278
+/cfe/trunk:226008,226049,226136,226282,226624,226707,226754,226863,226877,227062,227220,227251,227278,227295
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_36/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_36/lib/Sema/SemaChecking.cpp?rev=227349&r1=227348&r2=227349&view=diff
==============================================================================
--- cfe/branches/release_36/lib/Sema/SemaChecking.cpp (original)
+++ cfe/branches/release_36/lib/Sema/SemaChecking.cpp Wed Jan 28 13:18:37 2015
@@ -1340,6 +1340,11 @@ ExprResult Sema::SemaAtomicOpsOverloaded
         << IsC11 << Ptr->getType() << Ptr->getSourceRange();
       return ExprError();
     }
+    if (IsC11 && ValType->isPointerType() &&
+        RequireCompleteType(Ptr->getLocStart(), ValType->getPointeeType(),
+                            diag::err_incomplete_type)) {
+      return ExprError();
+    }
   } else if (IsN && !ValType->isIntegerType() && !ValType->isPointerType()) {
     // For __atomic_*_n operations, the value type must be a scalar integral or
     // pointer type which is 1, 2, 4, 8 or 16 bytes in length.

Modified: cfe/branches/release_36/test/Sema/atomic-ops.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_36/test/Sema/atomic-ops.c?rev=227349&r1=227348&r2=227349&view=diff
==============================================================================
--- cfe/branches/release_36/test/Sema/atomic-ops.c (original)
+++ cfe/branches/release_36/test/Sema/atomic-ops.c Wed Jan 28 13:18:37 2015
@@ -49,7 +49,7 @@ char i8;
 short i16;
 int i32;
 int __attribute__((vector_size(8))) i64;
-struct Incomplete *incomplete;
+struct Incomplete *incomplete; // expected-note {{forward declaration of 'struct Incomplete'}}
 
 _Static_assert(__atomic_is_lock_free(1, &i8), "");
 _Static_assert(__atomic_is_lock_free(1, &i64), "");
@@ -268,6 +268,10 @@ void memory_checks(_Atomic(int) *Ap, int
   (void)__c11_atomic_fetch_add(Ap, 1, memory_order_acq_rel);
   (void)__c11_atomic_fetch_add(Ap, 1, memory_order_seq_cst);
 
+  (void)__c11_atomic_fetch_add(
+      (struct Incomplete * _Atomic *)0, // expected-error {{incomplete type 'struct Incomplete'}}
+      1, memory_order_seq_cst);
+
   (void)__c11_atomic_init(Ap, val);
   (void)__c11_atomic_init(Ap, val);
   (void)__c11_atomic_init(Ap, val);





More information about the llvm-branch-commits mailing list