Skip to content

[Prolangs-C] Fix compilation errors with clang 15 and above #223

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

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

androm3da
Copy link
Member

@androm3da androm3da commented Mar 20, 2025

Correcting these function declarations addresses these compilation errors:

llvm-test-suite/MultiSource/Benchmarks/Prolangs-C/loader/sym_tab.c:40:5: error: conflicting types for 'INSERT_IN_SYM_TAB'
   40 | int INSERT_IN_SYM_TAB(char *MODULE,char *LABEL,int LOCATION,enum kind TYPE,
      |     ^
llvm-test-suite/MultiSource/Benchmarks/Prolangs-C/loader/sym_tab.h:52:12: note: previous declaration is here
   52 | extern int INSERT_IN_SYM_TAB();
      |            ^
1 error generated.

llvm-test-suite/MultiSource/Benchmarks/Prolangs-C/assembler/sym_tab.c:40:5: error: conflicting types for 'INSERT_IN_SYM_TAB'
   40 | int INSERT_IN_SYM_TAB(char *MODULE,char *LABEL,int LOCATION,enum kind TYPE,
      |     ^
llvm-test-suite/MultiSource/Benchmarks/Prolangs-C/assembler/sym_tab.h:52:12: note: previous declaration is here
   52 | extern int INSERT_IN_SYM_TAB();
      |            ^
1 error generated.

Since clang 15.x, this has been an error for C programs.

@androm3da
Copy link
Member Author

Am I missing something obvious? It seems odd that I am the first person to stumble across this issue with clang.

@androm3da
Copy link
Member Author

BTW - AFAICT this code came from (Rutgers, then Virginia Tech - https://prolangs.cs.vt.edu/rutgers/https://prolangs.cs.vt.edu/). But it's not maintained there? Is this fork of prolangs-C safe to update in llvm-test-suite?

@androm3da androm3da force-pushed the bcain/prolangs_symtab2 branch from ae245ef to 3494f09 Compare March 21, 2025 00:43
@DavidSpickett
Copy link
Contributor

I think they would have been downloaded from this page - https://prolangs.cs.vt.edu/rutgers/software.php.

This is a collection of existing software, put together some time around 1997 going by the modification dates. Used for some research, so 1. they wouldn't change it because it needs to match that research and 2. all these would have their own upstream locations, assuming they still exist. This one I've no idea how I'd even find it.

We have code changes made to it already: https://github.com/llvm/llvm-test-suite/commits/main/MultiSource/Benchmarks/Prolangs-C/assembler

It's not under a specific license but includes:

/* %%%%%%%%%%%%%%%%%%%% (c) William Landi 1991 %%%%%%%%%%%%%%%%%%%%%%%%%%%% */
/* Permission to use this code is granted as long as the copyright */
/* notice remains in place. */

So for some definition of "use" we are still complying with that.

TLDR: it's fine to modify this here in llvm-test-suite, or at least, as fine as it was for the previous changes :)

Also surprised this hasn't come up before.

Would be good to include in the commit message why this error happens and what version of clang started doing it.

@DavidSpickett
Copy link
Contributor

I think this is it:
https://releases.llvm.org/15.0.0/tools/clang/docs/ReleaseNotes.html#improvements-to-clang-s-diagnostics

Clang now appropriately issues an error in C when a definition of a function without a prototype and with no arguments is an invalid redeclaration of a function with a prototype. e.g., void f(int); void f() {} is now properly diagnosed.

https://godbolt.org/z/7q8zbPTcq

15 is the first one to error here.

Correcting these function declarations addresses these compilation
errors:

```
llvm-test-suite/MultiSource/Benchmarks/Prolangs-C/loader/sym_tab.c:40:5: error: conflicting types for 'INSERT_IN_SYM_TAB'
   40 | int INSERT_IN_SYM_TAB(char *MODULE,char *LABEL,int LOCATION,enum kind TYPE,
      |     ^
llvm-test-suite/MultiSource/Benchmarks/Prolangs-C/loader/sym_tab.h:52:12: note: previous declaration is here
   52 | extern int INSERT_IN_SYM_TAB();
      |            ^
1 error generated.

llvm-test-suite/MultiSource/Benchmarks/Prolangs-C/assembler/sym_tab.c:40:5: error: conflicting types for 'INSERT_IN_SYM_TAB'
   40 | int INSERT_IN_SYM_TAB(char *MODULE,char *LABEL,int LOCATION,enum kind TYPE,
      |     ^
llvm-test-suite/MultiSource/Benchmarks/Prolangs-C/assembler/sym_tab.h:52:12: note: previous declaration is here
   52 | extern int INSERT_IN_SYM_TAB();
      |            ^
1 error generated.
```

Since clang 15.x, this has been an error for C programs.
@androm3da androm3da force-pushed the bcain/prolangs_symtab2 branch from 3494f09 to 023151e Compare March 26, 2025 03:12
@androm3da
Copy link
Member Author

Would be good to include in the commit message why this error happens and what version of clang started doing it.

Thanks - I have updated the commit message.

@DavidSpickett
Copy link
Contributor

DavidSpickett commented Mar 26, 2025

I should have been clearer, the commit message is now fine, but for it to be used for the final commit message when we "Squash and merge" it needs to be placed in the PR's description as well.

(this is due to the GitHub setting llvm has chosen for its repositories)

@DavidSpickett DavidSpickett changed the title [Prolangs-C] Fix compilation errors [Prolangs-C] Fix compilation errors with clang 15 and above Mar 26, 2025
Copy link
Contributor

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I will merge once the PR's description is updated.

@androm3da
Copy link
Member Author

(this is due to the GitHub setting llvm has chosen for its repositories)

Gee: that's not my favorite feature. Oh well.

Thanks for the heads up, commit message(s) are fixed now.

@DavidSpickett DavidSpickett merged commit 0dd1905 into llvm:main Mar 26, 2025
1 check passed
@DavidSpickett
Copy link
Contributor

Even if you are the first to hit this (which I doubt), I can't imagine you would have been the last. So thanks for contributing a fix!

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

Successfully merging this pull request may close these issues.

2 participants