Ban the use of __builtin_types_compatible_p in C++; g++ doesn't support it,
and it isn't clear exactly what it's supposed to mean. Thanks Eli!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72142 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 3f99c68..bb85455 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -5022,6 +5022,12 @@
assert((!argT1.isNull() && !argT2.isNull()) && "Missing type argument(s)");
+ if (getLangOptions().CPlusPlus) {
+ Diag(BuiltinLoc, diag::err_types_compatible_p_in_cplusplus)
+ << SourceRange(BuiltinLoc, RPLoc);
+ return ExprError();
+ }
+
return Owned(new (Context) TypesCompatibleExpr(Context.IntTy, BuiltinLoc,
argT1, argT2, RPLoc));
}
diff --git a/lib/Sema/SemaTemplateInstantiateExpr.cpp b/lib/Sema/SemaTemplateInstantiateExpr.cpp
index 5e91ada..ca19a3d 100644
--- a/lib/Sema/SemaTemplateInstantiateExpr.cpp
+++ b/lib/Sema/SemaTemplateInstantiateExpr.cpp
@@ -469,22 +469,8 @@
Sema::OwningExprResult
TemplateExprInstantiator::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
- QualType Type1 = SemaRef.InstantiateType(E->getArgType1(), TemplateArgs,
- /*FIXME:*/ E->getBuiltinLoc(),
- DeclarationName());
- if (Type1.isNull())
- return SemaRef.ExprError();
-
- QualType Type2 = SemaRef.InstantiateType(E->getArgType2(), TemplateArgs,
- /*FIXME:*/ E->getBuiltinLoc(),
- DeclarationName());
- if (Type2.isNull())
- return SemaRef.ExprError();
-
- return SemaRef.ActOnTypesCompatibleExpr(E->getBuiltinLoc(),
- Type1.getAsOpaquePtr(),
- Type2.getAsOpaquePtr(),
- E->getRParenLoc());
+ assert(false && "__builtin_types_compatible_p is not legal in C++");
+ return SemaRef.ExprError();
}
Sema::OwningExprResult