[LLVMbugs] [Bug 5984] New: Bogus 'use of undeclared identifier' error causing compilation to fail
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sun Jan 10 01:48:02 PST 2010
http://llvm.org/bugs/show_bug.cgi?id=5984
Summary: Bogus 'use of undeclared identifier' error causing
compilation to fail
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: parser
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: richard at tiptree.demon.co.uk
CC: llvmbugs at cs.uiuc.edu
Created an attachment (id=4019)
--> (http://llvm.org/bugs/attachment.cgi?id=4019)
sys/wait.h header from centos-5.4 with glibc-2.11.1 built from source
When compiling the gnustep-base library (objective-c ) I encountered
compilation failure related to sys/wait.h
It appears that something about the wait definitions causes clang to lose track
of the visibility of the objective-c class instance variable being used.
I simplified this to a tiny test program:
#include <sys/wait.h>
#include <objc/Object.h>
@interface MyClass : Object
{
int myStatus;
}
- (int) test;
@end
@implementation MyClass
- (int) test
{
if (WIFEXITED(myStatus))
return 1;
return 0;
}
@end
int
main()
{
}
When I compile this test using clang (and a -I option to tell it where my
objective-c headers are) I get the following:
clang a.m -I /usr/GNUstep/Local/Library/Headers -lobjc
a.m:14:7: error: use of undeclared identifier 'myStatus'
if (WIFEXITED(myStatus))
^
In file included from a.m:1:
/usr/include/sys/wait.h:85:28: note: instantiated from:
# define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status))
^
In file included from a.m:1:
In file included from /usr/include/sys/wait.h:80:
/usr/include/bits/waitstatus.h:38:30: note: instantiated from:
#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
^
a.m:14:7: note: instantiated from:
if (WIFEXITED(myStatus))
^
In file included from a.m:1:
/usr/include/sys/wait.h:85:28: note: instantiated from:
# define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status))
^
a.m:14:7: note: instantiated from:
if (WIFEXITED(myStatus))
^
In file included from a.m:1:
/usr/include/sys/wait.h:85:41: note: instantiated from:
# define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status))
^
a.m:14:7: note: instantiated from:
if (WIFEXITED(myStatus))
^
a.m:14:17: note: instantiated from:
if (WIFEXITED(myStatus))
^
a.m:14:7: error: member reference base type 'void' is not a structure or union
if (WIFEXITED(myStatus))
^~~~~~~~~~~~~~~~~~~
In file included from a.m:1:
/usr/include/sys/wait.h:85:28: note: instantiated from:
# define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status))
^
In file included from a.m:1:
In file included from /usr/include/sys/wait.h:80:
/usr/include/bits/waitstatus.h:38:30: note: instantiated from:
#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
^
a.m:14:7: note: instantiated from:
if (WIFEXITED(myStatus))
^
In file included from a.m:1:
/usr/include/sys/wait.h:85:28: note: instantiated from:
# define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status))
^
a.m:14:7: note: instantiated from:
if (WIFEXITED(myStatus))
^
In file included from a.m:1:
/usr/include/sys/wait.h:85:41: note: instantiated from:
# define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status))
^
/usr/include/sys/wait.h:48:42: note: instantiated from:
{ .__in = (status) }).__i))
~~~~~~~~~~~~~~~~~~~~~ ^
2 diagnostics generated.
As you can see, the compiler appears to have forgotten about the myStatus
instance variable.
An easy workaround is to copy myStatus to a local integer variable, and use
that copy as the argument to WIFEXITED, so this bug is annoying, but not
critical.
I attach a copy of the sys/wait.h file involved.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list