llvm / llvm-project

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

Undefined internal function warning with generic selection expressions #98504

Open AaronBallman opened 1 month ago

AaronBallman commented 1 month ago

C23 6.9p3 says:

There shall be no more than one external definition for each identifier declared with internal linkage in a translation unit. Moreover, if an identifier declared with internal linkage is used in an expression there shall be exactly one external definition for the identifier in the translation unit, unless it is: — part of the operand of a sizeof operator whose result is an integer constant; — part of the operand of an alignof operator whose result is an integer constant; — part of the controlling expression of a generic selection; — part of the expression in a generic association that is not the result expression of its generic selection; — or, part of the operand of any typeof operator whose result is not a variably modified type.

Clang incorrectly handles the generic association bullet. Consider:

static void *a(void);
_Generic(0, int : 0, default: a);

Clang diagnoses the mention of a despite that being in an association that is not the result expression. This rejects valid code under -pedantic-errors.

llvmbot commented 1 month ago

@llvm/issue-subscribers-clang-frontend

Author: Aaron Ballman (AaronBallman)

C23 6.9p3 says: There shall be no more than one external definition for each identifier declared with internal linkage in a translation unit. Moreover, if an identifier declared with internal linkage is used in an expression there shall be exactly one external definition for the identifier in the translation unit, unless it is: — part of the operand of a sizeof operator whose result is an integer constant; — part of the operand of an alignof operator whose result is an integer constant; — part of the controlling expression of a generic selection; — part of the expression in a generic association that is not the result expression of its generic selection; — or, part of the operand of any typeof operator whose result is not a variably modified type. Clang incorrectly handles the generic association bullet. Consider: ``` static void *a(void); _Generic(0, int : 0, default: a); ``` Clang diagnoses the mention of `a` despite that being in an association that is not the result expression. This rejects valid code under `-pedantic-errors`.
llvmbot commented 1 month ago

@llvm/issue-subscribers-c11

Author: Aaron Ballman (AaronBallman)

C23 6.9p3 says: There shall be no more than one external definition for each identifier declared with internal linkage in a translation unit. Moreover, if an identifier declared with internal linkage is used in an expression there shall be exactly one external definition for the identifier in the translation unit, unless it is: — part of the operand of a sizeof operator whose result is an integer constant; — part of the operand of an alignof operator whose result is an integer constant; — part of the controlling expression of a generic selection; — part of the expression in a generic association that is not the result expression of its generic selection; — or, part of the operand of any typeof operator whose result is not a variably modified type. Clang incorrectly handles the generic association bullet. Consider: ``` static void *a(void); _Generic(0, int : 0, default: a); ``` Clang diagnoses the mention of `a` despite that being in an association that is not the result expression. This rejects valid code under `-pedantic-errors`.