Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve diagnostic for * vs & confusion #6313

Closed
lattner opened this issue Jan 5, 2010 · 6 comments
Closed

improve diagnostic for * vs & confusion #6313

lattner opened this issue Jan 5, 2010 · 6 comments

Comments

@lattner
Copy link
Collaborator

lattner commented Jan 5, 2010

Bugzilla Link 5941
Version unspecified
OS All
CC @DougGregor,@jryans

Extended Description

Consider:

class A;
void f0(A *a);
void f1(A &a);
void f2(A *a) {
f1(a);
}
void f3(A &a) {
f0(a);
}

We produce:
t.cc:7:3: error: no matching function for call to 'f1'
f1(a);
^~
t.cc:4:6: note: candidate function
void f1(A &a);
^
t.cc:11:3: error: no matching function for call to 'f0'
f0(a);
^~
t.cc:3:6: note: candidate function
void f0(A *a);
^

In addition to producing a better error message for this common issue, it would be really nice to produce a fixit that ass a & or *.

This is AKA rdar://7113438

@DougGregor
Copy link
Contributor

*** Bug llvm/llvm-bugzilla-archive#9555 has been marked as a duplicate of this bug. ***

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 22, 2012

As of r158931, clang's error messages are better:

$ cat tmp.cc
class A;
void f0(A *a);
void f1(A &a);
void f2(A *a) {
f1(a);
}
void f3(A &a) {
f0(a);
}

$ ./bin/clang -fsyntax-only tmp.cc
tmp.cc:5:3: error: no matching function for call to 'f1'
f1(a);
^~
tmp.cc:3:6: note: candidate function not viable: cannot convert argument of incomplete type 'A *' to
'A &'
void f1(A &a);
^
tmp.cc:8:3: error: no matching function for call to 'f0'
f0(a);
^~
tmp.cc:2:6: note: candidate function not viable: cannot convert argument of incomplete type 'A' to
'A *'
void f0(A *a);
^
2 errors generated.

And if you change "class A;" to "class A {};":

$ ./bin/clang -fsyntax-only tmp.cc
tmp.cc:5:3: error: no matching function for call to 'f1'
f1(a);
^~
tmp.cc:3:6: note: candidate function not viable: no known conversion from 'A *' to 'A &' for 1st
argument; dereference the argument with *
void f1(A &a);
^
tmp.cc:8:3: error: no matching function for call to 'f0'
f0(a);
^~
tmp.cc:2:6: note: candidate function not viable: no known conversion from 'A' to 'A *' for 1st
argument; take the address of the argument with &
void f0(A *a);
^
2 errors generated.

The error message when A is an incomplete type could use a bit more love to make it more helpful like when A is a complete type, and there aren't any fix-it hints for any of the cases.

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 6, 2016

Created a patch submission here: http://reviews.llvm.org/D16949

@DougGregor
Copy link
Contributor

mentioned in issue llvm/llvm-bugzilla-archive#9555

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
augusto2112 pushed a commit to augusto2112/llvm-project that referenced this issue Feb 27, 2023
…ecursive-subprogram

[cherry-pick][debug-info][codegen] Prevent creation of self-referential SP node
@arsenm
Copy link
Contributor

arsenm commented Aug 16, 2023

Linked patch was committed

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 16, 2023

@llvm/issue-subscribers-clang-codegen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants