ldc/tests/codegen/attributes.d
Martin Kinkelin 967947eb84 Emulate @weak functions on Windows and don't emit COMDATs for ELF anymore
Emulation for @weak global variables is still left out but should be
analogous.

The test adaptations are mostly a revert of 3893840f. The testcase has
shown that @weak hasn't worked properly for ELF (linker apparently
prefers the version in the 1st object file, independent of whether it's
weak or not), because the functions are emitted in COMDATs.
clang emits COMDATs for templates and inline functions only, not for
regular functions.
2020-05-16 20:42:57 +02:00

32 lines
1 KiB
D

// Tests LDC-specific attributes
// RUN: %ldc -O -c -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
import ldc.attributes;
//---- @(section) -----------------------------------------------------
// CHECK-DAG: @{{.*}}mySectionedGlobali{{.*}} section ".mySection"
@(section(".mySection")) int mySectionedGlobal;
// CHECK-DAG: define{{.*}} void @{{.*}}sectionedfoo{{.*}} section "funcSection"
@(section("funcSection")) void sectionedfoo() {}
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//---- @(weak) --------------------------------------------------------
// CHECK-DAG: @{{.*}}myWeakGlobali{{\"?}} = weak
@(ldc.attributes.weak) int myWeakGlobal;
// CHECK-DAG: define{{.*}} {{(weak .*void @.*_D)|(void @.*_D6__weak)}}10attributes8weakFuncFZv
@weak void weakFunc() {}
//---------------------------------------------------------------------
// CHECK-LABEL: define{{.*}} i32 @_Dmain
void main() {
sectionedfoo();
}