diff options
author | Eric Fiselier <eric@efcs.ca> | 2019-02-01 22:06:02 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2019-02-01 22:06:02 +0000 |
commit | 207c6e6243d3cac318287382d2ce7d2de071800d (patch) | |
tree | 28cb8b05132010186be41184db55894242a5a1e2 /test/SemaCXX/decl-init-ref.cpp | |
parent | bda04e052c4b14818d140f2a8f6e063f36c1552e (diff) | |
download | clang-207c6e6243d3cac318287382d2ce7d2de071800d.tar.gz |
Improve diagnostic to tell you a type is incomplete.
I recently ran into this code:
```
\#include <iostream>
void foo(const std::string &s, const std::string& = "");
\#include <string>
void test() { foo(""); }
```
The diagnostic produced said it can't bind char[1] to std::string
const&. It didn't mention std::string is incomplete. The user had to
infer that.
This patch causes the diagnostic to now say "incomplete type".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352927 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/decl-init-ref.cpp')
-rw-r--r-- | test/SemaCXX/decl-init-ref.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/SemaCXX/decl-init-ref.cpp b/test/SemaCXX/decl-init-ref.cpp index 42b9286852..fb5ca8c149 100644 --- a/test/SemaCXX/decl-init-ref.cpp +++ b/test/SemaCXX/decl-init-ref.cpp @@ -36,3 +36,12 @@ namespace PR16502 { int f(); const A &c = { 10, ++c.temporary }; } + +namespace IncompleteTest { + struct String; + // expected-error@+1 {{reference to incomplete type 'const IncompleteTest::String' could not bind to an lvalue of type 'const char [1]'}} + void takeString(const String& = "") {} // expected-note {{passing argument to parameter here}} expected-note {{candidate function}} + void test() { + takeString(); // expected-error {{no matching function for call}} + } +} |