[cfe-commits] r95238 - in /cfe/trunk: lib/AST/ASTContext.cpp test/Sema/function-redecl.c

Douglas Gregor dgregor at apple.com
Wed Feb 3 11:27:30 PST 2010


Author: dgregor
Date: Wed Feb  3 13:27:29 2010
New Revision: 95238

URL: http://llvm.org/viewvc/llvm-project?rev=95238&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/Sema/function-redecl.c

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=95238&r1=95237&r2=95238&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Feb  3 13:27:29 2010
@@ -4330,6 +4330,12 @@
     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();

Modified: cfe/trunk/test/Sema/function-redecl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/function-redecl.c?rev=95238&r1=95237&r2=95238&view=diff

==============================================================================
--- cfe/trunk/test/Sema/function-redecl.c (original)
+++ cfe/trunk/test/Sema/function-redecl.c Wed Feb  3 13:27:29 2010
@@ -125,3 +125,7 @@
   x(5);
   x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int', expected 'int *'}}
 }
+
+enum e0 {}; 
+void f3(); 
+void f3(enum e0 x) {}





More information about the cfe-commits mailing list