r188718 - Handle init lists and _Atomic fields.

Eli Friedman eli.friedman at gmail.com
Mon Aug 19 15:12:56 PDT 2013


Author: efriedma
Date: Mon Aug 19 17:12:56 2013
New Revision: 188718

URL: http://llvm.org/viewvc/llvm-project?rev=188718&view=rev
Log:
Handle init lists and _Atomic fields.

Fixes PR16931.

Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/test/Sema/atomic-ops.c

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=188718&r1=188717&r2=188718&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Aug 19 17:12:56 2013
@@ -837,10 +837,14 @@ void InitListChecker::CheckSubElementTyp
     // C++ initialization is handled later.
   }
 
-  if (ElemType->isScalarType())
+  // FIXME: Need to handle atomic aggregate types with implicit init lists.
+  if (ElemType->isScalarType() || ElemType->isAtomicType())
     return CheckScalarType(Entity, IList, ElemType, Index,
                            StructuredList, StructuredIndex);
 
+  assert((ElemType->isRecordType() || ElemType->isVectorType() ||
+          ElemType->isArrayType()) && "Unexpected type");
+
   if (const ArrayType *arrayType = SemaRef.Context.getAsArrayType(ElemType)) {
     // arrayType can be incomplete if we're initializing a flexible
     // array member.  There's nothing we can do with the completed

Modified: cfe/trunk/test/Sema/atomic-ops.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/atomic-ops.c?rev=188718&r1=188717&r2=188718&view=diff
==============================================================================
--- cfe/trunk/test/Sema/atomic-ops.c (original)
+++ cfe/trunk/test/Sema/atomic-ops.c Mon Aug 19 17:12:56 2013
@@ -176,3 +176,9 @@ void f(_Atomic(int) *i, _Atomic(int*) *p
 
 _Atomic(int*) PR12527_a;
 void PR12527() { int *b = PR12527_a; }
+
+void PR16931(int* x) { // expected-note {{passing argument to parameter 'x' here}}
+  typedef struct { _Atomic(_Bool) flag; } flag;
+  flag flagvar = { 0 };
+  PR16931(&flagvar); // expected-warning {{incompatible pointer types}}
+}





More information about the cfe-commits mailing list