llvm / llvm-project

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

Clang shouldn't mangle the function name #53916

Open TKaipeng opened 2 years ago

TKaipeng commented 2 years ago

Error message

test.cpp:7:35: error: alias must point to a defined variable or function
  void f3() __attribute__ ((weak, alias("f1")));

test.cpp

extern "C" {
  static void * f1() {};
  // static void* f1() {};
  // Clang works well, GCC not
  void f2() __attribute__ ((weak, alias("_ZL2f1v")));
  // GCC works well, Clang not
  void f3() __attribute__ ((weak, alias("f1")));
}

command

clang++ test.cpp -S

version: commit 3af7bbca4a0ef64de64b8bb38d3b167673ec60f0

It's compiled as expected without "static" modifier.

llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-codegen