Skip to content

Commit d9a96ac

Browse files
committed
address pr comments round 2
1 parent 2598db2 commit d9a96ac

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2805,7 +2805,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
28052805

28062806
// Determine whether an array is a valid return type
28072807
// Array is a valid return type for HLSL
2808-
bool isReturnableArrayType() const { return getLangOpts().HLSL; }
2808+
bool isReturnableArrayType(QualType T) const {
2809+
return T->isArrayType() && getLangOpts().HLSL;
2810+
}
28092811

28102812
/// Determine whether the given types are equivalent after
28112813
/// cvr-qualifiers have been removed.

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20681,7 +20681,7 @@ ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
2068120681
const FunctionType *FnType = CalleeType->castAs<FunctionType>();
2068220682

2068320683
// Verify that this is a legal result type of a function.
20684-
if ((DestType->isArrayType() && !S.Context.isReturnableArrayType()) ||
20684+
if ((DestType->isArrayType() && !S.Context.isReturnableArrayType(DestType)) ||
2068520685
DestType->isFunctionType()) {
2068620686
unsigned diagID = diag::err_func_returning_array_function;
2068720687
if (Kind == FK_BlockPointer)
@@ -20761,8 +20761,7 @@ ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
2076120761

2076220762
ExprResult RebuildUnknownAnyExpr::VisitObjCMessageExpr(ObjCMessageExpr *E) {
2076320763
// Verify that this is a legal result type of a call.
20764-
if ((DestType->isArrayType() && !S.Context.isReturnableArrayType()) ||
20765-
DestType->isFunctionType()) {
20764+
if (DestType->isArrayType() || DestType->isFunctionType()) {
2076620765
S.Diag(E->getExprLoc(), diag::err_func_returning_array_function)
2076720766
<< DestType->isFunctionType() << DestType;
2076820767
return ExprError();

clang/lib/Sema/SemaType.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@ QualType Sema::BuildMatrixType(QualType ElementTy, Expr *NumRows, Expr *NumCols,
25302530
}
25312531

25322532
bool Sema::CheckFunctionReturnType(QualType T, SourceLocation Loc) {
2533-
if ((T->isArrayType() && !Context.isReturnableArrayType()) ||
2533+
if ((T->isArrayType() && !Context.isReturnableArrayType(T)) ||
25342534
T->isFunctionType()) {
25352535
Diag(Loc, diag::err_func_returning_array_function)
25362536
<< T->isFunctionType() << T;
@@ -4936,7 +4936,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
49364936
// C99 6.7.5.3p1: The return type may not be a function or array type.
49374937
// For conversion functions, we'll diagnose this particular error later.
49384938
if (!D.isInvalidType() &&
4939-
((T->isArrayType() && !S.Context.isReturnableArrayType()) ||
4939+
((T->isArrayType() && !S.Context.isReturnableArrayType(T)) ||
49404940
T->isFunctionType()) &&
49414941
(D.getName().getKind() !=
49424942
UnqualifiedIdKind::IK_ConversionFunctionId)) {

0 commit comments

Comments
 (0)