sepavloff added you to the CC list for the revision "Handle atomic types in  
Type::hasIntegerRepresentation()".

Hi doug.gregor,

Previous version of Type::hasIntegerRepresentation() returned 'false' for
types as '_Atomic(int)'. As a result, shift operations for atomic types
were not allowed. This fix allows handling atomic types in this function.

http://llvm-reviews.chandlerc.com/D673

Files:
  lib/AST/Type.cpp
  test/Sema/atomic-expr.c

Index: lib/AST/Type.cpp
===================================================================
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -613,6 +613,8 @@
 }
 
 bool Type::hasIntegerRepresentation() const {
+  if (const AtomicType *Atomic = dyn_cast<AtomicType>(CanonicalType))
+    return Atomic->getValueType()->hasIntegerRepresentation();
   if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
     return VT->getElementType()->isIntegerType();
   else
Index: test/Sema/atomic-expr.c
===================================================================
--- /dev/null
+++ test/Sema/atomic-expr.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// expected-no-diagnostics
+
+_Atomic(unsigned int) data1;
+int _Atomic data2;
+
+// Shift operations
+
+int func_01 (int x) {
+  return data1 << x;
+}
+
+int func_02 (int x) {
+  return x << data1;
+}
+
+int func_03 (int x) {
+  return data2 << x;
+}
+
+int func_04 (int x) {
+  return x << data2;
+}
+
+int func_05 () {
+  return data2 << data1;
+}
+
+int func_06 () {
+  return data1 << data2;
+}
Index: lib/AST/Type.cpp
===================================================================
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -613,6 +613,8 @@
 }
 
 bool Type::hasIntegerRepresentation() const {
+  if (const AtomicType *Atomic = dyn_cast<AtomicType>(CanonicalType))
+    return Atomic->getValueType()->hasIntegerRepresentation();
   if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
     return VT->getElementType()->isIntegerType();
   else
Index: test/Sema/atomic-expr.c
===================================================================
--- /dev/null
+++ test/Sema/atomic-expr.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// expected-no-diagnostics
+
+_Atomic(unsigned int) data1;
+int _Atomic data2;
+
+// Shift operations
+
+int func_01 (int x) {
+  return data1 << x;
+}
+
+int func_02 (int x) {
+  return x << data1;
+}
+
+int func_03 (int x) {
+  return data2 << x;
+}
+
+int func_04 (int x) {
+  return x << data2;
+}
+
+int func_05 () {
+  return data2 << data1;
+}
+
+int func_06 () {
+  return data1 << data2;
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to