[llvm-branch-commits] [cfe-branch] r120666 - in /cfe/branches/Apple/whitney: lib/AST/Type.cpp test/Sema/enum.c

Daniel Dunbar daniel at zuster.org
Wed Dec 1 18:52:18 PST 2010


Author: ddunbar
Date: Wed Dec  1 20:52:18 2010
New Revision: 120666

URL: http://llvm.org/viewvc/llvm-project?rev=120666&view=rev
Log:
Merge r120345:
--
Author: Fariborz Jahanian <fjahanian at apple.com>
Date:   Mon Nov 29 23:18:09 2010 +0000

    Incomplete enum types not to be treated as integer type
    when checking for integer signed/unsigned-ness. PR8694,
    // rdar://8707031

Modified:
    cfe/branches/Apple/whitney/lib/AST/Type.cpp
    cfe/branches/Apple/whitney/test/Sema/enum.c

Modified: cfe/branches/Apple/whitney/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/AST/Type.cpp?rev=120666&r1=120665&r2=120666&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/AST/Type.cpp (original)
+++ cfe/branches/Apple/whitney/lib/AST/Type.cpp Wed Dec  1 20:52:18 2010
@@ -489,8 +489,12 @@
            BT->getKind() <= BuiltinType::Int128;
   }
 
-  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
-    return ET->getDecl()->getIntegerType()->isSignedIntegerType();
+  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
+    // Incomplete enum types are not treated as integer types.
+    // FIXME: In C++, enum types are never integer types.
+    if (ET->getDecl()->isComplete())
+      return ET->getDecl()->getIntegerType()->isSignedIntegerType();
+  }
 
   return false;
 }
@@ -511,8 +515,12 @@
            BT->getKind() <= BuiltinType::UInt128;
   }
 
-  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
-    return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
+  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
+    // Incomplete enum types are not treated as integer types.
+    // FIXME: In C++, enum types are never integer types.
+    if (ET->getDecl()->isComplete())
+      return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
+  }
 
   return false;
 }

Modified: cfe/branches/Apple/whitney/test/Sema/enum.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/Sema/enum.c?rev=120666&r1=120665&r2=120666&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/Sema/enum.c (original)
+++ cfe/branches/Apple/whitney/test/Sema/enum.c Wed Dec  1 20:52:18 2010
@@ -104,3 +104,16 @@
 }
 
 char test5[__has_feature(enumerator_attributes) ? 1 : -1];
+
+// PR8694
+// rdar://8707031
+void PR8694(int* e) // expected-note {{passing argument to parameter 'e' here}}
+{
+}
+
+void crash(enum E* e) // expected-warning {{declaration of 'enum E' will not be visible outside of this function}} \
+                      // expected-warning {{ISO C forbids forward references to 'enum' types}}
+{
+        PR8694(e); // expected-warning {{incompatible pointer types passing 'enum E *' to parameter of type 'int *'}}
+}
+





More information about the llvm-branch-commits mailing list