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

clang incorrectly rejects references to earlier parameters in a prototype #2418

Closed
efriedma-quic opened this issue Feb 16, 2008 · 5 comments
Closed
Labels
bugzilla clang:frontend

Comments

@efriedma-quic
Copy link
Collaborator

@efriedma-quic efriedma-quic commented Feb 16, 2008

Bugzilla Link 2046
Resolution FIXED
Resolved on Mar 12, 2010 00:56
Version unspecified
OS Linux

Extended Description

Testcase:
int aa(int b, int x[sizeof b]) {}

This is perfectly legal C90 and C99 code, but clang claims the b is undeclared.

@lattner
Copy link
Collaborator

@lattner lattner commented Feb 16, 2008

Simpler testcase: void foo(int i, int A[i]) {}

@lattner
Copy link
Collaborator

@lattner lattner commented Apr 5, 2008

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

@lattner
Copy link
Collaborator

@lattner lattner commented Apr 6, 2008

This is actually incredibly ugly. Currently clang doesn't make param decls for arguments when parsing an argument list: it only creates them when parsing a function body. Instead, it just evaluates the type of the argument. This appears to be sufficient except for cases like this.

This issue brings up "interesting" (aka PITA) lifetime issues as well. For example, in this case:

int (*v)(int b, int x[sizeof b]) {}

we now need to keep the decl for 'b' around, because it is referenced by the type of 'x'. This implies that we need to create and keep around decls for all arguments in prototypes unless we are extremely clever. This will punish normal cases like:

void exit(int status)

by making us keep a decl for status around.

@lattner
Copy link
Collaborator

@lattner lattner commented Apr 8, 2008

@lattner
Copy link
Collaborator

@lattner lattner commented Nov 26, 2021

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

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla clang:frontend
Projects
None yet
Development

No branches or pull requests

2 participants