From: Douglas Gregor Date: Wed, 1 Dec 2010 16:10:38 +0000 (+0000) Subject: Improve the diagnostic when the fixed underlying type of a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d11617f6e0622bbf843d6f8d60c441f844e46e9a;p=clang Improve the diagnostic when the fixed underlying type of a redeclaration of an enum type differs from that of the original declaration, from Daniel Wallin git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120577 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 3c5c9b32e5..eb386fccee 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -879,7 +879,7 @@ def ext_enumerator_too_large : ExtWarn< def err_enumerator_wrapped : Error< "enumerator value %0 is not representable in the underlying type %1">; def err_enum_redeclare_type_mismatch : Error< - "enumeration redeclared with different underlying type">; + "enumeration redeclared with different underlying type %0 (was %1)">; def err_enum_redeclare_fixed_mismatch : Error< "enumeration previously declared with %select{non|}0fixed underlying type">; def err_enum_redeclare_scoped_mismatch : Error< diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index a3b8b8ec30..786a13f1d3 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5961,7 +5961,10 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, T = QualType(EnumUnderlying.get(), 0); if (!Context.hasSameUnqualifiedType(T, PrevEnum->getIntegerType())) { - Diag(KWLoc, diag::err_enum_redeclare_type_mismatch); + Diag(NameLoc.isValid() ? NameLoc : KWLoc, + diag::err_enum_redeclare_type_mismatch) + << T + << PrevEnum->getIntegerType(); Diag(PrevTagDecl->getLocation(), diag::note_previous_use); return PrevTagDecl; }