mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 04:06:06 +00:00

C89 allowed a type specifier to be elided with the resulting type being int, aka implicit int behavior. This feature was subsequently removed in C99 without a deprecation period, so implementations continued to support the feature. Now, as with implicit function declarations, is a good time to reevaluate the need for this support. This patch allows -Wimplicit-int to issue warnings in C89 mode (off by default), defaults the warning to an error in C99 through C17, and disables support for the feature entirely in C2x. It also removes a warning about missing declaration specifiers that really was just an implicit int warning in disguise and other minor related cleanups.
90 lines
1.7 KiB
C
90 lines
1.7 KiB
C
// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
|
|
|
|
void I( void (^)(void));
|
|
void (^noop)(void);
|
|
|
|
void nothing(void);
|
|
int printf(const char*, ...);
|
|
|
|
typedef void (^T) (void);
|
|
|
|
void takeblock(T);
|
|
int takeintint(int (^C)(int)) { return C(4); }
|
|
|
|
T somefunction(void) {
|
|
if (^{ })
|
|
nothing();
|
|
|
|
noop = ^{};
|
|
|
|
noop = ^{printf("\nClosure\n"); };
|
|
|
|
I(^{ });
|
|
|
|
return ^{printf("\nClosure\n"); };
|
|
}
|
|
void test2(void) {
|
|
int x = 4;
|
|
|
|
takeblock(^{ printf("%d\n", x); });
|
|
|
|
while (1) {
|
|
takeblock(^{
|
|
break; // expected-error {{'break' statement not in loop or switch statement}}
|
|
continue; // expected-error {{'continue' statement not in loop statement}}
|
|
while(1) break; // ok
|
|
goto foo; // expected-error {{use of undeclared label 'foo'}}
|
|
a: goto a; // ok
|
|
});
|
|
break;
|
|
}
|
|
|
|
foo:
|
|
takeblock(^{ x = 4; }); // expected-error {{variable is not assignable (missing __block type specifier)}}
|
|
__block y = 7; // expected-error {{type specifier missing, defaults to 'int'}}
|
|
takeblock(^{ y = 8; });
|
|
}
|
|
|
|
|
|
void (^test3(void))(void) {
|
|
return ^{};
|
|
}
|
|
|
|
void test4(void) {
|
|
void (^noop)(void) = ^{};
|
|
void (*noop2)(void) = 0;
|
|
}
|
|
|
|
void myfunc(int (^block)(int)) {}
|
|
|
|
void myfunc3(const int *x);
|
|
|
|
void test5(void) {
|
|
int a;
|
|
|
|
myfunc(^(int abcd) {
|
|
myfunc3(&a);
|
|
return 1;
|
|
});
|
|
}
|
|
|
|
void *X;
|
|
|
|
void test_arguments(void) {
|
|
int y;
|
|
int (^c)(char);
|
|
(1 ? c : 0)('x');
|
|
(1 ? 0 : c)('x');
|
|
|
|
(1 ? c : c)('x');
|
|
}
|
|
|
|
static int global_x = 10;
|
|
void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
|
|
|
|
typedef void (^void_block_t)(void);
|
|
|
|
static const void_block_t myBlock = ^{ };
|
|
|
|
static const void_block_t myBlock2 = ^ void(void) { };
|