[cfe-commits] r58079 - in /cfe/trunk: lib/AST/Expr.cpp lib/AST/ExprConstant.cpp test/Sema/PR2919-builtin-types-compat-strips-crv.c
Daniel Dunbar
daniel at zuster.org
Fri Oct 24 01:07:59 PDT 2008
Author: ddunbar
Date: Fri Oct 24 03:07:57 2008
New Revision: 58079
URL: http://llvm.org/viewvc/llvm-project?rev=58079&view=rev
Log:
PR2919: __builtin_types_compatible_p strips CRV qualifiers.
Added:
cfe/trunk/test/Sema/PR2919-builtin-types-compat-strips-crv.c
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=58079&r1=58078&r2=58079&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Oct 24 03:07:57 2008
@@ -717,7 +717,13 @@
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: {
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=58079&r1=58078&r2=58079&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Oct 24 03:07:57 2008
@@ -205,7 +205,13 @@
}
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);
Added: cfe/trunk/test/Sema/PR2919-builtin-types-compat-strips-crv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/PR2919-builtin-types-compat-strips-crv.c?rev=58079&view=auto
==============================================================================
--- cfe/trunk/test/Sema/PR2919-builtin-types-compat-strips-crv.c (added)
+++ cfe/trunk/test/Sema/PR2919-builtin-types-compat-strips-crv.c Fri Oct 24 03:07:57 2008
@@ -0,0 +1,5 @@
+typedef struct foo T0;
+typedef const struct foo T1;
+
+int a0[__builtin_types_compatible_p(T0,
+ const T1) ? 1 : -1];
More information about the cfe-commits
mailing list