From 1ae23294fb435b3aca28e47c3996436817cb5872 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 4 Aug 2006 06:42:31 +0000 Subject: [PATCH] C99 requires at least one type specifier. llvm-svn: 38813 --- clang/Parse/DeclSpec.cpp | 10 ++++++++++ clang/include/clang/Basic/DiagnosticKinds.def | 3 +++ 2 files changed, 13 insertions(+) diff --git a/clang/Parse/DeclSpec.cpp b/clang/Parse/DeclSpec.cpp index e4fd47e2ac95..2ae1bc73fc0f 100644 --- a/clang/Parse/DeclSpec.cpp +++ b/clang/Parse/DeclSpec.cpp @@ -204,4 +204,14 @@ void DeclSpec::Finish(SourceLocation Loc, Diagnostic &D, TypeSpecComplex = TSC_unspecified; } } + + // If this is C99, require that at least one specifier is present! + if (Lang.C99 && (getParsedSpecifiers() & PQ_TypeSpecifier) == 0) { + D.Report(Loc, diag::w_type_defaults_to_int); + TypeSpecType = TST_int; + } + + // Okay, now we can infer the real type. + + // 'data definition has no type or storage class'? } diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index 389884b42db9..9cb983816220 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -234,6 +234,9 @@ DIAG(err_pp_I_dash_not_supported, ERROR, // Parser Diagnostics //===----------------------------------------------------------------------===// +DIAG(w_type_defaults_to_int, WARNING, + "type defaults to 'int'") + DIAG(ext_empty_source_file, EXTENSION, "ISO C forbids an empty source file") DIAG(ext_top_level_semi, EXTENSION,