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

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
98 lines
4.0 KiB
C
98 lines
4.0 KiB
C
// RUN: %clang_cc1 %s -ffreestanding -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic -fpascal-strings -std=c99
|
|
|
|
#include <stdint.h>
|
|
#include <limits.h>
|
|
|
|
int a(void) {int p; *(1 ? &p : (void*)(0 && (a(),1))) = 10;} /* expected-error {{incomplete type 'void' is not assignable}}
|
|
expected-warning {{ISO C does not allow indirection on operand of type 'void *'}} */
|
|
|
|
// ?: with __builtin_constant_p as the operand is an i-c-e.
|
|
int expr;
|
|
char w[__builtin_constant_p(expr) ? expr : 1];
|
|
|
|
char v[sizeof(__builtin_constant_p(0)) == sizeof(int) ? 1 : -1];
|
|
|
|
int implicitConversion = 1.0;
|
|
char floatArith[(int)(1.0+2.0)]; // expected-warning {{variable length array folded to constant array as an extension}}
|
|
|
|
// __builtin_constant_p as the condition of ?: allows arbitrary foldable
|
|
// constants to be transmogrified into i-c-e's.
|
|
char b[__builtin_constant_p((int)(1.0+2.0)) ? (int)(1.0+2.0) : -1];
|
|
|
|
struct c {
|
|
int a : (
|
|
__builtin_constant_p((int)(1.0+2.0)) ? (int)(1.0+
|
|
expr // expected-error {{expression is not an integer constant expression}}
|
|
) : -1);
|
|
};
|
|
|
|
// Check that we can evaluate statement-expressions properly when
|
|
// constant-folding inside an ICE.
|
|
void PR49239(void) {
|
|
goto check_not_vla;
|
|
char not_vla[__builtin_constant_p(1) ? ({ 42; }) : -1]; // expected-warning {{statement expression}}
|
|
check_not_vla:;
|
|
_Static_assert(sizeof(not_vla) == 42, ""); // expected-warning {{C11 extension}}
|
|
|
|
// It's not clear that this should be valid: __builtin_expect(expr1, expr2)
|
|
// should probably be an ICE if and only if expr1 is an ICE, but we roughly
|
|
// follow GCC in treating it as an ICE if and only if we can evaluate expr1
|
|
// regardless of whether it's an ICE.
|
|
goto check_also_not_vla;
|
|
char also_not_vla[__builtin_expect(({ 76; }), 0)]; // expected-warning {{statement expression}}
|
|
check_also_not_vla:;
|
|
_Static_assert(sizeof(also_not_vla) == 76, ""); // expected-warning {{C11 extension}}
|
|
}
|
|
|
|
|
|
void test1(int n, int* p) { *(n ? p : (void *)(7-7)) = 1; }
|
|
void test2(int n, int* p) { *(n ? p : (void *)0) = 1; }
|
|
|
|
|
|
|
|
char array[1024/(sizeof (long))];
|
|
|
|
int x['\xBb' == (char) 187 ? 1: -1];
|
|
|
|
// PR1992
|
|
void func(int x)
|
|
{
|
|
switch (x) {
|
|
case sizeof("abc"): break;
|
|
case sizeof("loooong"): func(4);
|
|
case sizeof("\ploooong"): func(4);
|
|
}
|
|
}
|
|
|
|
int expr;
|
|
char y[__builtin_constant_p(expr) ? -1 : 1];
|
|
char z[__builtin_constant_p(4) ? 1 : -1];
|
|
|
|
// Comma tests
|
|
int comma1[0?1,2:3]; // expected-warning {{left operand of comma operator has no effect}}
|
|
int comma2[1 || (1, 2)]; // expected-warning {{use of logical '||' with constant operand}} \
|
|
// expected-note {{use '|' for a bitwise operation}} \
|
|
// expected-warning {{left operand of comma operator has no effect}}
|
|
int comma3[(1, 2)]; // expected-warning {{variable length array folded to constant array as an extension}} \
|
|
// expected-warning {{left operand of comma operator has no effect}}
|
|
|
|
// Pointer + __builtin_constant_p
|
|
char pbcp[__builtin_constant_p(4) ? (intptr_t)&expr : 0]; // expected-error {{variable length array declaration not allowed at file scope}}
|
|
|
|
int illegaldiv1a[1 || 1/0];
|
|
int illegaldiv1b[1 && 1/0]; //expected-error{{variable length array declaration not allowed at file scope}}
|
|
|
|
int illegaldiv2[1/0]; // expected-error {{variable length array declaration not allowed at file scope}}
|
|
int illegaldiv3[INT_MIN / -1]; // expected-error {{variable length array declaration not allowed at file scope}}
|
|
// PR9262
|
|
int illegaldiv4[0 / (1 / 0)]; // expected-error {{variable length array declaration not allowed at file scope}}
|
|
|
|
int chooseexpr[__builtin_choose_expr(1, 1, expr)];
|
|
int realop[(__real__ 4) == 4 ? 1 : -1];
|
|
int imagop[(__imag__ 4) == 0 ? 1 : -1];
|
|
|
|
int *PR14729 = 0 ?: 1/0; // expected-error {{not a compile-time constant}} expected-warning 2{{}} expected-error {{incompatible integer to pointer conversion initializing 'int *' with an expression of type 'int'}}
|
|
|
|
int bcp_call_v;
|
|
int bcp_call_a[] = {__builtin_constant_p(bcp_call_v && 0) ? bcp_call_v && 0 : -1};
|