@@ -735,13 +735,28 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
735
735
// Check for equivalent field names.
736
736
IdentifierInfo *Name1 = Field1->getIdentifier ();
737
737
IdentifierInfo *Name2 = Field2->getIdentifier ();
738
- if (!::IsStructurallyEquivalent (Name1, Name2))
738
+ if (!::IsStructurallyEquivalent (Name1, Name2)) {
739
+ if (Context.Complain ) {
740
+ Context.Diag2 (Owner2->getLocation (),
741
+ Context.ErrorOnTagTypeMismatch
742
+ ? diag::err_odr_tag_type_inconsistent
743
+ : diag::warn_odr_tag_type_inconsistent)
744
+ << Context.ToCtx .getTypeDeclType (Owner2);
745
+ Context.Diag2 (Field2->getLocation (), diag::note_odr_field_name)
746
+ << Field2->getDeclName ();
747
+ Context.Diag1 (Field1->getLocation (), diag::note_odr_field_name)
748
+ << Field1->getDeclName ();
749
+ }
739
750
return false ;
751
+ }
740
752
741
753
if (!IsStructurallyEquivalent (Context, Field1->getType (),
742
754
Field2->getType ())) {
743
755
if (Context.Complain ) {
744
- Context.Diag2 (Owner2->getLocation (), diag::warn_odr_tag_type_inconsistent)
756
+ Context.Diag2 (Owner2->getLocation (),
757
+ Context.ErrorOnTagTypeMismatch
758
+ ? diag::err_odr_tag_type_inconsistent
759
+ : diag::warn_odr_tag_type_inconsistent)
745
760
<< Context.ToCtx .getTypeDeclType (Owner2);
746
761
Context.Diag2 (Field2->getLocation (), diag::note_odr_field)
747
762
<< Field2->getDeclName () << Field2->getType ();
@@ -753,7 +768,10 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
753
768
754
769
if (Field1->isBitField () != Field2->isBitField ()) {
755
770
if (Context.Complain ) {
756
- Context.Diag2 (Owner2->getLocation (), diag::warn_odr_tag_type_inconsistent)
771
+ Context.Diag2 (Owner2->getLocation (),
772
+ Context.ErrorOnTagTypeMismatch
773
+ ? diag::err_odr_tag_type_inconsistent
774
+ : diag::warn_odr_tag_type_inconsistent)
757
775
<< Context.ToCtx .getTypeDeclType (Owner2);
758
776
if (Field1->isBitField ()) {
759
777
Context.Diag1 (Field1->getLocation (), diag::note_odr_bit_field)
@@ -780,7 +798,9 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
780
798
if (Bits1 != Bits2) {
781
799
if (Context.Complain ) {
782
800
Context.Diag2 (Owner2->getLocation (),
783
- diag::warn_odr_tag_type_inconsistent)
801
+ Context.ErrorOnTagTypeMismatch
802
+ ? diag::err_odr_tag_type_inconsistent
803
+ : diag::warn_odr_tag_type_inconsistent)
784
804
<< Context.ToCtx .getTypeDeclType (Owner2);
785
805
Context.Diag2 (Field2->getLocation (), diag::note_odr_bit_field)
786
806
<< Field2->getDeclName () << Field2->getType () << Bits2;
@@ -799,7 +819,10 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
799
819
RecordDecl *D1, RecordDecl *D2) {
800
820
if (D1->isUnion () != D2->isUnion ()) {
801
821
if (Context.Complain ) {
802
- Context.Diag2 (D2->getLocation (), diag::warn_odr_tag_type_inconsistent)
822
+ Context.Diag2 (D2->getLocation (),
823
+ Context.ErrorOnTagTypeMismatch
824
+ ? diag::err_odr_tag_type_inconsistent
825
+ : diag::warn_odr_tag_type_inconsistent)
803
826
<< Context.ToCtx .getTypeDeclType (D2);
804
827
Context.Diag1 (D1->getLocation (), diag::note_odr_tag_kind_here)
805
828
<< D1->getDeclName () << (unsigned )D1->getTagKind ();
@@ -927,7 +950,10 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
927
950
Field1 != Field1End; ++Field1, ++Field2) {
928
951
if (Field2 == Field2End) {
929
952
if (Context.Complain ) {
930
- Context.Diag2 (D2->getLocation (), diag::warn_odr_tag_type_inconsistent)
953
+ Context.Diag2 (D2->getLocation (),
954
+ Context.ErrorOnTagTypeMismatch
955
+ ? diag::err_odr_tag_type_inconsistent
956
+ : diag::warn_odr_tag_type_inconsistent)
931
957
<< Context.ToCtx .getTypeDeclType (D2);
932
958
Context.Diag1 (Field1->getLocation (), diag::note_odr_field)
933
959
<< Field1->getDeclName () << Field1->getType ();
@@ -942,7 +968,10 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
942
968
943
969
if (Field2 != Field2End) {
944
970
if (Context.Complain ) {
945
- Context.Diag2 (D2->getLocation (), diag::warn_odr_tag_type_inconsistent)
971
+ Context.Diag2 (D2->getLocation (),
972
+ Context.ErrorOnTagTypeMismatch
973
+ ? diag::err_odr_tag_type_inconsistent
974
+ : diag::warn_odr_tag_type_inconsistent)
946
975
<< Context.ToCtx .getTypeDeclType (D2);
947
976
Context.Diag2 (Field2->getLocation (), diag::note_odr_field)
948
977
<< Field2->getDeclName () << Field2->getType ();
@@ -964,7 +993,10 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
964
993
EC1 != EC1End; ++EC1, ++EC2) {
965
994
if (EC2 == EC2End) {
966
995
if (Context.Complain ) {
967
- Context.Diag2 (D2->getLocation (), diag::warn_odr_tag_type_inconsistent)
996
+ Context.Diag2 (D2->getLocation (),
997
+ Context.ErrorOnTagTypeMismatch
998
+ ? diag::err_odr_tag_type_inconsistent
999
+ : diag::warn_odr_tag_type_inconsistent)
968
1000
<< Context.ToCtx .getTypeDeclType (D2);
969
1001
Context.Diag1 (EC1->getLocation (), diag::note_odr_enumerator)
970
1002
<< EC1->getDeclName () << EC1->getInitVal ().toString (10 );
@@ -978,7 +1010,10 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
978
1010
if (!llvm::APSInt::isSameValue (Val1, Val2) ||
979
1011
!IsStructurallyEquivalent (EC1->getIdentifier (), EC2->getIdentifier ())) {
980
1012
if (Context.Complain ) {
981
- Context.Diag2 (D2->getLocation (), diag::warn_odr_tag_type_inconsistent)
1013
+ Context.Diag2 (D2->getLocation (),
1014
+ Context.ErrorOnTagTypeMismatch
1015
+ ? diag::err_odr_tag_type_inconsistent
1016
+ : diag::warn_odr_tag_type_inconsistent)
982
1017
<< Context.ToCtx .getTypeDeclType (D2);
983
1018
Context.Diag2 (EC2->getLocation (), diag::note_odr_enumerator)
984
1019
<< EC2->getDeclName () << EC2->getInitVal ().toString (10 );
@@ -991,7 +1026,10 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
991
1026
992
1027
if (EC2 != EC2End) {
993
1028
if (Context.Complain ) {
994
- Context.Diag2 (D2->getLocation (), diag::warn_odr_tag_type_inconsistent)
1029
+ Context.Diag2 (D2->getLocation (),
1030
+ Context.ErrorOnTagTypeMismatch
1031
+ ? diag::err_odr_tag_type_inconsistent
1032
+ : diag::warn_odr_tag_type_inconsistent)
995
1033
<< Context.ToCtx .getTypeDeclType (D2);
996
1034
Context.Diag2 (EC2->getLocation (), diag::note_odr_enumerator)
997
1035
<< EC2->getDeclName () << EC2->getInitVal ().toString (10 );
0 commit comments