More improvements to abstract type checking. Handle arrays correctly, and make sure to check parameter types before they decay.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67550 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index c964daf..d71417b 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1996,12 +1996,6 @@
} else if (FTI.NumArgs > 0 && FTI.ArgInfo[0].Param != 0) {
for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
ParmVarDecl *PVD = (ParmVarDecl *)FTI.ArgInfo[i].Param;
-
- // Function parameters cannot have abstract class types.
- if (RequireNonAbstractType(PVD->getLocation(), PVD->getType(),
- diag::err_abstract_type_in_decl,
- 1 /* parameter type */))
- InvalidDecl = true;
Params.push_back(PVD);
}
}
@@ -2611,6 +2605,13 @@
// FIXME: If a source translation tool needs to see the original type, then
// we need to consider storing both types (in ParmVarDecl)...
//
+
+ // Parameters can not be abstract class types.
+ if (RequireNonAbstractType(D.getIdentifierLoc(), parmDeclType,
+ diag::err_abstract_type_in_decl,
+ 1 /* parameter type */))
+ D.setInvalidType(true);
+
if (parmDeclType->isArrayType()) {
// int x[restrict 4] -> int *restrict
parmDeclType = Context.getArrayDecayedType(parmDeclType);
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index ad2dba7..6f33c00 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -788,6 +788,9 @@
if (!getLangOptions().CPlusPlus)
return false;
+
+ if (const ArrayType *AT = Context.getAsArrayType(T))
+ return RequireNonAbstractType(Loc, AT->getElementType(), DiagID, SelID);
const RecordType *RT = T->getAsRecordType();
if (!RT)
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index ac36a1f..271f1da 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -197,6 +197,10 @@
diag::err_invalid_incomplete_type_use, FullRange))
return ExprError();
+ if (RequireNonAbstractType(TyBeginLoc, Ty,
+ diag::err_allocation_of_abstract_type, 0))
+ return ExprError();
+
exprs.release();
return Owned(new (Context) CXXZeroInitValueExpr(Ty, TyBeginLoc, RParenLoc));
}