]> granicus.if.org Git - clang/commitdiff
When determining whether a function without a prototype is compatible
authorDouglas Gregor <dgregor@apple.com>
Wed, 3 Feb 2010 19:27:29 +0000 (19:27 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 3 Feb 2010 19:27:29 +0000 (19:27 +0000)
with a function with a prototype, treat parameters of enumeration type
based on the enumeration type's promotion type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95238 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 331932a4585bbf370c42012a928058196c439bcc..46c5b41f931472acead823d877450387017a8085 100644 (file)
@@ -4330,6 +4330,12 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs) {
     unsigned proto_nargs = proto->getNumArgs();
     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
+      // to pass enum values.
+      if (const EnumType *Enum = argTy->getAs<EnumType>())
+        argTy = Enum->getDecl()->getPromotionType();
+      
       if (argTy->isPromotableIntegerType() ||
           getCanonicalType(argTy).getUnqualifiedType() == FloatTy)
         return QualType();
index 9544dc9baef698569ff42b30ffb7cef340381a46..1302b34b107a38e43d75feffb7f86f1a3dbd0f13 100644 (file)
@@ -125,3 +125,7 @@ void test_x() {
   x(5);
   x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int', expected 'int *'}}
 }
+
+enum e0 {}; 
+void f3(); 
+void f3(enum e0 x) {}