llvm-project/clang/test/Sema/err-decl-block-extern-no-init.c
Jun Zhang 1d51bb824f
[Clang] Reword diagnostic for scope identifier with linkage
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
2022-09-12 22:40:54 +08:00

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}}
}