From a6983a9bce475937df894aa8fe359dc516eb3d0d Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 21 Mar 2012 20:56:29 +0000 Subject: For enums with no tag name, display its location in the diagnostic instead of displaying ''. // rdar://11082110 llvm-svn: 153219 --- clang/lib/Sema/SemaStmt.cpp | 6 +++--- clang/test/Sema/switch.c | 49 ++++++++++++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 19 deletions(-) (limited to 'clang') diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 1ddedcfe680..6db66a5eff8 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -881,7 +881,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, EI++; if (EI == EIend || EI->first > CI->first) Diag(CI->second->getLHS()->getExprLoc(), diag::warn_not_in_enum) - << ED->getDeclName(); + << CondTypeBeforePromotion; } // See which of case ranges aren't in enum EI = EnumVals.begin(); @@ -892,7 +892,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, if (EI == EIend || EI->first != RI->first) { Diag(RI->second->getLHS()->getExprLoc(), diag::warn_not_in_enum) - << ED->getDeclName(); + << CondTypeBeforePromotion; } llvm::APSInt Hi = @@ -902,7 +902,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, EI++; if (EI == EIend || EI->first != Hi) Diag(RI->second->getRHS()->getExprLoc(), diag::warn_not_in_enum) - << ED->getDeclName(); + << CondTypeBeforePromotion; } // Check which enum vals aren't in switch diff --git a/clang/test/Sema/switch.c b/clang/test/Sema/switch.c index 5c8ebf516c3..a7a7f604921 100644 --- a/clang/test/Sema/switch.c +++ b/clang/test/Sema/switch.c @@ -109,14 +109,14 @@ void test7() { switch(a) { case A: case B: - case 3: // expected-warning{{case value not in enumerated type ''}} + case 3: // expected-warning{{case value not in enumerated type 'enum