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.
This commit is contained in:
Aaron Ballman 2022-05-04 08:34:26 -04:00
parent b540ee5402
commit 2cb2cd242c
108 changed files with 360 additions and 319 deletions

View File

@ -1492,8 +1492,8 @@ TEST(DiagsInHeaders, DiagInsideHeader) {
TU.AdditionalFiles = {{"a.h", std::string(Header.code())}};
EXPECT_THAT(*TU.build().getDiagnostics(),
UnorderedElementsAre(AllOf(
Diag(Main.range(), "in included file: C++ requires a "
"type specifier for all declarations"),
Diag(Main.range(), "in included file: a type specifier is "
"required for all declarations"),
withNote(Diag(Header.range(), "error occurred here")))));
}
@ -1506,8 +1506,8 @@ TEST(DiagsInHeaders, DiagInTransitiveInclude) {
{"b.h", "no_type_spec; // error-ok"}};
EXPECT_THAT(*TU.build().getDiagnostics(),
UnorderedElementsAre(
Diag(Main.range(), "in included file: C++ requires a "
"type specifier for all declarations")));
Diag(Main.range(), "in included file: a type specifier is "
"required for all declarations")));
}
TEST(DiagsInHeaders, DiagInMultipleHeaders) {
@ -1520,10 +1520,10 @@ TEST(DiagsInHeaders, DiagInMultipleHeaders) {
{"b.h", "no_type_spec; // error-ok"}};
EXPECT_THAT(*TU.build().getDiagnostics(),
UnorderedElementsAre(
Diag(Main.range("a"), "in included file: C++ requires a type "
"specifier for all declarations"),
Diag(Main.range("b"), "in included file: C++ requires a type "
"specifier for all declarations")));
Diag(Main.range("a"), "in included file: a type specifier is "
"required for all declarations"),
Diag(Main.range("b"), "in included file: a type specifier is "
"required for all declarations")));
}
TEST(DiagsInHeaders, PreferExpansionLocation) {
@ -1537,8 +1537,8 @@ TEST(DiagsInHeaders, PreferExpansionLocation) {
{"b.h", "#ifndef X\n#define X\nno_type_spec; // error-ok\n#endif"}};
EXPECT_THAT(*TU.build().getDiagnostics(),
UnorderedElementsAre(Diag(Main.range(),
"in included file: C++ requires a type "
"specifier for all declarations")));
"in included file: a type specifier is "
"required for all declarations")));
}
TEST(DiagsInHeaders, PreferExpansionLocationMacros) {
@ -1555,8 +1555,8 @@ TEST(DiagsInHeaders, PreferExpansionLocationMacros) {
{"c.h", "#ifndef X\n#define X\nno_type_spec; // error-ok\n#endif"}};
EXPECT_THAT(*TU.build().getDiagnostics(),
UnorderedElementsAre(
Diag(Main.range(), "in included file: C++ requires a "
"type specifier for all declarations")));
Diag(Main.range(), "in included file: a type specifier is "
"required for all declarations")));
}
TEST(DiagsInHeaders, LimitDiagsOutsideMainFile) {
@ -1584,8 +1584,8 @@ TEST(DiagsInHeaders, LimitDiagsOutsideMainFile) {
#endif)cpp"}};
EXPECT_THAT(*TU.build().getDiagnostics(),
UnorderedElementsAre(
Diag(Main.range(), "in included file: C++ requires a "
"type specifier for all declarations")));
Diag(Main.range(), "in included file: a type specifier is "
"required for all declarations")));
}
TEST(DiagsInHeaders, OnlyErrorOrFatal) {
@ -1599,8 +1599,8 @@ TEST(DiagsInHeaders, OnlyErrorOrFatal) {
TU.AdditionalFiles = {{"a.h", std::string(Header.code())}};
EXPECT_THAT(*TU.build().getDiagnostics(),
UnorderedElementsAre(AllOf(
Diag(Main.range(), "in included file: C++ requires "
"a type specifier for all declarations"),
Diag(Main.range(), "in included file: a type specifier is "
"required for all declarations"),
withNote(Diag(Header.range(), "error occurred here")))));
}

View File

@ -3,4 +3,4 @@
struct Foo {
member; // no-crash
};
// CHECK-MESSAGES: :[[@LINE-2]]:3: error: C++ requires a type specifier for all declarations [clang-diagnostic-error]
// CHECK-MESSAGES: :[[@LINE-2]]:3: error: a type specifier is required for all declarations [clang-diagnostic-error]

View File

@ -20,7 +20,7 @@ struct Foo {
// CHECK-MESSAGES: -input.cpp:3:7: error: 'a' declared as an array with a negative size [clang-diagnostic-error]
// CHECK-MESSAGES: -input.cpp:4:7: warning: zero size arrays are an extension [clang-diagnostic-zero-length-array]
// CHECK-MESSAGES: -input.cpp:6:11: error: unknown type name 'x' [clang-diagnostic-error]
// CHECK-MESSAGES: -input.cpp:8:3: error: C++ requires a type specifier for all declarations [clang-diagnostic-error]
// CHECK-MESSAGES: -input.cpp:8:3: error: a type specifier is required for all declarations [clang-diagnostic-error]
// CHECK-YAML: ---
// CHECK-YAML-NEXT: MainSourceFile: '{{.*}}-input.cpp'
@ -88,7 +88,7 @@ struct Foo {
// CHECK-YAML-NEXT: BuildDirectory: '{{.*}}'
// CHECK-YAML-NEXT: - DiagnosticName: clang-diagnostic-error
// CHECK-YAML-NEXT: DiagnosticMessage:
// CHECK-YAML-NEXT: Message: 'C++ requires a type specifier for all declarations'
// CHECK-YAML-NEXT: Message: a type specifier is required for all declarations
// CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
// CHECK-YAML-NEXT: FileOffset: 86
// CHECK-YAML-NEXT: Replacements: []

View File

@ -170,7 +170,17 @@ Improvements to Clang's diagnostics
``-Wno-implicit-function-declaration``. As of C2x, support for implicit
function declarations has been removed, and the warning options will have no
effect.
- The ``-Wimplicit-int`` warning diagnostic now defaults to an error in C99 and
later. Prior to C2x, it may be downgraded to a warning with
``-Wno-error=implicit-int``, or disabled entirely with ``-Wno-implicit-int``.
As of C2x, support for implicit int has been removed, and the warning options
will have no effect. Specifying ``-Wimplicit-int`` in C89 mode will now issue
warnings instead of being a noop.
- No longer issue a "declaration specifiers missing, defaulting to int"
diagnostic in C89 mode because it is not an extension in C89, it was valid
code. The diagnostic has been removed entirely as it did not have a
diagnostic group to disable it, but it can be covered wholly by
``-Wimplicit-int``.
- ``-Wmisexpect`` warns when the branch weights collected during profiling
conflict with those added by ``llvm.expect``.

View File

@ -123,7 +123,9 @@ def err_enum_template : Error<"enumeration cannot be a template">;
def warn_cxx20_compat_consteval : Warning<
"'consteval' specifier is incompatible with C++ standards before C++20">,
InGroup<CXX20Compat>, DefaultIgnore;
def warn_missing_type_specifier : Warning<
"type specifier missing, defaults to 'int'">,
InGroup<ImplicitInt>, DefaultIgnore;
}
let CategoryName = "Nullability Issue" in {

View File

@ -4341,8 +4341,9 @@ def err_void_param_qualified : Error<
"'void' as parameter must not have type qualifiers">;
def err_ident_list_in_fn_declaration : Error<
"a parameter list without types is only allowed in a function definition">;
def ext_param_not_declared : Extension<
"parameter %0 was not declared, defaulting to type 'int'">;
def ext_param_not_declared : ExtWarn<
"parameter %0 was not declared, defaults to 'int'; ISO C99 and later do not "
"support implicit int">, InGroup<ImplicitInt>, DefaultError;
def err_param_default_argument : Error<
"C does not support default arguments">;
def err_param_default_argument_redefinition : Error<
@ -9997,15 +9998,13 @@ def warn_receiver_forward_class : Warning<
"receiver %0 is a forward class and corresponding @interface may not exist">,
InGroup<ForwardClassReceiver>;
def note_method_sent_forward_class : Note<"method %0 is used for the forward class">;
def ext_missing_declspec : ExtWarn<
"declaration specifier missing, defaulting to 'int'">;
def ext_missing_type_specifier : ExtWarn<
"type specifier missing, defaults to 'int'">,
InGroup<ImplicitInt>;
"type specifier missing, defaults to 'int'; ISO C99 and later do not support "
"implicit int">, InGroup<ImplicitInt>, DefaultError;
def err_missing_type_specifier : Error<
"a type specifier is required for all declarations">;
def err_decimal_unsupported : Error<
"GNU decimal type extension not supported">;
def err_missing_type_specifier : Error<
"C++ requires a type specifier for all declarations">;
def err_objc_array_of_interfaces : Error<
"array of interface %0 is invalid (probably should be an array of pointers)">;
def ext_c99_array_usage : Extension<

View File

@ -120,7 +120,6 @@ BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")
LANGOPT(GNUMode , 1, 1, "GNU extensions")
LANGOPT(GNUKeywords , 1, 1, "GNU keywords")
VALUE_LANGOPT(GNUCVersion , 32, 0, "GNU C compatibility version")
BENIGN_LANGOPT(ImplicitInt, 1, 0, "C89 implicit 'int'")
LANGOPT(DisableKNRFunctions, 1, 0, "require function types to have a prototype")
LANGOPT(Digraphs , 1, 0, "digraphs")
BENIGN_LANGOPT(HexFloats , 1, 0, "C99 hexadecimal float constants")

View File

@ -537,6 +537,12 @@ public:
return !requiresStrictPrototypes() && !OpenCL;
}
/// Returns true if implicit int is part of the language requirements.
bool isImplicitIntRequired() const { return !CPlusPlus && !C99; }
/// Returns true if implicit int is supported at all.
bool isImplicitIntAllowed() const { return !CPlusPlus && !C2x; }
/// Check if return address signing is enabled.
bool hasSignReturnAddress() const {
return getSignReturnAddressScope() != SignReturnAddressScopeKind::None;

View File

@ -59,9 +59,8 @@ enum LangFeatures {
Digraphs = (1 << 11),
GNUMode = (1 << 12),
HexFloat = (1 << 13),
ImplicitInt = (1 << 14),
OpenCL = (1 << 15),
HLSL = (1 << 16)
OpenCL = (1 << 14),
HLSL = (1 << 15)
};
/// LangStandard - Information about the properties of a particular language
@ -131,9 +130,6 @@ public:
/// hasHexFloats - Language supports hexadecimal float constants.
bool hasHexFloats() const { return Flags & HexFloat; }
/// hasImplicitInt - Language allows variables to be typed as int implicitly.
bool hasImplicitInt() const { return Flags & ImplicitInt; }
/// isOpenCL - Language is a OpenCL variant.
bool isOpenCL() const { return Flags & OpenCL; }

View File

@ -36,18 +36,17 @@
// C89-ish modes.
LANGSTANDARD(c89, "c89",
C, "ISO C 1990",
ImplicitInt)
C, "ISO C 1990", 0)
LANGSTANDARD_ALIAS(c89, "c90")
LANGSTANDARD_ALIAS(c89, "iso9899:1990")
LANGSTANDARD(c94, "iso9899:199409",
C, "ISO C 1990 with amendment 1",
Digraphs | ImplicitInt)
Digraphs)
LANGSTANDARD(gnu89, "gnu89",
C, "ISO C 1990 with GNU extensions",
LineComment | Digraphs | GNUMode | ImplicitInt)
LineComment | Digraphs | GNUMode)
LANGSTANDARD_ALIAS(gnu89, "gnu90")
// C99-ish modes

