зеркало из https://github.com/microsoft/clang-1.git
PR2919: __builtin_types_compatible_p strips CRV qualifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58079 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
d02dae5a21
Коммит
ac620decb6
|
@ -717,7 +717,13 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
|
|||
case TypesCompatibleExprClass: {
|
||||
const TypesCompatibleExpr *TCE = cast<TypesCompatibleExpr>(this);
|
||||
Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType())));
|
||||
Result = Ctx.typesAreCompatible(TCE->getArgType1(), TCE->getArgType2());
|
||||
// Per gcc docs "this built-in function ignores top level
|
||||
// qualifiers". We need to use the canonical version to properly
|
||||
// be able to strip CRV qualifiers from the type.
|
||||
QualType T0 = Ctx.getCanonicalType(TCE->getArgType1());
|
||||
QualType T1 = Ctx.getCanonicalType(TCE->getArgType2());
|
||||
Result = Ctx.typesAreCompatible(T0.getUnqualifiedType(),
|
||||
T1.getUnqualifiedType());
|
||||
break;
|
||||
}
|
||||
case CallExprClass: {
|
||||
|
|
|
@ -205,7 +205,13 @@ public:
|
|||
}
|
||||
bool VisitTypesCompatibleExpr(const TypesCompatibleExpr *E) {
|
||||
Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
|
||||
Result = Info.Ctx.typesAreCompatible(E->getArgType1(), E->getArgType2());
|
||||
// Per gcc docs "this built-in function ignores top level
|
||||
// qualifiers". We need to use the canonical version to properly
|
||||
// be able to strip CRV qualifiers from the type.
|
||||
QualType T0 = Info.Ctx.getCanonicalType(E->getArgType1());
|
||||
QualType T1 = Info.Ctx.getCanonicalType(E->getArgType2());
|
||||
Result = Info.Ctx.typesAreCompatible(T0.getUnqualifiedType(),
|
||||
T1.getUnqualifiedType());
|
||||
return true;
|
||||
}
|
||||
bool VisitDeclRefExpr(const DeclRefExpr *E);
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
typedef struct foo T0;
|
||||
typedef const struct foo T1;
|
||||
|
||||
int a0[__builtin_types_compatible_p(T0,
|
||||
const T1) ? 1 : -1];
|
Загрузка…
Ссылка в новой задаче