bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc,
bool Diagnose = true);
+ TypeLoc getReturnTypeLoc(FunctionDecl *FD) const;
+
bool DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD,
SourceLocation ReturnLoc,
Expr *&RetExpr, AutoType *AT);
FD->setInvalidDecl();
} else {
// Substitute 'void' for the 'auto' in the type.
- TypeLoc ResultType = FD->getTypeSourceInfo()->getTypeLoc().
- IgnoreParens().castAs<FunctionProtoTypeLoc>().getReturnLoc();
+ TypeLoc ResultType = getReturnTypeLoc(FD);
Context.adjustDeducedFunctionResultType(
FD, SubstAutoType(ResultType.getType(), Context.VoidTy));
}
}
}
+TypeLoc Sema::getReturnTypeLoc(FunctionDecl *FD) const {
+ TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
+ while (auto ATL = TL.getAs<AttributedTypeLoc>())
+ TL = ATL.getModifiedLoc().IgnoreParens();
+ return TL.IgnoreParens().castAs<FunctionProtoTypeLoc>().getReturnLoc();
+}
+
/// Deduce the return type for a function from a returned expression, per
/// C++1y [dcl.spec.auto]p6.
bool Sema::DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD,
SourceLocation ReturnLoc,
Expr *&RetExpr,
AutoType *AT) {
- TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
- if (auto ATL = TL.getAs<AttributedTypeLoc>())
- TL = ATL.getModifiedLoc();
- TypeLoc OrigResultType =
- TL.IgnoreParens().castAs<FunctionProtoTypeLoc>().getReturnLoc();
+ TypeLoc OrigResultType = getReturnTypeLoc(FD);
QualType Deduced;
if (RetExpr && isa<InitListExpr>(RetExpr)) {
// expected-no-diagnostics
void deduce() {
- auto lambda = [](int i) __attribute__ (( pcs("aapcs") )) {
+ auto single_int = [](int i) __attribute__ (( pcs("aapcs") )) {
return i;
};
- lambda(42);
+ auto multiple_int = [](int i) __attribute__ (( pcs("aapcs") ))
+ __attribute__ (( pcs("aapcs") )) {
+ return i;
+ };
+
+ auto single_void = []() __attribute__ (( pcs("aapcs") )) { };
+ auto multiple_void = []() __attribute__ (( pcs("aapcs") ))
+ __attribute__ (( pcs("aapcs") )) { };
}
+auto ( __attribute__ (( pcs("aapcs") )) single_attribute() ) { }
+auto ( ( __attribute__ (( pcs("aapcs") )) ( ( __attribute__ (( pcs("aapcs") )) multiple_attributes() ) ) ) ) { }
+