llvm-project/clang/test/Sema/extern-redecl.c
Aaron Ballman 0f1c1be196 [clang] Remove rdar links; NFC
We have a new policy in place making links to private resources
something we try to avoid in source and test files. Normally, we'd
organically switch to the new policy rather than make a sweeping change
across a project. However, Clang is in a somewhat special circumstance
currently: recently, I've had several new contributors run into rdar
links around test code which their patch was changing the behavior of.
This turns out to be a surprisingly bad experience, especially for
newer folks, for a handful of reasons: not understanding what the link
is and feeling intimidated by it, wondering whether their changes are
actually breaking something important to a downstream in some way,
having to hunt down strangers not involved with the patch to impose on
them for help, accidental pressure from asking for potentially private
IP to be made public, etc. Because folks run into these links entirely
by chance (through fixing bugs or working on new features), there's not
really a set of problematic links to focus on -- all of the links have
basically the same potential for causing these problems. As a result,
this is an omnibus patch to remove all such links.

This was not a mechanical change; it was done by manually searching for
rdar, radar, radr, and other variants to find all the various
problematic links. From there, I tried to retain or reword the
surrounding comments so that we would lose as little context as
possible. However, because most links were just a plain link with no
supporting context, the majority of the changes are simple removals.

Differential Review: https://reviews.llvm.org/D158071
2023-08-28 12:13:42 -04:00

87 lines
2.8 KiB
C

// RUN: %clang_cc1 -fsyntax-only -verify -Wno-strict-prototypes %s
static int a16[]; // expected-warning {{tentative array definition assumed to have one element}}
void f16(void) {
extern int a16[];
}
// PR10013: Scope of extern declarations extend past enclosing block
extern int PR10013_x;
int PR10013(void) {
int *PR10013_x = 0;
{
extern int PR10013_x;
extern int PR10013_x;
}
return PR10013_x; // expected-error{{incompatible pointer to integer conversion}}
}
static int test1_a[]; // expected-warning {{tentative array definition assumed to have one element}}
extern int test1_a[];
void test2declarer(void) { extern int test2_array[100]; }
extern int test2_array[];
int test2v = sizeof(test2_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int[]'}}
void test3declarer(void) {
{ extern int test3_array[100]; }
extern int test3_array[];
int x = sizeof(test3_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int[]'}}
}
void test4(void) {
extern int test4_array[];
{
extern int test4_array[100];
int x = sizeof(test4_array); // fine
}
int x = sizeof(test4_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int[]'}}
}
// Test that invalid local extern declarations of library
// builtins behave reasonably.
extern void abort(void); // expected-note 2 {{previous declaration is here}}
extern float *calloc(void); // expected-warning {{incompatible redeclaration of library function}} expected-note {{is a builtin}} expected-note 2 {{previous declaration is here}}
void test5a(void) {
int abort(void); // expected-error {{conflicting types}}
float *malloc(void); // expected-warning {{incompatible redeclaration of library function}} expected-note 2 {{is a builtin}}
int *calloc(void); // expected-error {{conflicting types}}
}
void test5b(void) {
int abort(void); // expected-error {{conflicting types}}
float *malloc(void); // expected-warning {{incompatible redeclaration of library function}}
int *calloc(void); // expected-error {{conflicting types}}
}
void test5c(void) {
void (*_abort)(void) = &abort;
void *(*_malloc)() = &malloc;
float *(*_calloc)() = &calloc;
}
void test6(void) {
extern int test6_array1[100];
extern int test6_array2[100];
void test6_fn1(int*);
void test6_fn2(int*);
{
// Types are only merged from visible declarations.
char test6_array2;
char test6_fn2;
{
extern int test6_array1[];
extern int test6_array2[];
(void)sizeof(test6_array1); // ok
(void)sizeof(test6_array2); // expected-error {{incomplete type}}
void test6_fn1();
void test6_fn2();
test6_fn1(1.2); // expected-error {{passing 'double' to parameter of incompatible type 'int *'}}
// FIXME: This is valid, but we should warn on it.
test6_fn2(1.2);
}
}
}