binutils-gdb/gdb/testsuite/gdb.objc/objcdecode.m
Tom de Vries b3b965fb91 [gdb/testsuite] Fix implicit declaration of printf in gdb.objc/*.m
When running gdb.objc/objcdecode.exp we get:
...
objcdecode.m: In function '-[Decode multipleDef]':
objcdecode.m:14:3: warning: incompatible implicit declaration of built-in \
  function 'printf'
   printf("method multipleDef\n");
   ^~~~~~
objcdecode.m:14:3: note: include '<stdio.h>' or provide a declaration of \
  'printf'
...

Fix this in the three gdb.objc/*.m test-cases by including stdio.h.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-24  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24807
	* gdb.objc/basicclass.m: Include stdio.h.
	* gdb.objc/nondebug.m: Same.
	* gdb.objc/objcdecode.m: Same.
2019-07-24 19:01:59 +02:00

51 lines
778 B
Objective-C

#include <stdio.h>
#include <objc/Object.h>
@interface Decode: Object
{
}
- multipleDef;
- (const char *) myDescription;
@end
@implementation Decode
- multipleDef
{
printf("method multipleDef\n");
return self;
}
- (const char *) myDescription
{
return "Decode gdb test object";
}
@end
int
multipleDef()
{
printf("function multipleDef\n");
return 0;
}
int main (int argc, const char *argv[])
{
id obj;
obj = [Decode new];
multipleDef();
[obj multipleDef];
return 0;
}
const char *_NSPrintForDebugger(id object)
{
/* This is not really what _NSPrintForDebugger should do, but it
is a simple test if gdb can call this function */
if (object && [object respondsTo: @selector(myDescription)])
return [object myDescription];
return NULL;
}