llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.68k stars 11.86k forks source link

Problem when declaring enum constant with old style function parameter declaration in C11. #39276

Open ebdd6ebc-1612-4e9b-aee1-f7d2b6361d5f opened 5 years ago

ebdd6ebc-1612-4e9b-aee1-f7d2b6361d5f commented 5 years ago
Bugzilla Link 39929
Version trunk
OS All
CC @zygoloid

Extended Description

Consider the following C11 program (prog.c):

void f(e) enum { x } e; { x; }

int main() { }

I was compiling this program with:

clang prog.c -std=c11 -pedantic-errors "-w"

The expected behaviour is that it should work, but I get the following error:

error: use of undeclared identifier 'x'

Note that it works fine when using the new style of declaring function parameters.

Also note that it works fine in gcc.

Link to online compiler:

https://wandbox.org/permlink/CGczhD2xFRJkUzTs

llvmbot commented 1 year ago

@llvm/issue-subscribers-c

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-frontend

AaronBallman commented 1 year ago

Issue reproduces as of Clang 16.0.0: https://gcc.godbolt.org/z/f6jEGeaaz