LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 14250 - incorrect -Wunneeded-internal-declaration warning with weak symbols
Summary: incorrect -Wunneeded-internal-declaration warning with weak symbols
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: LLVM Codegen (show other bugs)
Version: 4.0
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-03 10:47 PDT by Paolo Bonzini
Modified: 2017-07-11 12:03 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paolo Bonzini 2012-11-03 10:47:51 PDT
This file:

static int g()
{
	return 42;
}
typeof(g) f __attribute__((__weak__, __alias__("g")));

compiled with -Wall gives:

g2.c:3:12: warning: function 'g' is not needed and will not be emitted
      [-Wunneeded-internal-declaration]

even though the function is emitted:

	.file	"g2.c"
	.text
	.align	16, 0x90
	.type	g,@function
g:                                      # @g
	.cfi_startproc
# BB#0:
	movl	$42, %eax
	ret
.Ltmp0:
	.size	g, .Ltmp0-g
	.cfi_endproc


	.weak	f
f = g
	.section	".note.GNU-stack","",@progbits
Comment 1 Eli Friedman 2012-11-06 18:25:26 PST
This is a consequence of the fact that semantic analysis doesn't try to associate __alias__ with the targeted decl.