]> granicus.if.org Git - clang/commitdiff
Fix a crash in type merging with enum types.
authorEli Friedman <eli.friedman@gmail.com>
Thu, 30 Aug 2012 00:44:15 +0000 (00:44 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 30 Aug 2012 00:44:15 +0000 (00:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162886 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/Sema/function-redecl.c

index 0c2cc1c61718939845879fc3a317d48d9803025b..33846019810e4516446a6f4a31583e57f2252692 100644 (file)
@@ -6413,10 +6413,13 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
     for (unsigned i = 0; i < proto_nargs; ++i) {
       QualType argTy = proto->getArgType(i);
       
-      // Look at the promotion type of enum types, since that is the type used
+      // Look at the converted type of enum types, since that is the type used
       // to pass enum values.
-      if (const EnumType *Enum = argTy->getAs<EnumType>())
-        argTy = Enum->getDecl()->getPromotionType();
+      if (const EnumType *Enum = argTy->getAs<EnumType>()) {
+        argTy = Enum->getDecl()->getIntegerType();
+        if (argTy.isNull())
+          return QualType();
+      }
       
       if (argTy->isPromotableIntegerType() ||
           getCanonicalType(argTy).getUnqualifiedType() == FloatTy)
index 7076bdf3bd1fff1545e70bddaf6bdb6ecea202c1..ff8e003cd7229d4d2bc25cc5620a06212571f546 100644 (file)
@@ -129,3 +129,7 @@ void test_x() {
 enum e0 {one}; 
 void f3(); 
 void f3(enum e0 x) {}
+
+enum incomplete_enum;
+void f4(); // expected-note {{previous declaration is here}}
+void f4(enum incomplete_enum); // expected-error {{conflicting types for 'f4'}}