summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-05-30 12:50:48 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-05-30 12:50:48 +0000
commit28f048af9db8540fb3c4a6b1cd1770a0dbb6cc3b (patch)
tree56ec9ac467648312430fe7d3f03a045d6047628a /clang/lib
parent8573defa2d5439aeefa6cf5edab800ca9a18bf36 (diff)
downloadbcm5719-llvm-28f048af9db8540fb3c4a6b1cd1770a0dbb6cc3b.tar.gz
bcm5719-llvm-28f048af9db8540fb3c4a6b1cd1770a0dbb6cc3b.zip
[Sema] Don't skip function bodies with 'auto' without trailing return type
Summary: Skipping them was clearly not intentional. It's impossible to guarantee correctness if the bodies are skipped. Also adds a test case for r327504, now that it does not produce invalid errors that made the test fail. Reviewers: aaron.ballman, sammccall, rsmith Reviewed By: rsmith Subscribers: rayglover-ibm, rwols, cfe-commits Differential Revision: https://reviews.llvm.org/D44480 llvm-svn: 333538
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e0be9efe966..cc44c034eae 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12660,9 +12660,15 @@ bool Sema::canSkipFunctionBody(Decl *D) {
// rest of the file.
// We cannot skip the body of a function with an undeduced return type,
// because any callers of that function need to know the type.
- if (const FunctionDecl *FD = D->getAsFunction())
- if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
+ if (const FunctionDecl *FD = D->getAsFunction()) {
+ if (FD->isConstexpr())
return false;
+ // We can't simply call Type::isUndeducedType here, because inside template
+ // auto can be deduced to a dependent type, which is not considered
+ // "undeduced".
+ if (FD->getReturnType()->getContainedDeducedType())
+ return false;
+ }
return Consumer.shouldSkipFunctionBody(D);
}
OpenPOWER on IntegriCloud