llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Incorrect warning "unused function ..."

Open weiguozhi opened this issue 14 years ago • 2 comments

Bugzilla Link 14234
Resolution INVALID
Resolved on Nov 01, 2012 04:18
Version trunk
OS All
CC @DougGregor,@zygoloid

Extended Description

Compile following c++ source code with command line

$clang++ -fsyntax-only -Wall t3.cpp

namespace {

int foo(){ return 1; }

}

Clang gives unexpected warning

t3.cpp:3:5: warning: unused function 'foo' [-Wunused-function] int foo(){ ^

weiguozhi avatar Nov 01 '12 08:11 weiguozhi

I think this was a misunderstanding of unnamed namespaces. Works as intended.

llvmbot avatar Nov 01 '12 11:11 llvmbot

Why is that unexpected? 'foo' is not used in this translation unit, and cannot be accessed from outside it.