please also add the testcase the original patch was breaking. Cheers, Rafael
On 7 June 2013 18:07, David Majnemer <[email protected]> wrote: > Author: majnemer > Date: Fri Jun 7 17:07:20 2013 > New Revision: 183575 > > URL: http://llvm.org/viewvc/llvm-project?rev=183575&view=rev > Log: > Revert "Properly consider the range of enum for range comparisons in C mode" > > The approach r183084 took was wrong, back it out. > > Modified: > cfe/trunk/lib/Sema/SemaChecking.cpp > cfe/trunk/test/Sema/outof-range-constant-compare.c > > Modified: cfe/trunk/lib/Sema/SemaChecking.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=183575&r1=183574&r2=183575&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) > +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Jun 7 17:07:20 2013 > @@ -4020,23 +4020,20 @@ struct IntRange { > if (const ComplexType *CT = dyn_cast<ComplexType>(T)) > T = CT->getElementType().getTypePtr(); > > + // For enum types, use the known bit width of the enumerators. > if (const EnumType *ET = dyn_cast<EnumType>(T)) { > - if (C.getLangOpts().CPlusPlus) { > - // For enum types, use the known bit width of the enumerators. > - EnumDecl *Enum = ET->getDecl(); > - if (!Enum->isCompleteDefinition()) > - return IntRange(C.getIntWidth(QualType(T, 0)), false); > + EnumDecl *Enum = ET->getDecl(); > + if (!Enum->isCompleteDefinition()) > + return IntRange(C.getIntWidth(QualType(T, 0)), false); > > - unsigned NumPositive = Enum->getNumPositiveBits(); > - unsigned NumNegative = Enum->getNumNegativeBits(); > + unsigned NumPositive = Enum->getNumPositiveBits(); > + unsigned NumNegative = Enum->getNumNegativeBits(); > > - if (NumNegative == 0) > - return IntRange(NumPositive, true/*NonNegative*/); > - else > - return IntRange(std::max(NumPositive + 1, NumNegative), > - false/*NonNegative*/); > - } else > - T = C.getCanonicalType(ET->getDecl()->getIntegerType().getTypePtr()); > + if (NumNegative == 0) > + return IntRange(NumPositive, true/*NonNegative*/); > + else > + return IntRange(std::max(NumPositive + 1, NumNegative), > + false/*NonNegative*/); > } > > const BuiltinType *BT = cast<BuiltinType>(T); > > Modified: cfe/trunk/test/Sema/outof-range-constant-compare.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/outof-range-constant-compare.c?rev=183575&r1=183574&r2=183575&view=diff > ============================================================================== > --- cfe/trunk/test/Sema/outof-range-constant-compare.c (original) > +++ cfe/trunk/test/Sema/outof-range-constant-compare.c Fri Jun 7 17:07:20 > 2013 > @@ -147,11 +147,3 @@ int main() > > return 1; > } > - > -typedef enum { > - alpha=0, bravo, charlie, delta, echo > -} named_t; > - > -static int bar(named_t foo) { > - return foo > 42; > -} > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
