From: Douglas Gregor Date: Wed, 3 Feb 2010 19:27:29 +0000 (+0000) Subject: When determining whether a function without a prototype is compatible X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0f8eacfdcd0d43f51e669f2d723992d4af9f746;p=clang When determining whether a function without a prototype is compatible 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 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 331932a458..46c5b41f93 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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()) + argTy = Enum->getDecl()->getPromotionType(); + if (argTy->isPromotableIntegerType() || getCanonicalType(argTy).getUnqualifiedType() == FloatTy) return QualType(); diff --git a/test/Sema/function-redecl.c b/test/Sema/function-redecl.c index 9544dc9bae..1302b34b10 100644 --- a/test/Sema/function-redecl.c +++ b/test/Sema/function-redecl.c @@ -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) {}