<commit_before><commit_msg>Test constant-folding of weak identifiers<commit_after>// RUN: %check --only -e %s -Wno-incompatible-pointer-types '-DERROR(...)=__VA_ARGS__'
// RUN: %ucc -fsyntax-only %s '-DERROR(...)=' -Wno-incompatible-pointer-types -Wno-arith-funcptr

enum { false };

__attribute((weak)) void w();
void f();

ERROR(int shortcircuit_weak_1 = w && 1;) // CHECK: error: global scalar initialiser not constant
ERROR(int shortcircuit_weak_2 = w && 0;) // CHECK: error: global scalar initialiser not constant
ERROR(int shortcircuit_weak_3 = 1 && w;) // CHECK: error: global scalar initialiser not constant
_Static_assert((0 && w) == false, "");

ERROR(int shortcircuit_weak_5 = w || 1;) // CHECK: error: global scalar initialiser not constant
ERROR(int shortcircuit_weak_6 = w || 0;) // CHECK: error: global scalar initialiser not constant
_Static_assert(1 || w, "");
ERROR(int shortcircuit_weak_8 = 0 || w;) // CHECK: error: global scalar initialiser not constant

_Static_assert(f && 1, "");
_Static_assert((f && 0) == false, "");
_Static_assert(1 && f, "");
_Static_assert((0 && f) == false, "");

_Static_assert(f || 1, "");
_Static_assert(f || 0, "");
_Static_assert(1 || f, "");
_Static_assert(0 || f, "");

// ---------

void (*arith_fptr_1)() = f + 2; // CHECK: warning: arithmetic on function pointer 'void (*)()'
void (*arith_fptr_2)() = w + 2; // CHECK: warning: arithmetic on function pointer 'void (*)()'

_Static_assert(!&f == false, "");
ERROR(int arith_2 = !&w;) // CHECK: error: global scalar initialiser not constant
_Static_assert(!f == false, "");
ERROR(int arith_4 = !w;) // CHECK: error: global scalar initialiser not constant
_Static_assert((0 == f) == false, "");
ERROR(int arith_6 = 0 == w;) // CHECK: error: global scalar initialiser not constant
_Static_assert(0 != f, "");
ERROR(int arith_8 = 0 != w;) // CHECK: error: global scalar initialiser not constant
_Static_assert((f == w) == false, "");
_Static_assert(f != w, "");
_Static_assert((f - f) == false, "");
_Static_assert((w - w) == false, "");
ERROR(int arith_13 = f - w;) // CHECK: error: global scalar initialiser not constant
ERROR(int arith_14 = w - f;) // CHECK: error: global scalar initialiser not constant
{'fraction_non_alphanumeric': 0.182518115942029, 'fraction_numerical': 0.017210144927536232, 'mean_word_length': 4.635204081632653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '232535', 'n_tokens_mistral': 747, 'n_tokens_neox': 738, 'n_words': 221}