summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaStmt.cpp7
-rw-r--r--clang/test/Sema/attributed-auto-deduction.cpp10
2 files changed, 15 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 464206eafe3..c03ac86de05 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -2755,8 +2755,11 @@ bool Sema::DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD,
SourceLocation ReturnLoc,
Expr *&RetExpr,
AutoType *AT) {
- TypeLoc OrigResultType = FD->getTypeSourceInfo()->getTypeLoc().
- IgnoreParens().castAs<FunctionProtoTypeLoc>().getReturnLoc();
+ TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
+ if (auto ATL = TL.getAs<AttributedTypeLoc>())
+ TL = ATL.getModifiedLoc();
+ TypeLoc OrigResultType =
+ TL.IgnoreParens().castAs<FunctionProtoTypeLoc>().getReturnLoc();
QualType Deduced;
if (RetExpr && isa<InitListExpr>(RetExpr)) {
diff --git a/clang/test/Sema/attributed-auto-deduction.cpp b/clang/test/Sema/attributed-auto-deduction.cpp
new file mode 100644
index 00000000000..d8dc43d6691
--- /dev/null
+++ b/clang/test/Sema/attributed-auto-deduction.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple armv7 -std=c++14 -x c++ %s -fsyntax-only
+// expected-no-diagnostics
+
+void deduce() {
+ auto lambda = [](int i) __attribute__ (( pcs("aapcs") )) {
+ return i;
+ };
+ lambda(42);
+}
+
OpenPOWER on IntegriCloud