Skip to content

Commit 2598db2

Browse files
committed
address pr comments
1 parent 362b64d commit 2598db2

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,6 +2803,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
28032803
return getUnqualifiedArrayType(T, Quals);
28042804
}
28052805

2806+
// Determine whether an array is a valid return type
2807+
// Array is a valid return type for HLSL
2808+
bool isReturnableArrayType() const { return getLangOpts().HLSL; }
2809+
28062810
/// Determine whether the given types are equivalent after
28072811
/// cvr-qualifiers have been removed.
28082812
bool hasSameUnqualifiedType(QualType T1, QualType T2) const {

clang/lib/Sema/SemaExpr.cpp

Lines changed: 3 additions & 2 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.getLangOpts().HLSL) ||
20684+
if ((DestType->isArrayType() && !S.Context.isReturnableArrayType()) ||
2068520685
DestType->isFunctionType()) {
2068620686
unsigned diagID = diag::err_func_returning_array_function;
2068720687
if (Kind == FK_BlockPointer)
@@ -20761,7 +20761,8 @@ 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() || DestType->isFunctionType()) {
20764+
if ((DestType->isArrayType() && !S.Context.isReturnableArrayType()) ||
20765+
DestType->isFunctionType()) {
2076520766
S.Diag(E->getExprLoc(), diag::err_func_returning_array_function)
2076620767
<< DestType->isFunctionType() << DestType;
2076720768
return ExprError();

clang/lib/Sema/SemaType.cpp

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

25322532
bool Sema::CheckFunctionReturnType(QualType T, SourceLocation Loc) {
2533-
if ((T->isArrayType() && !getLangOpts().HLSL) || T->isFunctionType()) {
2533+
if ((T->isArrayType() && !Context.isReturnableArrayType()) ||
2534+
T->isFunctionType()) {
25342535
Diag(Loc, diag::err_func_returning_array_function)
25352536
<< T->isFunctionType() << T;
25362537
return true;
@@ -4935,7 +4936,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
49354936
// C99 6.7.5.3p1: The return type may not be a function or array type.
49364937
// For conversion functions, we'll diagnose this particular error later.
49374938
if (!D.isInvalidType() &&
4938-
((T->isArrayType() && !S.getLangOpts().HLSL) ||
4939+
((T->isArrayType() && !S.Context.isReturnableArrayType()) ||
49394940
T->isFunctionType()) &&
49404941
(D.getName().getKind() !=
49414942
UnqualifiedIdKind::IK_ConversionFunctionId)) {

0 commit comments

Comments
 (0)