summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-08-14 02:06:07 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-08-14 02:06:07 +0000
commit1d4c3cfb88d12de8c308f2484ab9dc9ad74e3300 (patch)
treee9c41efb5fdcf2804e6ba0203123e40f2becc925 /clang/lib
parent7d6d47b862a82f402554ecb2914d407182783964 (diff)
downloadbcm5719-llvm-1d4c3cfb88d12de8c308f2484ab9dc9ad74e3300.tar.gz
bcm5719-llvm-1d4c3cfb88d12de8c308f2484ab9dc9ad74e3300.zip
Make __is_convertible_to handle abstract types correctly. PR13591.
llvm-svn: 161828
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp1
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp18
2 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 539ed0eac56..1d45a6823da 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -3478,6 +3478,7 @@ bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T,
: TypeDiagnoser(DiagID == 0), DiagID(DiagID), SelID(SelID) { }
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) {
+ if (Suppressed) return;
if (SelID == -1)
S.Diag(Loc, DiagID) << T;
else
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 1a3cff5bd7c..27402599a40 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -3542,9 +3542,25 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, BinaryTypeTrait BTT,
// We model the initialization as a copy-initialization of a temporary
// of the appropriate type, which for this expression is identical to the
// return statement (since NRVO doesn't apply).
+
+ // Functions aren't allowed to return function or array types.
+ if (RhsT->isFunctionType() || RhsT->isArrayType())
+ return false;
+
+ // A return statement in a void function must have void type.
+ if (RhsT->isVoidType())
+ return LhsT->isVoidType();
+
+ // A function definition requires a complete, non-abstract return type.
+ if (Self.RequireCompleteType(KeyLoc, RhsT, 0) ||
+ Self.RequireNonAbstractType(KeyLoc, RhsT, 0))
+ return false;
+
+ // Compute the result of add_rvalue_reference.
if (LhsT->isObjectType() || LhsT->isFunctionType())
LhsT = Self.Context.getRValueReferenceType(LhsT);
-
+
+ // Build a fake source and destination for initialization.
InitializedEntity To(InitializedEntity::InitializeTemporary(RhsT));
OpaqueValueExpr From(KeyLoc, LhsT.getNonLValueExprType(Self.Context),
Expr::getValueKindForType(LhsT));
OpenPOWER on IntegriCloud