mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 19:47:05 +00:00

If the declaration of an identifier has block scope, and the identifier has external or internal linkage, the declaration shall have no initializer for the identifier. Clang now gives a more suitable diagnosis for this case. Fixes https://github.com/llvm/llvm-project/issues/57478 Signed-off-by: Jun Zhang <jun@junz.org> Differential Revision: https://reviews.llvm.org/D133088
16 lines
382 B
C
16 lines
382 B
C
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
|
|
static int x;
|
|
|
|
void foo(void)
|
|
{
|
|
extern int x = 1; // expected-error {{declaration of block scope identifier with linkage cannot have an initializer}}
|
|
}
|
|
|
|
int y;
|
|
|
|
void bar(void)
|
|
{
|
|
extern int y = 1; // expected-error {{declaration of block scope identifier with linkage cannot have an initializer}}
|
|
|
|
}
|