View File

@ -113,7 +113,6 @@ void LangOptions::setLangDefaults(LangOptions &Opts, Language Lang,
Opts.GNUMode = Std.isGNUMode();
Opts.GNUCVersion = 0;
Opts.HexFloats = Std.hasHexFloats();
Opts.ImplicitInt = Std.hasImplicitInt();
Opts.WChar = Std.isCPlusPlus();
Opts.Digraphs = Std.hasDigraphs();

View File

@ -2637,8 +2637,8 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
// error, do lookahead to try to do better recovery. This never applies
// within a type specifier. Outside of C++, we allow this even if the
// language doesn't "officially" support implicit int -- we support
// implicit int as an extension in C99 and C11.
if (!isTypeSpecifier(DSC) && !getLangOpts().CPlusPlus &&
// implicit int as an extension in some language modes.
if (!isTypeSpecifier(DSC) && getLangOpts().isImplicitIntAllowed() &&
isValidAfterIdentifierInDeclarator(NextToken())) {
// If this token is valid for implicit int, e.g. "static x = 4", then
// we just avoid eating the identifier, so it will be parsed as the

View File

@ -1195,10 +1195,12 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D,
const DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo();
TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
// If this is C90 and the declspecs were completely missing, fudge in an
// If this is C89 and the declspecs were completely missing, fudge in an
// implicit int. We do this here because this is the only place where
// declaration-specifiers are completely optional in the grammar.
if (getLangOpts().ImplicitInt && D.getDeclSpec().isEmpty()) {
if (getLangOpts().isImplicitIntRequired() && D.getDeclSpec().isEmpty()) {
Diag(D.getIdentifierLoc(), diag::warn_missing_type_specifier)
<< D.getDeclSpec().getSourceRange();
const char *PrevSpec;
unsigned DiagID;
const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();

View File

@ -14317,18 +14317,28 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
SourceLocation LocAfterDecls) {
DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo();
// Verify 6.9.1p6: 'every identifier in the identifier list shall be declared'
// for a K&R function.
// C99 6.9.1p6 "If a declarator includes an identifier list, each declaration
// in the declaration list shall have at least one declarator, those
// declarators shall only declare identifiers from the identifier list, and
// every identifier in the identifier list shall be declared.
//
// C89 3.7.1p5 "If a declarator includes an identifier list, only the
// identifiers it names shall be declared in the declaration list."
//
// This is why we only diagnose in C99 and later. Note, the other conditions
// listed are checked elsewhere.
if (!FTI.hasPrototype) {
for (int i = FTI.NumParams; i != 0; /* decrement in loop */) {
--i;
if (FTI.Params[i].Param == nullptr) {
SmallString<256> Code;
llvm::raw_svector_ostream(Code)
<< " int " << FTI.Params[i].Ident->getName() << ";\n";
Diag(FTI.Params[i].IdentLoc, diag::ext_param_not_declared)
<< FTI.Params[i].Ident
<< FixItHint::CreateInsertion(LocAfterDecls, Code);
if (getLangOpts().C99) {
SmallString<256> Code;
llvm::raw_svector_ostream(Code)
<< " int " << FTI.Params[i].Ident->getName() << ";\n";
Diag(FTI.Params[i].IdentLoc, diag::ext_param_not_declared)
<< FTI.Params[i].Ident
<< FixItHint::CreateInsertion(LocAfterDecls, Code);
}
// Implicitly declare the argument as type 'int' for lack of a better
// type.

View File

@ -1343,35 +1343,34 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
// allowed to be completely missing a declspec. This is handled in the
// parser already though by it pretending to have seen an 'int' in this
// case.
if (S.getLangOpts().ImplicitInt) {
// In C89 mode, we only warn if there is a completely missing declspec
// when one is not allowed.
if (DS.isEmpty()) {
S.Diag(DeclLoc, diag::ext_missing_declspec)
<< DS.getSourceRange()
<< FixItHint::CreateInsertion(DS.getBeginLoc(), "int");
}
if (S.getLangOpts().isImplicitIntRequired()) {
S.Diag(DeclLoc, diag::warn_missing_type_specifier)
<< DS.getSourceRange()
<< FixItHint::CreateInsertion(DS.getBeginLoc(), "int");
} else if (!DS.hasTypeSpecifier()) {
// C99 and C++ require a type specifier. For example, C99 6.7.2p2 says:
// "At least one type specifier shall be given in the declaration
// specifiers in each declaration, and in the specifier-qualifier list in
// each struct declaration and type name."
if (S.getLangOpts().CPlusPlus && !DS.isTypeSpecPipe()) {
if (!S.getLangOpts().isImplicitIntAllowed() && !DS.isTypeSpecPipe()) {
S.Diag(DeclLoc, diag::err_missing_type_specifier)
<< DS.getSourceRange();
<< DS.getSourceRange();
// When this occurs in C++ code, often something is very broken with the
// value being declared, poison it as invalid so we don't get chains of
// When this occurs, often something is very broken with the value
// being declared, poison it as invalid so we don't get chains of
// errors.
declarator.setInvalidType(true);
} else if (S.getLangOpts().getOpenCLCompatibleVersion() >= 200 &&
DS.isTypeSpecPipe()) {
S.Diag(DeclLoc, diag::err_missing_actual_pipe_type)
<< DS.getSourceRange();
<< DS.getSourceRange();
declarator.setInvalidType(true);
} else {
assert(S.getLangOpts().isImplicitIntAllowed() &&
"implicit int is disabled?");
S.Diag(DeclLoc, diag::ext_missing_type_specifier)
<< DS.getSourceRange();
<< DS.getSourceRange()
<< FixItHint::CreateInsertion(DS.getBeginLoc(), "int");
}
}

View File

@ -1,4 +1,4 @@
// RUN: %clang_analyze_cc1 -Wno-implicit-function-declaration -w -verify %s \
// RUN: %clang_analyze_cc1 -Wno-implicit-function-declaration -Wno-implicit-int -w -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions

View File

@ -1,4 +1,4 @@
// RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference -analyzer-output=plist -o %t > /dev/null 2>&1
// RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference -analyzer-output=plist -Wno-error=implicit-int -o %t > /dev/null 2>&1
// RUN: %normalize_plist <%t | diff -ub %S/Inputs/expected-plists/inline-unique-reports.c.plist -
static inline bug(int *p) {

View File

@ -1,4 +1,4 @@
// RUN: %clang_analyze_cc1 -Wno-strict-prototypes -analyzer-store=region -verify %s \
// RUN: %clang_analyze_cc1 -Wno-strict-prototypes -Wno-error=implicit-int -analyzer-store=region -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=alpha.deadcode.UnreachableCode \
// RUN: -analyzer-checker=alpha.core.CastSize \

View File

@ -7,7 +7,7 @@ struct S {
// Note, this is not permitted: conversion-declarator cannot have a trailing return type.
// FIXME: don't issue the second diagnostic for this.
operator auto(*)()->int(); // expected-error{{'auto' not allowed in conversion function type}} expected-error {{C++ requires a type specifier}}
operator auto(*)()->int(); // expected-error{{'auto' not allowed in conversion function type}} expected-error {{a type specifier is required}}
};
typedef auto Fun(int a) -> decltype(a + a);

View File

@ -1094,7 +1094,7 @@ namespace dr298 { // dr298: yes
struct B b; // expected-error {{typedef 'B' cannot be referenced with a struct specifier}}
struct C c; // expected-error {{typedef 'C' cannot be referenced with a struct specifier}}
B::B() {} // expected-error {{requires a type specifier}}
B::B() {} // expected-error {{a type specifier is required}}
B::A() {} // ok
C::~C() {} // expected-error {{destructor cannot be declared using a typedef 'dr298::C' (aka 'const dr298::A') of the class name}}

View File

@ -1054,7 +1054,7 @@ namespace dr484 { // dr484: yes
struct N::DT {}; // expected-error {{conflicts with typedef}}
typedef struct {
S(); // expected-error {{requires a type}}
S(); // expected-error {{a type specifier is required}}
} S;
}

View File

@ -162,7 +162,7 @@ namespace dr522 { // dr522: yes
template<typename T> void b3(Base<T> *);
void test(int n, const int cn, int **p, int *S::*pm) {
int *a[3], *S::*am[3];
int *a[3], *S::*am[3];
const Derived cd = Derived();
Derived d[3];
@ -413,20 +413,20 @@ namespace dr535 { // dr535: yes
// dr538: na
// dr539: yes
const dr539( // expected-error {{requires a type specifier}}
const dr539( // expected-error {{a type specifier is required}}
const a) { // expected-error {{unknown type name 'a'}}
const b; // expected-error {{requires a type specifier}}
const b; // expected-error {{a type specifier is required}}
new const; // expected-error {{expected a type}}
try {} catch (const n) {} // expected-error {{unknown type name 'n'}}
try {} catch (const) {} // expected-error {{expected a type}}
if (const n = 0) {} // expected-error {{requires a type specifier}}
switch (const n = 0) {} // expected-error {{requires a type specifier}}
while (const n = 0) {} // expected-error {{requires a type specifier}}
for (const n = 0; // expected-error {{requires a type specifier}}
const m = 0; ) {} // expected-error {{requires a type specifier}}
sizeof(const); // expected-error {{requires a type specifier}}
if (const n = 0) {} // expected-error {{a type specifier is required}}
switch (const n = 0) {} // expected-error {{a type specifier is required}}
while (const n = 0) {} // expected-error {{a type specifier is required}}
for (const n = 0; // expected-error {{a type specifier is required}}
const m = 0; ) {} // expected-error {{a type specifier is required}}
sizeof(const); // expected-error {{a type specifier is required}}
struct S {
const n; // expected-error {{requires a type specifier}}
const n; // expected-error {{a type specifier is required}}
operator const(); // expected-error {{expected a type}}
};
#if __cplusplus >= 201103L
@ -435,7 +435,7 @@ const dr539( // expected-error {{requires a type specifier}}
// badly confused when recovering here. We should fix this recovery.
{ for (const n // expected-error {{unknown type name 'n'}} expected-note {{}}
: arr) ; {} } // expected-error +{{}}
(void) [](const) {}; // expected-error {{requires a type specifier}}
(void) [](const) {}; // expected-error {{a type specifier is required}}
(void) [](const n) {}; // expected-error {{unknown type name 'n'}}
enum E : const {}; // expected-error {{expected a type}}
using T = const; // expected-error {{expected a type}}
@ -879,7 +879,7 @@ namespace dr585 { // dr585: yes
struct A {
friend T;
#if __cplusplus <= 201402L
// expected-error@-2 {{requires a type specifier}} expected-error@-2 {{can only be classes or functions}}
// expected-error@-2 {{a type specifier is required}} expected-error@-2 {{can only be classes or functions}}
#else
// expected-error@-4 {{use of class template 'T' requires template arguments; argument deduction not allowed in friend declaration}}
// expected-note@-7 {{here}}
@ -891,7 +891,7 @@ namespace dr585 { // dr585: yes
template<template<typename> class T> struct B {
friend T;
#if __cplusplus <= 201402L
// expected-error@-2 {{requires a type specifier}} expected-error@-2 {{can only be classes or functions}}
// expected-error@-2 {{a type specifier is required}} expected-error@-2 {{can only be classes or functions}}
#else
// expected-error@-4 {{use of template template parameter 'T' requires template arguments; argument deduction not allowed in friend declaration}}
// expected-note@-6 {{here}}

View File

@ -36,7 +36,7 @@ EXPORT module MODULE_NAME;
// expected-error@-2 {{redefinition of module 'x'}}
// expected-note-re@module-declaration.cpp:* {{loaded from '{{.*[/\\]}}x.pcm'}}
#elif TEST == 7
// expected-error@-5 {{expected ';'}} expected-error@-5 {{requires a type specifier}}
// expected-error@-5 {{expected ';'}} expected-error@-5 {{a type specifier is required}}
#elif TEST == 9
// expected-warning@-7 {{unknown attribute 'fancy' ignored}}
#elif TEST == 10

View File

@ -10,7 +10,7 @@ template<typename T> struct A { static A a; } A<T>::a; // expected-error {{expec
expected-error {{use of undeclared identifier 'T'}}
template<typename T> struct B { } f(); // expected-error {{expected ';' after struct}} \
expected-error {{requires a type specifier}}
expected-error {{a type specifier is required}}
template<typename T> struct C { } // expected-error {{expected ';' after struct}}

View File

@ -24,9 +24,9 @@ template<typename T> using B = A<T>; // expected-note {{template}}
B() -> B<int>; // expected-error {{cannot specify deduction guide for alias template 'B'}}
// FIXME: expected-error@-1 {{declarator requires an identifier}}
template<typename T> int C;
C() -> int; // expected-error {{requires a type specifier}}
C() -> int; // expected-error {{a type specifier is required}}
template<typename T> void D();
D() -> int; // expected-error {{requires a type specifier}}
D() -> int; // expected-error {{a type specifier is required}}
template<template<typename> typename TT> struct E { // expected-note 2{{template}}
// FIXME: Should only diagnose this once!
TT(int) -> TT<int>; // expected-error 2{{cannot specify deduction guide for template template parameter 'TT'}} expected-error {{requires an identifier}}

View File

@ -4,7 +4,7 @@ template <class T> struct Base {
// expected-note@-1 2{{member type 'Base<int>' found by ambiguous name lookup}}
// expected-note@-2 2{{member type 'Base<char>' found by ambiguous name lookup}}
static void f();
};
};
struct X0 { };
@ -26,7 +26,7 @@ namespace PR6717 {
} // expected-error {{expected ';' after class}}
WebVector(const WebVector<T>& other) { } // expected-error{{undeclared identifier 'T'}} \
expected-error{{requires a type specifier}}
expected-error{{a type specifier is required}}
template <typename C>
WebVector<T>& operator=(const C& other) { } // expected-error{{undeclared identifier 'T'}}

View File

@ -2,7 +2,7 @@
// Test ?: in function calls
extern fp(int, char*);
extern void fp(int, char*);
char *Ext;
void
__bb_exit_func (void)

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
extern int vfork(void);
test() {
void test() {
vfork();
}

View File

@ -1,6 +1,6 @@
// PR 1346
// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
extern bar(void *);
extern void bar(void *);
void f(void *cd) {
bar(((void *)((unsigned long)(cd) ^ -1)));

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
extern p(int *);
extern void p(int *);
int q(void) {
// CHECK: alloca i32, align 16
int x __attribute__ ((aligned (16)));

View File

@ -6,13 +6,13 @@ struct T
unsigned i:8;
unsigned c:24;
};
f(struct T t)
int f(struct T t)
{
struct T s[1];
s[0]=t;
return(char)s->c;
}
main(void)
int main(void)
{
// CHECK: getelementptr inbounds [1 x %struct.T], [1 x %struct.T]* %s, i32 0, i32 0
// CHECK: getelementptr inbounds [1 x %struct.T], [1 x %struct.T]* %s, i32 0, i32 0

View File

@ -12,7 +12,7 @@
Any bad names will make the frontend choke.
*/
main(void)
int main(void)
{
__asm__ __volatile__ (".set noat \n\t addi $7,$at,77":::"at");

View File

@ -9,19 +9,19 @@ typedef float v4sf __attribute__ ((__vector_size__ (16)));
typedef int v4i32 __attribute__ ((__vector_size__ (16)));
// O32: define{{.*}} void @test_v4sf(i32 inreg noundef %a1.coerce0, i32 inreg noundef %a1.coerce1, i32 inreg noundef %a1.coerce2, i32 inreg noundef %a1.coerce3, i32 noundef signext %a2, i32 %0, i32 inreg noundef %a3.coerce0, i32 inreg noundef %a3.coerce1, i32 inreg noundef %a3.coerce2, i32 inreg noundef %a3.coerce3) local_unnamed_addr [[NUW:#[0-9]+]]
// O32: declare i32 @test_v4sf_2(i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 noundef signext, i32, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef)
// O32: declare void @test_v4sf_2(i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 noundef signext, i32, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef)
// N64: define{{.*}} void @test_v4sf(i64 inreg noundef %a1.coerce0, i64 inreg noundef %a1.coerce1, i32 noundef signext %a2, i64 %0, i64 inreg noundef %a3.coerce0, i64 inreg noundef %a3.coerce1) local_unnamed_addr [[NUW:#[0-9]+]]
// N64: declare signext i32 @test_v4sf_2(i64 inreg noundef, i64 inreg noundef, i32 noundef signext, i64, i64 inreg noundef, i64 inreg noundef)
extern test_v4sf_2(v4sf, int, v4sf);
// N64: declare void @test_v4sf_2(i64 inreg noundef, i64 inreg noundef, i32 noundef signext, i64, i64 inreg noundef, i64 inreg noundef)
extern void test_v4sf_2(v4sf, int, v4sf);
void test_v4sf(v4sf a1, int a2, v4sf a3) {
test_v4sf_2(a3, a2, a1);
}
// O32: define{{.*}} void @test_v4i32(i32 inreg noundef %a1.coerce0, i32 inreg noundef %a1.coerce1, i32 inreg noundef %a1.coerce2, i32 inreg noundef %a1.coerce3, i32 noundef signext %a2, i32 %0, i32 inreg noundef %a3.coerce0, i32 inreg noundef %a3.coerce1, i32 inreg noundef %a3.coerce2, i32 inreg noundef %a3.coerce3) local_unnamed_addr [[NUW]]
// O32: declare i32 @test_v4i32_2(i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 noundef signext, i32, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef)
// O32: declare void @test_v4i32_2(i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 noundef signext, i32, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef)
// N64: define{{.*}} void @test_v4i32(i64 inreg noundef %a1.coerce0, i64 inreg noundef %a1.coerce1, i32 noundef signext %a2, i64 %0, i64 inreg noundef %a3.coerce0, i64 inreg noundef %a3.coerce1) local_unnamed_addr [[NUW]]
// N64: declare signext i32 @test_v4i32_2(i64 inreg noundef, i64 inreg noundef, i32 noundef signext, i64, i64 inreg noundef, i64 inreg noundef)
extern test_v4i32_2(v4i32, int, v4i32);
// N64: declare void @test_v4i32_2(i64 inreg noundef, i64 inreg noundef, i32 noundef signext, i64, i64 inreg noundef, i64 inreg noundef)
extern void test_v4i32_2(v4i32, int, v4i32);
void test_v4i32(v4i32 a1, int a2, v4i32 a3) {
test_v4i32_2(a3, a2, a1);
}

View File

@ -13,6 +13,6 @@ kernel void k(){
auto a = get_local_id(1);
#ifndef __OPENCL_CPP_VERSION__
//expected-error@-2{{OpenCL C version 2.0 does not support the 'auto' storage class specifier}}
//expected-warning@-3{{type specifier missing, defaults to 'int'}}
//expected-error@-3{{type specifier missing, defaults to 'int'}}
#endif
}

View File

@ -29,7 +29,7 @@ int array0[5] = { [3] 3 }; // expected-warning {{GNU 'missing ='}}
// CHECK: int x
// CHECK: int y
void f1(x, y) // expected-warning 2{{defaulting to type 'int'}}
void f1(x, y) // expected-error 2{{was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}}
{
}
@ -50,7 +50,7 @@ int test_cond(int y, int fooBar) { // expected-note {{here}}
const typedef typedef int int_t; // expected-warning {{duplicate 'typedef'}}
// <rdar://problem/7159693>
enum Color {
enum Color {
Red // expected-error{{missing ',' between enumerators}}
Green = 17 // expected-error{{missing ',' between enumerators}}
Blue,

View File

@ -228,9 +228,9 @@ void CheckSuffixOnIntegerLiterals(void) {
// Using auto
auto auto_fract = 0r; // expected-error{{invalid suffix 'r' on integer constant}}
// expected-warning@-1{{type specifier missing, defaults to 'int'}}
// expected-error@-1{{type specifier missing, defaults to 'int'}}
auto auto_accum = 0k; // expected-error{{invalid suffix 'k' on integer constant}}
// expected-warning@-1{{type specifier missing, defaults to 'int'}}
// expected-error@-1{{type specifier missing, defaults to 'int'}}
}
// Ok conversions

View File

@ -11,7 +11,7 @@ unsigned long _Accum u_long_accum; // expected-error{{compile with '-ffixed-p
// Aliased fixed point types
short _Accum short_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
_Accum accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
// expected-warning@-1{{type specifier missing, defaults to 'int'}}
// expected-error@-1{{type specifier missing, defaults to 'int'}}
long _Accum long_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
// Cannot use fixed point suffixes

View File

@ -3,7 +3,7 @@
#include <noline.h>
#include <line-directive-in-system.h>
// expected-warning@line-directive.h:* {{type specifier missing, defaults to 'int'}}
// expected-error@line-directive.h:* {{type specifier missing, defaults to 'int'}}
#include "line-directive.h"
// This tests that "#line" directives in system headers preserve system

View File

@ -1,4 +1,4 @@
// RUN: env CINDEXTEST_EDITING=1 LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test -test-load-source-reparse 2 none -remap-file-0=%S/Inputs/reparse-issue.h,%S/Inputs/reparse-issue.h-0 -remap-file-1=%S/Inputs/reparse-issue.h,%S/Inputs/reparse-issue.h-1 -- %s 2>&1 | FileCheck %s
#include "Inputs/reparse-issue.h"
// CHECK: reparse-issue.h:4:1:{1:1-1:1}: error: C++ requires a type specifier for all declarations
// CHECK: reparse-issue.h:4:1:{1:1-1:1}: error: a type specifier is required for all declarations

View File

@ -18,11 +18,10 @@ This test serves two purposes:
The list of warnings below should NEVER grow. It should gradually shrink to 0.
CHECK: Warnings without flags (67):
CHECK: Warnings without flags (66):
CHECK-NEXT: ext_expected_semi_decl_list
CHECK-NEXT: ext_explicit_specialization_storage_class
CHECK-NEXT: ext_missing_declspec
CHECK-NEXT: ext_missing_whitespace_after_macro_name
CHECK-NEXT: ext_new_paren_array_nonconst
CHECK-NEXT: ext_plain_complex
@ -90,4 +89,4 @@ CHECK-NEXT: warn_weak_import
The list of warnings in -Wpedantic should NEVER grow.
CHECK: Number in -Wpedantic (not covered by other -W flags): 27
CHECK: Number in -Wpedantic (not covered by other -W flags): 26

View File

@ -1,6 +1,6 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs/malformed-overload -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Wno-strict-prototypes -verify %s
NSLog(@"%@", path); // expected-error {{expected parameter declarator}} expected-error {{expected ')'}} expected-warning {{type specifier missing}} expected-warning {{incompatible redeclaration}} expected-note {{to match this '('}} expected-note {{'NSLog' is a builtin with type}}
NSLog(@"%@", path); // expected-error {{expected parameter declarator}} expected-error {{expected ')'}} expected-error {{type specifier missing}} expected-warning {{incompatible redeclaration}} expected-note {{to match this '('}} expected-note {{'NSLog' is a builtin with type}}
#import "X.h"
@class NSString;

View File

@ -1,24 +1,24 @@
// REQUIRES: x86-registered-target
// RUN: rm -rf %t
// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
// RUN: -fmodules-ignore-macro=PREFIX -DPREFIX -I %S/Inputs/va_list \
// RUN: -fmodules-ignore-macro=PREFIX -DPREFIX -Wno-error=implicit-int -I %S/Inputs/va_list \
// RUN: -x objective-c-header %s -o %t.pch -emit-pch
// Include the pch, as a basic correctness check.
// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
// RUN: -fmodules-ignore-macro=PREFIX -I %S/Inputs/va_list -include-pch %t.pch \
// RUN: -fmodules-ignore-macro=PREFIX -I %S/Inputs/va_list -Wno-error=implicit-int -include-pch %t.pch \
// RUN: -x objective-c %s -fsyntax-only
// Repeat the previous emit-pch, but not we will have a global module index.
// For some reason, this results in an identifier for __va_list_tag being
// emitted into the pch.
// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
// RUN: -fmodules-ignore-macro=PREFIX -DPREFIX -I %S/Inputs/va_list \
// RUN: -fmodules-ignore-macro=PREFIX -DPREFIX -I %S/Inputs/va_list -Wno-error=implicit-int \
// RUN: -x objective-c-header %s -o %t.pch -emit-pch
// Include the pch, which now has __va_list_tag in it, which needs to be merged.
// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
// RUN: -fmodules-ignore-macro=PREFIX -I %S/Inputs/va_list -include-pch %t.pch \
// RUN: -fmodules-ignore-macro=PREFIX -Wno-error=implicit-int -I %S/Inputs/va_list -include-pch %t.pch \
// RUN: -x objective-c %s -fsyntax-only
// rdar://18039719

View File

@ -14,7 +14,7 @@
#ifndef HEADER
#define HEADER
static inline __attribute__((always_inline)) f(enum { x, y } p) {
static inline __attribute__((always_inline)) int f(enum { x, y } p) {
return y;
}

View File

@ -97,8 +97,8 @@ vector unsigned long int v_uli; // nonaix-warning {{Use of 'long' with '__ve
// These should have warnings.
__vector long double vv_ld; // expected-error {{cannot use 'long double' with '__vector'}}
vector long double v_ld; // expected-error {{cannot use 'long double' with '__vector'}}
vector bool v_b; // expected-warning {{type specifier missing, defaults to 'int'}}
vector __bool v___b; // expected-warning {{type specifier missing, defaults to 'int'}}
vector bool v_b; // expected-error {{type specifier missing, defaults to 'int'}}
vector __bool v___b; // expected-error {{type specifier missing, defaults to 'int'}}
// These should have errors.
#ifndef __VSX__

View File

@ -7,7 +7,7 @@ foo(void) {
}
__attribute__(()) y; // expected-warning {{defaults to 'int'}}
__attribute__(()) y; // expected-error {{type specifier missing, defaults to 'int'}}
// PR2796
int (__attribute__(()) *z)(long y);
@ -19,8 +19,8 @@ int f2(y, __attribute__(()) x); // expected-error {{expected identifier}}
// This is parsed as a normal argument list (with two args that are implicit
// int) because the __attribute__ is a declspec.
void f3(__attribute__(()) x, // expected-warning {{defaults to 'int'}}
y); // expected-warning {{defaults to 'int'}}
void f3(__attribute__(()) x, // expected-error {{type specifier missing, defaults to 'int'}}
y); // expected-error {{type specifier missing, defaults to 'int'}}
void f4(__attribute__(())); // expected-error {{expected parameter declarator}}
@ -30,14 +30,14 @@ int baz(int (__attribute__(()) *x)(long y));
void g1(void (*f1)(__attribute__(()) int x));
void g2(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
void g3(void (*f3)(__attribute__(()) x, int y)); // expected-warning {{defaults to 'int'}}
void g3(void (*f3)(__attribute__(()) x, int y)); // expected-error {{type specifier missing, defaults to 'int'}}
void g4(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}
void (*h1)(void (*f1)(__attribute__(()) int x));
void (*h2)(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
void (*h3)(void (*f3)(__attribute__(()) x)); // expected-warning {{defaults to 'int'}}
void (*h3)(void (*f3)(__attribute__(()) x)); // expected-error {{type specifier missing, defaults to 'int'}}
void (*h4)(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}

View File

@ -17,7 +17,7 @@ template <typename T> class B : T // not ',' or '{'
// expected-error@+8 {{expected ';' after top level declarator}}
#endif
#if __cplusplus <= 201402L
// expected-error@+5 {{C++ requires a type specifier for all declarations}}
// expected-error@+5 {{a type specifier is required for all declarations}}
#else
// expected-error@+3 {{expected unqualified-id}}
#endif

View File

@ -60,7 +60,8 @@ void f4(void) [[]];
void f5(int i [[]], [[]] int j, int [[]] k);
void f6(a, b) [[]] int a; int b; { // notc2x-error {{an attribute list cannot appear here}} \
c2x-warning 2 {{type specifier missing, defaults to 'int'}} \
c2x-error {{unknown type name 'a'}} \
c2x-error {{unknown type name 'b'}} \
c2x-error {{expected ';' after top level declarator}} \
c2x-error {{expected identifier or '('}}
}
@ -70,7 +71,8 @@ void f6(a, b) [[]] int a; int b; { // notc2x-error {{an attribute list cannot ap
// behavior given that we *don't* want to parse it as part of the K&R parameter
// declarations. It is disallowed to avoid a parsing ambiguity we already
// handle well.
int (*f7(a, b))(int, int) [[]] int a; int b; { // c2x-warning 2 {{type specifier missing, defaults to 'int'}} \
int (*f7(a, b))(int, int) [[]] int a; int b; { // c2x-error {{unknown type name 'a'}} \
c2x-error {{unknown type name 'b'}} \
c2x-error {{expected ';' after top level declarator}} \
c2x-error {{expected identifier or '('}}

View File

@ -4,7 +4,7 @@
// Functions with an identifier list are not supported in C2x.
void ident_list(a) // c2x-error {{expected ';' after top level declarator}} \
c2x-warning {{type specifier missing, defaults to 'int'}}
c2x-error {{unknown type name 'a'}}
int a;
{} // c2x-error {{expected identifier or '('}}

View File

@ -24,7 +24,7 @@ void foo() {
// The following tests used to be crash bugs.
// PR21815
// expected-error@+2{{C++ requires a type specifier for all declarations}}
// expected-error@+2{{a type specifier is required for all declarations}}
// expected-error@+1{{expected unqualified-id}}
a (::( ));

View File

@ -112,7 +112,8 @@ vector __bool long long v_bll4; // expected-error {{use of 'long long' with
#endif
__vector long double vv_ld3; // expected-error {{cannot use 'long double' with '__vector'}}
vector long double v_ld4; // expected-error {{cannot use 'long double' with '__vector'}}
vector bool v_b; // expected-error {{C++ requires a type specifier for all declarations}}
// FIXME: why is this diagnostic different from the others?
vector bool v_b; // expected-error {{a type specifier is required for all declarations}}
vector bool float v_bf; // expected-error {{cannot use 'float' with '__vector bool'}}
vector bool double v_bd; // expected-error {{cannot use 'double' with '__vector bool'}}
vector bool pixel v_bp; // expected-error {{cannot use '__pixel' with '__vector bool'}}

View File

@ -6,4 +6,4 @@
// type-specifier-seq in conversion-type-id
template <typename T> requires T::operator short
unsigned int foo(); // expected-error {{C++ requires a type specifier for all declarations}}
unsigned int foo(); // expected-error {{a type specifier is required for all declarations}}

View File

@ -30,7 +30,7 @@ y::a a3 = a2;
void foo() {
y: // label
y::a s;
int a = 4;
a = a ? a : a+1;
}
@ -39,7 +39,7 @@ struct b : y::a {};
template <typename T>
class someclass {
int bar() {
T *P;
return 1 ? P->x : P->y;
@ -62,7 +62,7 @@ struct a {
void test(struct Type *P) {
int Type;
Type = 1 ? P->Type : Type;
Type = (y:b) 4; // expected-error {{unexpected ':' in nested name specifier}}
Type = 1 ? (
(y:b) // expected-error {{unexpected ':' in nested name specifier}}
@ -128,7 +128,7 @@ struct CodeCompleteConsumer {
};
void CodeCompleteConsumer::() { // expected-error {{xpected unqualified-id}}
}
}
;
@ -306,14 +306,14 @@ namespace rdar37099386 {
// PR8380
extern "" // expected-error {{unknown linkage language}}
test6a { ;// expected-error {{C++ requires a type specifier for all declarations}}
test6a { ;// expected-error {{a type specifier is required for all declarations}}
#if __cplusplus <= 199711L
// expected-error@-2 {{expected ';' after top level declarator}}
#else
// expected-error@-4 {{expected expression}}
// expected-note@-5 {{to match this}}
#endif
int test6b;
#if __cplusplus >= 201103L
// expected-error@+3 {{expected}}

View File

@ -26,6 +26,6 @@ void test() {
};
}
struct Foo {
void bar(*decltype(1) aux); // expected-error {{C++ requires a type specifier for all declarations}}. \
void bar(*decltype(1) aux); // expected-error {{a type specifier is required for all declarations}}. \
// expected-error {{expected ')'}} expected-note {{to match this '('}}
};

View File

@ -6,7 +6,7 @@
// Errors
export class foo { }; // expected-error {{expected template}}
template x; // expected-error {{C++ requires a type specifier for all declarations}} \
template x; // expected-error {{a type specifier is required for all declarations}} \
// expected-error {{does not refer}}
export template x; // expected-error {{expected '<' after 'template'}}
export template<class T> class x0; // expected-warning {{exported templates are unsupported}}
@ -62,7 +62,7 @@ template <int> class NTP0;
template <int N> class NTP1;
template <int N = 5> class NTP2;
template <int = 10> class NTP3;
template <unsigned int N = 12u> class NTP4;
template <unsigned int N = 12u> class NTP4;
template <unsigned int = 12u> class NTP5;
template <unsigned = 15u> class NTP6;
template <typename T, T Obj> class NTP7;
@ -111,11 +111,11 @@ template<template<typename> class T> struct shadow8 { // expected-note{{template
};
// Non-type template parameters in scope
template<int Size>
template<int Size>
void f(int& i) {
i = Size;
#ifdef DELAYED_TEMPLATE_PARSING
Size = i;
Size = i;
#else
Size = i; // expected-error{{expression is not assignable}}
#endif
@ -144,7 +144,7 @@ namespace PR6184 {
template <typename T>
void bar(typename T::x);
}
template <typename T>
void N::bar(typename T::x) { }
}
@ -198,7 +198,7 @@ struct L {
struct O {
template <typename U>
static oneT Fun(U);
};
};
template <int k>
@ -212,8 +212,8 @@ template<typename U>
oneT L<0>::O<char>::Fun(U) { return one; }
void Instantiate() {
sassert(sizeof(L<0>::O<int>::Fun(0)) == sizeof(one));
void Instantiate() {
sassert(sizeof(L<0>::O<int>::Fun(0)) == sizeof(one));
sassert(sizeof(L<0>::O<char>::Fun(0)) == sizeof(one));
}

View File

@ -1,15 +1,15 @@
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
namespace ImplicitInt {
static a(4); // expected-error {{requires a type specifier}}
b(int n); // expected-error {{requires a type specifier}}
static a(4); // expected-error {{a type specifier is required}}
b(int n); // expected-error {{a type specifier is required}}
c (*p)[]; // expected-error {{unknown type name 'c'}}
itn f(char *p, *q); // expected-error {{unknown type name 'itn'}} expected-error {{requires a type specifier}}
itn f(char *p, *q); // expected-error {{unknown type name 'itn'}} expected-error {{a type specifier is required}}
struct S {
void f();
};
S::f() {} // expected-error {{requires a type specifier}}
S::f() {} // expected-error {{a type specifier is required}}
}
// PR7180

View File

@ -28,7 +28,7 @@ auto XL1 = [] constexpr mutable constexpr {}; // expected-error{{cannot appear
auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected body of lambda expression}}
auto XL3 = []( constexpr mutable constexpr {}; // expected-error{{invalid storage class specifier}} \
// expected-error{{function parameter cannot be constexpr}} \
// expected-error{{C++ requires}} \
// expected-error{{a type specifier is required}} \
// expected-error{{expected ')'}} \
// expected-note{{to match this '('}} \
// expected-error{{expected body}} \

View File

@ -6,7 +6,7 @@ void f0(); /* expected-warning {{a function declaration without a prototype is d
void f1(int [*]);
void f2(int [const *]);
void f3(int [volatile const*]);
int f4(*XX)(void); /* expected-error {{cannot return}} expected-warning {{type specifier missing, defaults to 'int'}} */
int f4(*XX)(void); /* expected-error {{cannot return}} expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} */
int f5(int [static]); /* expected-error {{'static' may not be used without an array size}} */
char ((((*X))));
@ -64,9 +64,9 @@ struct xyz test8(void) { return a; } // a should be be marked invalid, no diag.
// Verify that implicit int still works.
static f; // expected-warning {{type specifier missing, defaults to 'int'}}
static g = 4; // expected-warning {{type specifier missing, defaults to 'int'}}
static h // expected-warning {{type specifier missing, defaults to 'int'}}
static f; // expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
static g = 4; // expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
static h // expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
__asm__("foo");

View File

@ -54,7 +54,7 @@ struct B {
// cxx20-warning@#4 {{incompatible with C++ standards before C++20}}
explicit (operator+(A())) operator int(); // #5
// cxx17-error@#5 {{requires a type specifier}} cxx17-error@#5 {{expected ';'}}
// cxx17-error@#5 {{a type specifier is required}} cxx17-error@#5 {{expected ';'}}
// cxx17-warning@#5 {{will be parsed as explicit(bool)}}
// cxx20-warning@#5 {{incompatible with C++ standards before C++20}}
};

View File

@ -4,12 +4,12 @@
// expected-note@+4{{to match this '('}}
// expected-error@+3{{expected unqualified-id}}
// expected-error@+2{{extraneous closing brace}}
// expected-error@+1{{C++ requires a type specifier for all declarations}}
// expected-error@+1{{a type specifier is required for all declarations}}
_BitInt(32} a;
// expected-error@+2{{expected expression}}
// expected-error@+1{{C++ requires a type specifier for all declarations}}
// expected-error@+1{{a type specifier is required for all declarations}}
_BitInt(32* ) b;
// expected-error@+3{{expected '('}}
// expected-error@+2{{expected unqualified-id}}
// expected-error@+1{{C++ requires a type specifier for all declarations}}
// expected-error@+1{{a type specifier is required for all declarations}}
_BitInt{32} c;

View File

@ -24,7 +24,7 @@ typedef struct objc_object {
@implementation MyList (BasicTest)
- (void)compilerTestAgainst {
static i;// expected-warning {{type specifier missing, defaults to 'int'}}
static i;// expected-error {{type specifier missing, defaults to 'int'}}
for (id el, elem in self) // expected-error {{only one element declaration is allowed}}
++i;
for (id el in self)

View File

@ -18,7 +18,7 @@
static_assert(1, ""); // c2x-error {{expected parameter declarator}} \
// c2x-error {{expected ')'}} \
// c2x-note {{to match this '('}} \
// c2x-warning {{type specifier missing, defaults to 'int'}} \
// c2x-error {{a type specifier is required for all declarations}} \
// c2x-ms-warning {{use of 'static_assert' without inclusion of <assert.h> is a Microsoft extension}}
#endif

View File

@ -32,7 +32,7 @@ nested(baz) rise of the dead tokens
// rdar://8197149 - VC++ allows invalid token pastes: (##baz
#define foo(x) abc(x)
#define bar(y) foo(##baz(y))
bar(q) // expected-warning {{type specifier missing}} expected-error {{invalid preprocessing token}} expected-error {{parameter list without types}}
bar(q) // expected-error {{type specifier missing}} expected-error {{invalid preprocessing token}} expected-error {{parameter list without types}}
// CHECK: abc(baz(q))

View File

@ -9,7 +9,7 @@ void bar(_AS2 int a); // expected-error {{parameter may not be qualified with an
void foo(_AS3 float *a,
_AS1 float b) // expected-error {{parameter may not be qualified with an address space}}
{
_AS2 *x;// expected-warning {{type specifier missing, defaults to 'int'}}
_AS2 *x;// expected-error {{type specifier missing, defaults to 'int'}}
_AS1 float * _AS2 *B;
int _AS1 _AS2 *Y; // expected-error {{multiple address spaces specified for type}}

View File

@ -37,7 +37,7 @@ void Issue53652(void) {
// GCC does not accept this either, for the same reason.
_Atomic(__auto_type) aat2 = a; // expected-error {{'__auto_type' not allowed here}} \
// expected-warning {{type specifier missing, defaults to 'int'}}
// expected-error {{type specifier missing, defaults to 'int'}}
// Ensure the types are what we expect them to be, regardless of order we
// pass the types.

View File

@ -37,7 +37,7 @@ void f0(void) {
// rdar://problem/8962770
void test4(void) {
int (^f)(void) = ^((x)) { }; // expected-warning {{type specifier missing}} expected-error {{type-id cannot have a name}}
int (^f)(void) = ^((x)) { }; // expected-error {{type specifier missing}} expected-error {{type-id cannot have a name}}
}
// rdar://problem/9170609

View File

@ -29,7 +29,7 @@ void test2(void) {
takeblock(^{ printf("%d\n", x); });
while (1) {
takeblock(^{
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
@ -41,12 +41,12 @@ void test2(void) {
foo:
takeblock(^{ x = 4; }); // expected-error {{variable is not assignable (missing __block type specifier)}}
__block y = 7; // expected-warning {{type specifier missing, defaults to 'int'}}
__block y = 7; // expected-error {{type specifier missing, defaults to 'int'}}
takeblock(^{ y = 8; });
}
void (^test3(void))(void) {
void (^test3(void))(void) {
return ^{};
}
@ -86,4 +86,4 @@ typedef void (^void_block_t)(void);
static const void_block_t myBlock = ^{ };
static const void_block_t myBlock2 = ^ void(void) { };
static const void_block_t myBlock2 = ^ void(void) { };

View File

@ -39,20 +39,16 @@ int *__restrict; /* expected-error {{expected identifier}} */
test6(void) { return 0; }
/* PR2012 */
test7; /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
test7;
void test8(int, x); /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
void test8(int, x);
typedef int sometype;
int a(sometype, y) {return 0;} /* expected-warning {{declaration specifier missing, defaulting to 'int'}} \
expected-warning {{omitting the parameter name in a function definition is a C2x extension}}*/
int a(sometype, y) {return 0;} /* expected-warning {{omitting the parameter name in a function definition is a C2x extension}}*/
void bar (void *);
void bar (void *);
void f11 (z) /* expected-error {{may not have 'void' type}} */
void z;
void z;
{ bar (&z); }
typedef void T;

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
// PR23086
__builtin_isinf(...); // expected-warning {{type specifier missing, defaults to 'int'}} expected-error {{ISO C requires a named parameter before '...'}} // expected-error {{cannot redeclare builtin function '__builtin_isinf'}} // expected-note {{'__builtin_isinf' is a builtin with type 'int ()'}}
__builtin_isinf(...); // expected-error {{type specifier missing, defaults to 'int'}} expected-error {{ISO C requires a named parameter before '...'}} // expected-error {{cannot redeclare builtin function '__builtin_isinf'}} // expected-note {{'__builtin_isinf' is a builtin with type 'int ()'}}

View File

@ -1,18 +1,18 @@
// RUN: not %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.6 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.7 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple x86_64-apple-macosx10.7 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: not %clang_cc1 -fsyntax-only -triple arm64-apple-ios7.1 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
// RUN: %clang_cc1 -fsyntax-only -triple arm64-apple-ios8.0 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple arm64-apple-ios8.0 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: not %clang_cc1 -fsyntax-only -triple thumbv7s-apple-ios8.3 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
// RUN: %clang_cc1 -fsyntax-only -triple thumbv7s-apple-ios9.0 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: %clang_cc1 -fsyntax-only -triple armv7-apple-ios9.0 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple thumbv7s-apple-ios9.0 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple armv7-apple-ios9.0 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: not %clang_cc1 -fsyntax-only -triple i386-apple-ios9.0-simulator %s 2>&1 | FileCheck %s --check-prefix NO-TLS
// RUN: %clang_cc1 -fsyntax-only -triple i386-apple-ios10.0-simulator %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple i386-apple-ios10.0-simulator %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: not %clang_cc1 -fsyntax-only -triple thumbv7k-apple-watchos1.0 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
// RUN: %clang_cc1 -fsyntax-only -triple thumbv7k-apple-watchos2.0 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple thumbv7k-apple-watchos2.0 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: not %clang_cc1 -fsyntax-only -triple i386-apple-watchos2.0-simulator %s 2>&1 | FileCheck %s --check-prefix NO-TLS
// RUN: %clang_cc1 -fsyntax-only -triple i386-apple-watchos3.0-simulator %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple i386-apple-watchos3.0-simulator %s 2>&1 | FileCheck %s --check-prefix TLS
__thread int a;

View File

@ -18,7 +18,7 @@ void h (const char *fmt, ...) {} // expected-error{{conflicting types for 'h'}}
// PR1965
int t5(b); // expected-error {{parameter list without types}}
int t6(int x, g); // expected-warning {{type specifier missing, defaults to 'int'}}
int t6(int x, g); // expected-error {{type specifier missing, defaults to 'int'}}
int t7(, ); // expected-error {{expected parameter declarator}} expected-error {{expected parameter declarator}}
int t8(, int a); // expected-error {{expected parameter declarator}}
@ -41,8 +41,8 @@ int t14() {
}
// <rdar://problem/6097326>
y(y) { return y; } // expected-warning{{parameter 'y' was not declared, defaulting to type 'int'}} \
// expected-warning{{type specifier missing, defaults to 'int'}}
y(y) { return y; } // expected-error{{parameter 'y' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} \
// expected-error{{type specifier missing, defaults to 'int'}}
// PR3137, <rdar://problem/6127293>

View File

@ -1,16 +1,24 @@
// RUN: %clang_cc1 -fsyntax-only %s -verify -pedantic -Wno-strict-prototypes
/* RUN: %clang_cc1 -fsyntax-only -std=c89 -Wimplicit-int %s -verify -Wno-strict-prototypes
RUN: %clang_cc1 -fsyntax-only -std=c99 %s -verify=ext -Wno-strict-prototypes
RUN: %clang_cc1 -fsyntax-only -std=c2x %s -verify=unsupported
*/
foo(void) { // expected-warning {{type specifier missing, defaults to 'int'}}
foo(void) { /* expected-warning {{type specifier missing, defaults to 'int'}} \
ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \
unsupported-error {{a type specifier is required for all declarations}} */
return 0;
}
y; // expected-warning {{type specifier missing, defaults to 'int'}}
y; /* expected-warning {{type specifier missing, defaults to 'int'}} \
ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \
unsupported-error {{a type specifier is required for all declarations}} */
// rdar://6131634
void f((x)); // expected-warning {{type specifier missing, defaults to 'int'}}
/* rdar://6131634 */
void f((x)); /* expected-warning {{type specifier missing, defaults to 'int'}} \
ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \
unsupported-error {{a type specifier is required for all declarations}} */
// PR3702
/* PR3702 */
#define PAD(ms10) { \
register i; \
}
@ -18,11 +26,18 @@ void f((x)); // expected-warning {{type specifier missing, defaults to 'int'}}
#define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */
void
h19_insline(n) // expected-warning {{parameter 'n' was not declared, defaulting to type 'int'}}
h19_insline(n) /* ext-error {{parameter 'n' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} \
unsupported-error {{unknown type name 'n'}} */
{
ILPAD(); // expected-warning {{type specifier missing, defaults to 'int'}}
ILPAD(); /* expected-warning {{type specifier missing, defaults to 'int'}} \
ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \
unsupported-error {{a type specifier is required for all declarations}} */
}
struct foo {
__extension__ __attribute__((packed)) x : 4; // expected-warning {{type specifier missing, defaults to 'int'}}
__extension__ __attribute__((packed)) x : 4; /* expected-warning {{type specifier missing, defaults to 'int'}} \
ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \
unsupported-error {{unknown type name 'x'}} */
};

View File

@ -6,7 +6,7 @@ void test(void) {
// PR2400
typedef xtype (*x)(void* handle); // expected-error {{function cannot return function type}} expected-warning {{type specifier missing, defaults to 'int'}} expected-warning {{type specifier missing, defaults to 'int'}}
typedef xtype (*x)(void* handle); // expected-error {{function cannot return function type}} expected-error 2{{type specifier missing, defaults to 'int'}}
typedef void ytype();

View File

@ -3,8 +3,8 @@
typedef struct _zend_module_entry zend_module_entry;
struct _zend_module_entry {
_efree((p)); // expected-error{{type name requires a specifier or qualifier}} \
expected-warning {{type specifier missing, defaults to 'int'}}
expected-error {{type specifier missing, defaults to 'int'}}
};
typedef struct _zend_function_entry { } zend_function_entry;
typedef struct _zend_pcre_globals { } zend_pcre_globals;
@ -18,10 +18,10 @@ static int zm_startup_pcre(int type, int module_number ) { }
static int zm_shutdown_pcre(int type, int module_number ) {
zend_function_entry pcre_functions[] = {{ }; // expected-error{{expected '}'}} expected-note {{to match this '{'}}
zend_module_entry pcre_module_entry = {
sizeof(zend_module_entry), 20071006, 0, 0, ((void *)0), ((void *)0),
"pcre", pcre_functions, zm_startup_pcre, zm_shutdown_pcre, ((void *)0),
((void *)0), zm_info_pcre, ((void *)0), sizeof(zend_pcre_globals), &pcre_globals,
((void (*)(void* ))(zm_globals_ctor_pcre)), ((void (*)(void* ))(zm_globals_dtor_pcre)),
((void *)0), 0, 0, ((void *)0), 0
sizeof(zend_module_entry), 20071006, 0, 0, ((void *)0), ((void *)0),
"pcre", pcre_functions, zm_startup_pcre, zm_shutdown_pcre, ((void *)0),
((void *)0), zm_info_pcre, ((void *)0), sizeof(zend_pcre_globals), &pcre_globals,
((void (*)(void* ))(zm_globals_ctor_pcre)), ((void (*)(void* ))(zm_globals_dtor_pcre)),
((void *)0), 0, 0, ((void *)0), 0
};
}

View File

@ -4,7 +4,7 @@ int f(int);
int f(int a) { return 0; } // expected-error {{redefinition of 'f'}}
// <rdar://problem/6097326>
int foo(x) {
int foo(x) { // expected-error {{parameter 'x' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}}
return 0;
}
int x = 1;

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wno-unreachable-code -Wno-unused-value -Wno-strict-prototypes
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -Wno-error=implicit-int -verify -fblocks -Wno-unreachable-code -Wno-unused-value -Wno-strict-prototypes
// clang emits the following warning by default.
// With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the
// With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the
// following warning.
int t14(void) {
return; // expected-warning {{non-void function 't14' should return a value}}
@ -173,7 +173,7 @@ int test27(void) {
goto done;
}
return 1;
case 4:
case 4:
while (0) { goto done; }
return 1;
case 5:
@ -190,7 +190,7 @@ int test27(void) {
// PR4624
void test28() __attribute__((noreturn));
void test28(x) { while (1) { } }
void test28(x) { while (1) { } } // expected-warning {{parameter 'x' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}}
void exit(int);
int test29(void) {

View File

@ -10,11 +10,11 @@ void PR21656(void) {
x = (float)arst; // expected-error-re {{use of undeclared identifier 'arst'{{$}}}}
}
a = b ? : 0; // expected-warning {{type specifier missing, defaults to 'int'}} \
a = b ? : 0; // expected-error {{type specifier missing, defaults to 'int'}} \
// expected-error {{use of undeclared identifier 'b'}}
int foobar; // expected-note {{'foobar' declared here}}
new_a = goobar ?: 4; // expected-warning {{type specifier missing, defaults to 'int'}} \
new_a = goobar ?: 4; // expected-error {{type specifier missing, defaults to 'int'}} \
// expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
// expected-error {{initializer element is not a compile-time constant}}

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -Wno-implicit-function-declaration -verify %s
// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -Wno-implicit-function-declaration -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -Wno-implicit-function-declaration -Wno-error=implicit-int -verify %s
// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -Wno-implicit-function-declaration -Wno-error=implicit-int -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
// function definition with 0 params, no prototype, no preceding declaration.
void foo0() {} // expected-warning {{a function declaration without a prototype is deprecated in all versions of C}}
@ -59,7 +59,8 @@ void foo10(); // expected-warning {{a function declaration without a prototype i
expected-note {{a function declaration without a prototype is not supported in C2x}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:12-[[@LINE-2]]:12}:"void"
// K&R function definition with incomplete param list declared
void foo10(p, p2) void *p; {} // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x}}
void foo10(p, p2) void *p; {} // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x}} \
expected-warning {{parameter 'p2' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}}
void foo11(int p, int p2);
void foo11(p, p2) int p; int p2; {} // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x}}

View File

@ -7,7 +7,7 @@ struct Errors {
void foo() {
// expected-note@+4 {{replace parentheses with an initializer to declare a variable}}
// expected-warning@+3 {{empty parentheses interpreted as a function declaration}}
// expected-error@+2 {{C++ requires a type specifier for all declarations}}
// expected-error@+2 {{a type specifier is required for all declarations}}
// expected-error@+1 {{use of '__super' inside a lambda is unsupported}}
auto lambda = []{ __super::foo(); };
}

View File

@ -3,5 +3,5 @@
// Don't crash.
template<typename>struct ae_same; // expected-note {{}}
template<typename>struct ts{}ap() // expected-error {{expected ';' after struct}} expected-error {{requires a type specifier}}
template<typename>struct ts{}ap() // expected-error {{expected ';' after struct}} expected-error {{a type specifier is required}}
{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); }; // expected-error {{use of undeclared identifier 'a'}} expected-error 5{{}}

View File

@ -1,17 +1,17 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify %s
// Don't crash.
template<typename aT>
struct basic_string{
a; // expected-error {{requires a type specifier}}
a; // expected-error {{a type specifier is required}}
basic_string(aT*);
};
struct runtime_error{
runtime_error(
basic_string<char> struct{ // expected-error {{cannot combine with previous 'type-name' declaration specifier}}
a(){ // expected-error {{requires a type specifier}}
a(){ // expected-error {{a type specifier is required}}
runtime_error(0);
}
}

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify %s
// Don't crash.
@ -18,7 +18,7 @@ int _S_construct();
int _S_construct(int);
_S_construct(); // expected-error {{requires}}
_S_construct(); // expected-error {{a type specifier is required}}
};
template<typename _CharT,typename _Traits,typename _Alloc>

View File

@ -5,13 +5,13 @@
// <rdar://problem/8124080>
template<typename _Alloc> class allocator;
template<class _CharT> struct char_traits;
template<typename _CharT, typename _Traits = char_traits<_CharT>,
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
class basic_string;
template<typename _CharT, typename _Traits, typename _Alloc>
const typename basic_string<_CharT, _Traits, _Alloc>::size_type
const typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_max_size // expected-error{{no member named '_Rep' in 'basic_string<_CharT, _Traits, _Alloc>'}}
= (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4;
= (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4;
// PR7118
template<typename T>
@ -181,8 +181,8 @@ namespace pr16964 {
template<typename> struct bs {
bs();
static int* member(); // expected-note{{possible target}}
member(); // expected-error{{C++ requires a type specifier for all declarations}}
static member(); // expected-error{{C++ requires a type specifier for all declarations}}
member(); // expected-error{{a type specifier is required for all declarations}}
static member(); // expected-error{{a type specifier is required for all declarations}}
static int* member(int); // expected-note{{possible target}}
};
@ -237,7 +237,7 @@ namespace pr16989 {
}
namespace pr20660 {
appendList(int[]...); // expected-error {{C++ requires a type specifier for all declarations}}
appendList(int[]...) { } // expected-error {{C++ requires a type specifier for all declarations}}
appendList(int[]...); // expected-error {{a type specifier is required for all declarations}}
appendList(int[]...) { } // expected-error {{a type specifier is required for all declarations}}
}

View File

@ -8,10 +8,10 @@
#define CONST constexpr
#endif
template<typename T>
template<typename T>
T pi = T(3.1415926535897932385); // expected-note 2{{declared here}}
template<typename T>
template<typename T>
CONST T cpi = T(3.1415926535897932385); // expected-note {{template is declared here}}
template<typename T> extern CONST T vc;
@ -33,7 +33,7 @@ namespace use_in_top_level_funcs {
int ipi = pi; // expected-error {{use of variable template 'pi' requires template arguments}}
int icpi = cpi; // expected-error {{use of variable template 'cpi' requires template arguments}}
}
template<typename T>
T circular_area(T r) {
return pi<T> * r * r;
@ -79,13 +79,13 @@ namespace odr_tmpl {
template<typename T> T v; // expected-note {{previous definition is here}}
template<typename T> int v; // expected-error {{redefinition of 'v'}}
template<typename T> extern int v1; // expected-note {{previous template declaration is here}}
template<int I> int v1; // expected-error {{template parameter has a different kind in template redeclaration}}
}
namespace pvt_use {
template<typename T> T v;
v = 10; // expected-error {{C++ requires a type specifier for all declarations}}
v = 10; // expected-error {{a type specifier is required for all declarations}}
}
namespace pvt_diff_params {
@ -121,36 +121,36 @@ namespace odr_tmpl {
template<typename T> extern auto v4; // expected-error {{declaration of variable 'v4' with deduced type 'auto' requires an initializer}}
}
#endif
}
namespace explicit_instantiation {
template<typename T>
template<typename T>
T pi0a = T(3.1415926535897932385); // expected-note {{variable template 'pi0a' declared here}}
template float pi0a<int>; // expected-error {{type 'float' of explicit instantiation of 'pi0a' does not match expected type 'int'}}
template<typename T>
template<typename T>
T pi0b = T(3.1415926535897932385); // expected-note {{variable template 'pi0b' declared here}}
template CONST int pi0b<int>; // expected-error {{type 'const int' of explicit instantiation of 'pi0b' does not match expected type 'int'}}
template<typename T>
template<typename T>
T pi0c = T(3.1415926535897932385); // expected-note {{variable template 'pi0c' declared here}}
template int pi0c<const int>; // expected-error {{type 'int' of explicit instantiation of 'pi0c' does not match expected type 'const int'}}
template<typename T>
template<typename T>
T pi0 = T(3.1415926535897932385);
template int pi0<int>; // expected-note {{previous explicit instantiation is here}}
template int pi0<int>; // expected-error {{duplicate explicit instantiation of 'pi0<int>'}}
template<typename T>
template<typename T>
CONST T pi1a = T(3.1415926535897932385); // expected-note {{variable template 'pi1a' declared here}}
template int pi1a<int>; // expected-error {{type 'int' of explicit instantiation of 'pi1a' does not match expected type 'const int'}}
template<typename T>
template<typename T>
CONST T pi1b = T(3.1415926535897932385); // expected-note {{variable template 'pi1b' declared here}}
template int pi1b<const int>; // expected-error {{type 'int' of explicit instantiation of 'pi1b' does not match expected type 'const const int'}}
template<typename T>
template<typename T>
CONST T pi1 = T(3.1415926535897932385);
template CONST int pi1<int>; // expected-note {{previous explicit instantiation is here}}
template CONST int pi1<int>; // expected-error {{duplicate explicit instantiation of 'pi1<int>'}}
@ -159,7 +159,7 @@ namespace explicit_instantiation {
namespace auto_var {
template<typename T> auto var0 = T();
template auto var0<int>; // expected-error {{'auto' variable template instantiation is not allowed}}
template<typename T> auto var = T();
template int var<int>;
}
@ -187,7 +187,7 @@ namespace explicit_specialization {
template<> CONST int pi2<int,int> = 4;
#ifndef PRECXX11
#ifndef PRECXX11
void foo() {
static_assert(pi2<int,int> == 4, "");
static_assert(pi2<float,int> == 2, "");
@ -209,15 +209,15 @@ namespace explicit_specialization {
template<typename T>
CONST int pi2<int,T> = 3; // expected-note {{partial specialization matches [with T = int]}}
void foo() {
int a = pi2<int,int>; // expected-error {{ambiguous partial specializations of 'pi2<int, int>'}}
}
}
namespace type_changes {
template<typename T>
template<typename T>
T pi0 = T(3.1415926535897932385);
template<> float pi0<int> = 10;
@ -252,15 +252,15 @@ namespace explicit_specialization {
#endif
template<typename T>
template<typename T>
CONST T pi1 = T(3.1415926535897932385);
template<> CONST int pi1<int> = 10; // expected-note {{previous definition is here}}
template<> CONST int pi1<int> = 10; // expected-error {{redefinition of 'pi1<int>'}}
}
namespace before_instantiation {
template<typename T>
template<typename T>
T pi0 = T(3.1415926535897932385); // expected-note {{variable template 'pi0' declared here}}
template<> int pi0<int> = 10; // expected-note 2{{previous template specialization is here}}
@ -274,7 +274,7 @@ namespace explicit_specialization {
template CONST int pi2<int,int>;
}
namespace after_instantiation {
template<typename T>
template<typename T>
T pi0 = T(3.1415926535897932385);
template int pi0<int>; // expected-note 2{{explicit instantiation first required here}}
@ -304,11 +304,11 @@ namespace explicit_specialization {
}
}
#endif
namespace extern_var {
// TODO:
}
namespace diff_type {
// TODO:
template<typename T> T* var = new T();
@ -343,7 +343,7 @@ namespace arrays {
float f = 10.5;
template<> float* arr<float> = &f;
void bar() {
int *iarr = arr<int>;
iarr[0] = 1;
@ -357,48 +357,48 @@ namespace arrays {
#endif
namespace nested {
namespace n0a {
template<typename T>
template<typename T>
T pi0a = T(3.1415926535897932385);
}
using namespace n0a;
int i0a = pi0a<int>;
template float pi0a<float>;
float f0a = pi0a<float>;
template<> double pi0a<double> = 5.2;
double d0a = pi0a<double>;
namespace n0b {
template<typename T>
template<typename T>
T pi0b = T(3.1415926535897932385);
}
int i0b = n0b::pi0b<int>;
template float n0b::pi0b<float>;
float f0b = n0b::pi0b<float>;
template<> double n0b::pi0b<double> = 5.2;
double d0b = n0b::pi0b<double>;
namespace n1 {
template<typename T>
template<typename T>
T pi1a = T(3.1415926535897932385); // expected-note {{explicitly specialized declaration is here}}
#ifndef PRECXX11
// expected-note@-2 {{explicit instantiation refers here}}
#endif
template<typename T>
template<typename T>
T pi1b = T(3.1415926535897932385); // expected-note {{explicitly specialized declaration is here}}
#ifndef PRECXX11
// expected-note@-2 {{explicit instantiation refers here}}
#endif
}
namespace use_n1a {
using namespace n1;
int i1 = pi1a<int>;
@ -408,20 +408,20 @@ namespace nested {
// expected-error@-2 {{explicit instantiation of 'pi1a<float>' not in a namespace enclosing 'n1'}}
#endif
float f1 = pi1a<float>;
template<> double pi1a<double> = 5.2; // expected-error {{not in a namespace enclosing 'n1'}}
double d1 = pi1a<double>;
}
namespace use_n1b {
int i1 = n1::pi1b<int>;
template float n1::pi1b<float>;
#ifndef PRECXX11
// expected-error@-2 {{explicit instantiation of 'pi1b<float>' not in a namespace enclosing 'n1'}}
#endif
float f1 = n1::pi1b<float>;
template<> double n1::pi1b<double> = 5.2; // expected-error {{not in a namespace enclosing 'n1'}}
double d1 = n1::pi1b<double>;
}
@ -451,7 +451,7 @@ namespace PR19169 {
template <typename T> int* f();
template <typename T> void f();
template<> int f<double>; // expected-error {{no variable template matches specialization; did you mean to use 'f' as function template instead?}}
template <typename T> void g();
template<> int g<double>; // expected-error {{no variable template matches specialization; did you mean to use 'g' as function template instead?}}
}

View File

@ -8,7 +8,7 @@ error e; // expected-error {{unknown type name}}
template <typename>
class Bar {
Bar<int> *variables_to_modify;
foo() { // expected-error {{C++ requires a type specifier for all declarations}}
foo() { // expected-error {{a type specifier is required for all declarations}}
for (auto *c : *variables_to_modify)
delete c;
}

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
x; // expected-error{{C++ requires a type specifier for all declarations}}
x; // expected-error{{a type specifier is required for all declarations}}
f(int y) { return y; } // expected-error{{C++ requires a type specifier for all declarations}}
f(int y) { return y; } // expected-error{{a type specifier is required for all declarations}}

View File

@ -2,7 +2,7 @@
// Don't crash.
struct g {
j; // expected-error {{C++ requires a type specifier for all declarations}}
j; // expected-error {{a type specifier is required for all declarations}}
};
void captures_invalid_type() {

View File

@ -5,7 +5,7 @@ namespace n1 {
class A { };
class C { A a; };
A::RunTest() {} // expected-error {{C++ requires a type specifier for all declarations}}
A::RunTest() {} // expected-error {{a type specifier is required for all declarations}}
void f() {
new C;
@ -16,7 +16,7 @@ namespace n2 {
class A { };
class C : public A { };
A::RunTest() {} // expected-error {{C++ requires a type specifier for all declarations}}
A::RunTest() {} // expected-error {{a type specifier is required for all declarations}}
void f() {
new C;

View File

@ -159,7 +159,7 @@ __typeof blur y; // expected-error {{use of undeclared identifier 'blur'; did y
}
namespace PR22092 {
a = b ? : 0; // expected-error {{C++ requires a type specifier for all declarations}} \
a = b ? : 0; // expected-error {{a type specifier is required for all declarations}} \
// expected-error-re {{use of undeclared identifier 'b'{{$}}}}
}

View File

@ -494,7 +494,7 @@ template <typename T> struct Wrappable {
// instead of incorrectly suggesting dropping "PR18213::WrapperInfo::".
template <>
PR18213::WrapperInfo ::PR18213::Wrappable<int>::kWrapperInfo = { 0 }; // expected-error {{no member named 'PR18213' in 'PR18213::WrapperInfo'; did you mean simply 'PR18213'?}} \
// expected-error {{C++ requires a type specifier for all declarations}}
// expected-error {{a type specifier is required for all declarations}}
}
namespace PR18651 {

View File

@ -116,4 +116,4 @@ template<typename T> int i(T::type, int());
// FIXME: We know which type specifier should have been specified here. Provide
// a fix-it to add 'typename A<T>::type'
template<typename T>
A<T>::g() { } // expected-error{{requires a type specifier}}
A<T>::g() { } // expected-error{{a type specifier is required}}

View File

@ -62,6 +62,6 @@
@end
@protocol P
- (int)test:(int)param, ..; // expected-warning{{type specifier missing}} \
- (int)test:(int)param, ..; // expected-error{{type specifier missing}} \
// expected-error{{expected ';' after method prototype}}
@end

View File

@ -42,21 +42,21 @@ namespace ns {
// expected-error@-1 {{type name requires a specifier or qualifier}}
// expected-error@-2 {{property requires fields to be named}}
// expected-error@-3 {{expected ';' at end of declaration list}}
// expected-error@-4 {{C++ requires a type specifier for all declarations}}
// expected-error@-4 {{a type specifier is required for all declarations}}
// expected-error@-5 {{cannot declare variable inside @interface or @protocol}}
@property (nonatomic) (ns::InnerType) invalidTypeParens2;
// expected-error@-1 {{type name requires a specifier or qualifier}}
// expected-error@-2 {{property requires fields to be named}}
// expected-error@-3 {{expected ';' at end of declaration list}}
// expected-error@-4 {{C++ requires a type specifier for all declarations}}
// expected-error@-4 {{a type specifier is required for all declarations}}
// expected-error@-5 {{cannot declare variable inside @interface or @protocol}}
@property (nonatomic) int OuterType::InnerType; // expected-error {{property requires fields to be named}}
@property (nonatomic) int OuterType::InnerType foo; // expected-error {{property requires fields to be named}}
// expected-error@-1 {{expected ';' at end of declaration list}}
// expected-error@-2 {{C++ requires a type specifier for all declarations}}
// expected-error@-2 {{a type specifier is required for all declarations}}
// expected-error@-3 {{cannot declare variable inside @interface or @protocol}}
@end

View File

@ -10,7 +10,7 @@ void foo(read_only pipe int p);
// expected-error@-5 {{C++ for OpenCL version 2021 does not support the 'pipe' type qualifier}}
// expected-error@-6 {{access qualifier can only be used for pipe and image type}}
#else
// expected-warning@-8 {{type specifier missing, defaults to 'int'}}
// expected-error@-8 {{type specifier missing, defaults to 'int'}}
// expected-error@-9 {{access qualifier can only be used for pipe and image type}}
// expected-error@-10 {{expected ')'}} expected-note@-10 {{to match this '('}}
#endif

View File

@ -9,7 +9,7 @@ void car() {
__attribute__((address_space(J))) int array[5]; // expected-error {{automatic variable qualified with an address space}}
__attribute__((address_space(I))) int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}}
__attribute__((address_space(J))) * x; // expected-error {{C++ requires a type specifier for all declarations}}
__attribute__((address_space(J))) * x; // expected-error {{a type specifier is required for all declarations}}
__attribute__((address_space(I))) float *B;
@ -89,12 +89,12 @@ template <unsigned B> int __attribute__((address_space(B+1))) *different_templat
void test_different_template() { (void) different_template<0>(); } // expected-error {{call to 'different_template' is ambiguous}}
template <typename T> struct partial_spec_deduce_as;
template <typename T, unsigned AS>
template <typename T, unsigned AS>
struct partial_spec_deduce_as <__attribute__((address_space(AS))) T *> {
static const unsigned value = AS;
};
static const unsigned value = AS;
};
int main() {
int main() {
int __attribute__((address_space(1))) * p1;
int p = GetAddressSpaceValue(p1);
@ -112,8 +112,8 @@ int main() {
ff.get_0(); // expected-note {{in instantiation of member function 'fooFunction<1>::get_0' requested here}}
ff.qf();
ff.test3(); // expected-note {{in instantiation of member function 'fooFunction<1>::test3' requested here}}
static_assert(partial_spec_deduce_as<int __attribute__((address_space(3))) *>::value == 3, "address space value has been incorrectly deduced");
static_assert(partial_spec_deduce_as<int __attribute__((address_space(3))) *>::value == 3, "address space value has been incorrectly deduced");
return 0;
}

View File

@ -14,7 +14,7 @@ void test() {
namespace rdar13267210 {
template < typename T > class A {
BaseTy; // expected-error{{C++ requires a type specifier for all declarations}}
BaseTy; // expected-error{{a type specifier is required for all declarations}}
};
template < typename T, int N > class C: A < T > {};

View File

@ -19,7 +19,7 @@ namespace N {
template<class, class> struct TooMany; // expected-note{{too many template parameters in template template argument}}
A<X> *a1;
A<X> *a1;
A<N::Z> *a2;
A< ::N::Z> *a3;
@ -42,19 +42,19 @@ A<::N::Z> *a10;
// Do not do a digraph correction here.
A<: :N::Z> *a11; // expected-error{{expected expression}} \
expected-error{{C++ requires a type specifier for all declarations}}
expected-error{{a type specifier is required for all declarations}}
// PR7807
namespace N {
template <typename, typename = int>
template <typename, typename = int>
struct X
{ };
template <typename ,int>
template <typename ,int>
struct Y
{ X<int> const_ref(); };
template <template<typename,int> class TT, typename T, int N>
template <template<typename,int> class TT, typename T, int N>
int operator<<(int, TT<T, N> a) { // expected-note{{candidate template ignored}}
0 << a.const_ref(); // expected-error{{invalid operands to binary expression ('int' and 'X<int>')}}
}

View File

@ -6,7 +6,7 @@
// RUN: cd %t/abc/def2
// RUN: env PWD="%t/abc/def" not clang-check "ijk/qwe/test.cpp" 2>&1 | FileCheck %s
// CHECK: C++ requires
// CHECK: a type specifier is required
// CHECK: /abc/def/ijk/qwe/test.cpp
invalid;

View File

@ -4,5 +4,5 @@
// RUN: cp "%s" "%t/abc/def/ijk/qwe/test.cpp"
// RUN: not clang-check "%t/abc/def/ijk/qwe/test.cpp" 2>&1 | FileCheck %s
// CHECK: C++ requires
// CHECK: a type specifier is required
invalid;

View File

@ -1,4 +1,4 @@
// RUN: not clang-check "%s" -- -c 2>&1 | FileCheck %s
// CHECK: C++ requires
// CHECK: a type specifier is required
invalid;

View File

@ -5,5 +5,5 @@
// RUN: not clang-check -p "%t/abc/def" "%t/test.cpp" 2>&1|FileCheck %s
// FIXME: Make the above easier.
// CHECK: C++ requires
// CHECK: a type specifier is required
invalid;

Some files were not shown because too many files have changed in this diff Show More