summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2014-10-15 21:37:55 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2014-10-15 21:37:55 +0000
commit715b1b7df87d4da02c120bbd360910b9da0e609b (patch)
tree3f27b3f49ce5aad2749432c8f708d8d276db083d /lib/Sema/SemaStmt.cpp
parent98cb8afec771a7af23722011d075c8d8ecd58e84 (diff)
Sema: handle AttributedTypeLocs in C++14 auto deduction
When performing a type deduction from the return type, the FunctionDecl may be attributed with a calling convention. In such a case, the retrieved type location may be an AttributedTypeLoc. Performing a castAs<FunctionProtoTypeLoc> on such a type loc would result in an assertion as they are not derived types. Ensure that we correctly handle the attributed type location by looking through it to the modified type loc. Fixes an assertion triggered in C++14 mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219851 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 464206eafe..c03ac86de0 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/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)) {