Files
clang-p2996/clang/test/Parser/colon-colon-parentheses.cpp
Aaron Ballman 2cb2cd242c Change the behavior of implicit int diagnostics
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.
2022-05-04 08:35:47 -04:00

37 lines
1.2 KiB
C++

// RUN: %clang_cc1 %s -verify -fno-spell-checking
struct S { static int a,b,c;};
int S::(a); // expected-error{{expected unqualified-id}}
int S::(b; // expected-error{{expected unqualified-id}}
);
int S::c;
int S::(*d); // expected-error{{expected unqualified-id}}
int S::(*e; // expected-error{{expected unqualified-id}}
);
int S::*f;
int g = S::(a); // expected-error {{expected unqualified-id}} expected-error {{use of undeclared identifier 'a'}}
int h = S::(b; // expected-error {{expected unqualified-id}} expected-error {{use of undeclared identifier 'b'}}
);
int i = S::c;
void foo() {
int a;
a = ::(g); // expected-error{{expected unqualified-id}}
a = ::(h; // expected-error{{expected unqualified-id}}
a = ::i;
}
// The following tests used to be crash bugs.
// PR21815
// expected-error@+2{{a type specifier is required for all declarations}}
// expected-error@+1{{expected unqualified-id}}
a (::( ));
::((c )); // expected-error{{expected unqualified-id}}
// PR26623
int f1(::(B) p); // expected-error {{expected unqualified-id}} expected-error {{use of undeclared identifier 'B'}}
int f2(::S::(C) p); // expected-error {{expected unqualified-id}} expected-error {{use of undeclared identifier 'C'}}