diff --git a/clang/lib/AST/ODRDiagsEmitter.cpp b/clang/lib/AST/ODRDiagsEmitter.cpp --- a/clang/lib/AST/ODRDiagsEmitter.cpp +++ b/clang/lib/AST/ODRDiagsEmitter.cpp @@ -193,6 +193,10 @@ DiagNote(TypedefType) << IsTypeAlias << SecondName << SecondType; return true; } + + if (diagnoseSubMismatchAttr(FirstRecord, FirstModule, SecondModule, FirstTD, + SecondTD)) + return true; return false; } diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp --- a/clang/lib/AST/ODRHash.cpp +++ b/clang/lib/AST/ODRHash.cpp @@ -506,6 +506,14 @@ } break; } + case attr::AlignValue: { + auto *M = cast(A); + Expr *AlignmentExpr = M->getAlignment(); + ID.AddBoolean(AlignmentExpr); + if (AlignmentExpr) + AddStmt(AlignmentExpr); + break; + } case attr::EnumExtensibility: { auto *M = cast(A); ID.AddInteger(M->getExtensibility()); diff --git a/clang/test/Modules/odr_hash.cpp b/clang/test/Modules/odr_hash.cpp --- a/clang/test/Modules/odr_hash.cpp +++ b/clang/test/Modules/odr_hash.cpp @@ -3788,6 +3788,32 @@ // expected-note@second.h:* {{attribute specified here}} #endif +#if defined(FIRST) +struct TypedefAttributePresence { + typedef double *AlignedDoublePtr __attribute__((align_value(64))); +}; +struct TypedefDifferentAttributeValue { + typedef double *AlignedDoublePtr __attribute__((align_value(64))); +}; +#elif defined(SECOND) +struct TypedefAttributePresence { + typedef double *AlignedDoublePtr; +}; +struct TypedefDifferentAttributeValue { + typedef double *AlignedDoublePtr __attribute__((align_value(32))); +}; +#else +TypedefAttributePresence testTypedefAttrPresence; +// expected-error@first.h:* {{'Types::Attributes::TypedefAttributePresence' has different definitions in different modules; first difference is definition in module 'FirstModule' found 'AlignedDoublePtr' with attribute 'align_value'}} +// expected-note@first.h:* {{attribute specified here}} +// expected-note@second.h:* {{but in 'SecondModule' found 'AlignedDoublePtr' with no attribute}} +TypedefDifferentAttributeValue testDifferentArgumentsInTypedefAttribute; +// expected-error@first.h:* {{'Types::Attributes::TypedefDifferentAttributeValue' has different definitions in different modules; first difference is definition in module 'FirstModule' found 'AlignedDoublePtr' with attribute ' __attribute__((align_value(64)))'}} +// expected-note@first.h:* {{attribute specified here}} +// expected-note@second.h:* {{but in 'SecondModule' found 'AlignedDoublePtr' with different attribute argument ' __attribute__((align_value(32)))'}} +// expected-note@second.h:* {{attribute specified here}} +#endif + #if defined(FIRST) #define PACKED __attribute__((packed)) struct PACKED AttributeInMacro {