diff options
author | Anders Carlsson <andersca@mac.com> | 2009-10-09 23:51:55 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-10-09 23:51:55 +0000 |
commit | 8c8d91917c307dc3ba4f60661377c745f2a6bef2 (patch) | |
tree | 17e9e9e63862004965ff1777415f48fd7f89f87d /lib/Sema/SemaType.cpp | |
parent | 3135df59cbe140923d9e81c09e3e324c01418bb6 (diff) |
Add CheckCallReturnType and start using it for regular call expressions. This will improve error messages. For
struct B;
B f();
void g() {
f();
}
We now get
t.cpp:6:3: error: calling 'f' with incomplete return type 'struct B'
f();
^~~
t.cpp:3:3: note: 'f' declared here
B f();
^
t.cpp:1:8: note: forward declaration of 'struct B'
struct B;
^
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83692 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r-- | lib/Sema/SemaType.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index da72197f0c..6767712085 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1820,7 +1820,9 @@ void Sema::ProcessTypeAttributeList(QualType &Result, const AttributeList *AL) { /// @returns @c true if @p T is incomplete and a diagnostic was emitted, /// @c false otherwise. bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, - const PartialDiagnostic &PD) { + const PartialDiagnostic &PD, + std::pair<SourceLocation, + PartialDiagnostic> Note) { unsigned diag = PD.getDiagID(); // FIXME: Add this assertion to help us flush out problems with @@ -1864,6 +1866,10 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, // We have an incomplete type. Produce a diagnostic. Diag(Loc, PD) << T; + // If we have a note, produce it. + if (!Note.first.isInvalid()) + Diag(Note.first, Note.second); + // If the type was a forward declaration of a class/struct/union // type, produce const TagType *Tag = 0; |