diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-02-22 02:45:07 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-02-22 02:45:07 +0000 |
commit | 284cc8d8a90ae6558e0a4b60b7dc1ddcfd220758 (patch) | |
tree | 8fd92888a11513a2ffb869c8b44f4436e8835c7c /lib/Sema/SemaChecking.cpp | |
parent | e9b801f7633b11b18d357a71442bd003435784e8 (diff) |
Warn about implicit conversions between values of different, named
enumeration types. Fixes <rdar://problem/8559831>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126183 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 556665483e..bb5ef7f9b3 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -2861,6 +2861,17 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, return DiagnoseImpCast(S, E, T, CC, DiagID); } + // Diagnose conversions between different enumeration types. + if (const EnumType *SourceEnum = Source->getAs<EnumType>()) + if (const EnumType *TargetEnum = Target->getAs<EnumType>()) + if ((SourceEnum->getDecl()->getIdentifier() || + SourceEnum->getDecl()->getTypedefForAnonDecl()) && + (TargetEnum->getDecl()->getIdentifier() || + TargetEnum->getDecl()->getTypedefForAnonDecl()) && + SourceEnum != TargetEnum) + return DiagnoseImpCast(S, E, T, CC, + diag::warn_impcast_different_enum_types); + return; } |