2010-07-16 05:05:01 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
|
|
|
|
|
|
struct X {
|
|
|
|
template<typename T, typename U>
|
|
|
|
static void f(int, int);
|
|
|
|
};
|
|
|
|
|
|
|
|
void f() {
|
|
|
|
void (*ptr)(int, int) = &X::f<int, int>;
|
2012-08-24 04:19:14 +08:00
|
|
|
|
|
|
|
unknown *p = 0; // expected-error {{unknown type name 'unknown'}}
|
|
|
|
unknown * p + 0; // expected-error {{undeclared identifier 'unknown'}}
|
2010-07-16 05:05:01 +08:00
|
|
|
}
|
2018-02-03 06:24:54 +08:00
|
|
|
|
|
|
|
auto (*p)() -> int(nullptr);
|
|
|
|
auto (*q)() -> int(*)(unknown); // expected-error {{unknown type name 'unknown'}}
|
|
|
|
auto (*r)() -> int(*)(unknown + 1); // expected-error {{undeclared identifier 'unknown'}}
|
2019-05-07 15:36:07 +08:00
|
|
|
|
|
|
|
int f(unknown const x); // expected-error {{unknown type name 'unknown'}}
|
2019-11-28 09:54:26 +08:00
|
|
|
|
|
|
|
// Disambiguating an array declarator from an array subscripting.
|
|
|
|
void arr() {
|
|
|
|
int x[] = {1}; // expected-note 2{{previous}}
|
|
|
|
|
|
|
|
// This is array indexing not an array declarator because a comma expression
|
|
|
|
// is not syntactically a constant-expression.
|
2021-06-24 14:46:42 +08:00
|
|
|
int(x[1,1]); // expected-warning {{left operand of comma operator has no effect}} expected-warning {{unused}}
|
2019-11-28 09:54:26 +08:00
|
|
|
|
|
|
|
// This is array indexing not an array declaration because a braced-init-list
|
|
|
|
// is not syntactically a constant-expression.
|
|
|
|
int(x[{0}]); // expected-error {{array subscript is not an integer}}
|
|
|
|
struct A {
|
|
|
|
struct Q { int n; };
|
|
|
|
int operator[](Q);
|
|
|
|
} a;
|
|
|
|
int(a[{0}]); // expected-warning {{unused}}
|
|
|
|
|
|
|
|
// These are array declarations.
|
2021-06-24 14:46:42 +08:00
|
|
|
int(x[((void)1,1)]); // expected-error {{redefinition}}
|
|
|
|
int(x[true ? 1 : (1,1)]); // expected-error {{redefinition}} // expected-warning {{left operand of comma operator has no effect}}
|
2020-02-24 20:59:26 +08:00
|
|
|
|
|
|
|
int (*_Atomic atomic_ptr_to_int);
|
|
|
|
*atomic_ptr_to_int = 42;
|
2019-11-28 09:54:26 +08:00
|
|
|
}
|