//===-- DiagnosticKinds.def - C Family Diagnostic Kind Database -*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  This file defines the DiagnosticKind database.
//
//===----------------------------------------------------------------------===//

// Flags for diagnostic:
//
//   DIAG_TYPE - Allows one of:
//     NOTE      - Informational message.
//     WARNING   - Warning.
//     EXTENSION - Notification that an extension to the language is being used.
//     ERROR     - Error, compilation will stop after parsing completes.
//     FATAL     - Fatal error: parsing must stop.

//===----------------------------------------------------------------------===//
// Portability
//===----------------------------------------------------------------------===//

DIAG(port_wchar_t, NOTE,
     "sizeof(wchar_t) varies between targets, source is not 'portable'")

//===----------------------------------------------------------------------===//
// Lexer Diagnostics
//===----------------------------------------------------------------------===//

DIAG(null_in_string, WARNING,
     "null character(s) preserved in string literal")
DIAG(null_in_char  , WARNING,
     "null character(s) preserved in character literal")
DIAG(null_in_file  , WARNING,
     "null character ignored")
DIAG(nested_block_comment, WARNING,
     "\"/*\" within block comment")
DIAG(escaped_newline_block_comment_end, WARNING,
     "escaped newline between */ characters at block comment end")
DIAG(min_max_deprecated, WARNING,
     "minimum/maximum operators are deprecated")
DIAG(backslash_newline_space, WARNING,
     "backslash and newline separated by space")

// Trigraphs.
DIAG(trigraph_ignored, WARNING, "trigraph ignored")
DIAG(trigraph_ignored_block_comment, WARNING,
     "ignored trigraph would end block comment")
DIAG(trigraph_ends_block_comment, WARNING,
     "trigraph ends block comment")
DIAG(trigraph_converted, WARNING,
     "trigraph converted to '%s' character")

DIAG(ext_multi_line_bcpl_comment, EXTENSION,
     "multi-line // comment")
DIAG(ext_bcpl_comment, EXTENSION,
     "// comments are not allowed in this language")
DIAG(ext_no_newline_eof, EXTENSION,
     "no newline at end of file")
DIAG(ext_backslash_newline_eof, EXTENSION,
     "backslash-newline at end of file")
DIAG(ext_dollar_in_identifier, EXTENSION,
     "'$' in identifier")
DIAG(charize_microsoft_ext, EXTENSION,
     "@# is a microsoft extension")

DIAG(ext_token_used, EXTENSION,
     "extension used")

DIAG(err_unterminated_string, ERROR,
     "missing terminating \" character")
DIAG(err_unterminated_char, ERROR,
     "missing terminating ' character")
DIAG(err_empty_character, ERROR,
     "empty character constant")
DIAG(err_unterminated_block_comment, ERROR,
     "unterminated /* comment")
DIAG(err_invalid_character_to_charify, ERROR,
     "invalid argument to convert to character")

//===----------------------------------------------------------------------===//
// Preprocessor Diagnostics
//===----------------------------------------------------------------------===//

DIAG(pp_hash_warning, WARNING,
     "#warning%s")
DIAG(pp_include_next_in_primary, WARNING,
     "#include_next in primary source file")
DIAG(pp_include_next_absolute_path, WARNING,
     "#include_next with absolute path")
DIAG(ext_c99_whitespace_required_after_macro_name, WARNING,
     "ISO C99 requires whitespace after the macro name")
DIAG(pp_pragma_once_in_main_file, WARNING,
     "#pragma once in main file")
DIAG(pp_pragma_sysheader_in_main_file, WARNING,
     "#pragma system_header ignored in main file")
DIAG(pp_poisoning_existing_macro, WARNING,
     "poisoning existing macro")
DIAG(pp_out_of_date_dependency, WARNING,
     "current file is older than dependency %s")
DIAG(pp_undef_builtin_macro, WARNING,
     "undefining builtin macro")
DIAG(pp_redef_builtin_macro, WARNING,
     "redefining builtin macro")
DIAG(pp_macro_not_used, WARNING,    // -Wunused-macros
     "macro is not used")
DIAG(pp_invalid_string_literal, WARNING,
     "invalid string literal, ignoring final '\\'")

DIAG(ext_pp_import_directive, EXTENSION,
     "#import is a language extension")
DIAG(ext_pp_ident_directive, EXTENSION,
     "#ident is a language extension")
DIAG(ext_pp_include_next_directive, EXTENSION,
     "#include_next is a language extension")
DIAG(ext_pp_warning_directive, EXTENSION,
     "#warning is a language extension")
DIAG(ext_pp_extra_tokens_at_eol, EXTENSION,
     "extra tokens at end of %s directive")
DIAG(ext_pp_comma_expr, EXTENSION,
     "comma operator in operand of #if")
DIAG(ext_pp_bad_vaargs_use, EXTENSION,
     "__VA_ARGS__ can only appear in the expansion of a C99 variadic macro")
DIAG(ext_pp_macro_redef, EXTENSION,
     "\"%s\" macro redefined")
DIAG(ext_pp_macro_redef2, EXTENSION,
     "this is previous definition")
DIAG(ext_variadic_macro, EXTENSION,
     "variadic macros were introduced in C99")
DIAG(ext_named_variadic_macro, EXTENSION,
     "named variadic macros are a GNU extension")
DIAG(ext_embedded_directive, EXTENSION,
     "embedding a directive within macro arguments is not portable")
DIAG(ext_missing_varargs_arg, EXTENSION,
     "varargs argument missing, but tolerated as an extension")
DIAG(ext_empty_fnmacro_arg, EXTENSION,
     "empty macro arguments were standardized in C99")

DIAG(ext_pp_base_file, EXTENSION,
     "__BASE_FILE__ is a language extension")
DIAG(ext_pp_include_level, EXTENSION,
     "__INCLUDE_LEVEL__ is a language extension")
DIAG(ext_pp_timestamp, EXTENSION,
     "__TIMESTAMP__ is a language extension")

DIAG(err_pp_invalid_directive, ERROR,
     "invalid preprocessing directive")
DIAG(err_pp_hash_error, ERROR,
     "#error%s")
DIAG(err_pp_file_not_found, ERROR,
     "file not found")
DIAG(err_pp_empty_filename, ERROR,
     "empty filename")
DIAG(err_pp_include_too_deep, ERROR,
     "#include nested too deeply")
DIAG(err_pp_expects_filename, ERROR,
     "expected \"FILENAME\" or <FILENAME>")
DIAG(err_pp_macro_not_identifier, ERROR,
     "macro names must be identifiers")
DIAG(err_pp_missing_macro_name, ERROR,
     "macro name missing")
DIAG(err_pp_missing_rparen_in_macro_def, ERROR,
     "missing ')' in macro parameter list")
DIAG(err_pp_invalid_tok_in_arg_list, ERROR,
     "invalid token in macro parameter list")
DIAG(err_pp_expected_ident_in_arg_list, ERROR,
     "expected identifier in macro parameter list")
DIAG(err_pp_expected_comma_in_arg_list, ERROR,
     "expected comma in macro parameter list")
DIAG(err_pp_duplicate_name_in_arg_list, ERROR,
     "duplicate macro parameter name \"%s\"")
DIAG(err_pp_stringize_not_parameter, ERROR,
     "'#' is not followed by a macro parameter")
DIAG(err_pp_malformed_ident, ERROR,
     "invalid #ident directive")
DIAG(err_pp_unterminated_conditional, ERROR,
     "unterminated conditional directive")
DIAG(pp_err_else_after_else, ERROR,
     "#else after #else")
DIAG(pp_err_elif_after_else, ERROR,
     "#elif after #else")
DIAG(pp_err_else_without_if, ERROR,
     "#else without #if")
DIAG(pp_err_elif_without_if, ERROR,
     "#elif without #if")
DIAG(err_pp_endif_without_if, ERROR,
     "#endif without #if")
DIAG(err_pp_expected_value_in_expr, ERROR,
     "expected value in expression")
DIAG(err_pp_missing_val_before_operator, ERROR,
     "missing value before operator")
DIAG(err_pp_expected_rparen, ERROR,
     "expected ')' in preprocessor expression")
DIAG(err_pp_expected_eol, ERROR,
     "expected end of line in preprocessor expression")
DIAG(err_pp_defined_requires_identifier, ERROR,
     "operator \"defined\" requires an identifier")
DIAG(err_pp_missing_rparen, ERROR,
     "missing ')' after \"defined\"")
DIAG(err_pp_colon_without_question, ERROR,
     "':' without preceding '?'")
DIAG(err_pp_question_without_colon, ERROR,
     "'?' without following ':'")
DIAG(err_pp_division_by_zero, ERROR,
     "division by zero in preprocessor expression")
DIAG(err_pp_remainder_by_zero, ERROR,
     "remainder by zero in preprocessor expression")
DIAG(err_pp_expr_bad_token, ERROR,
     "token is not valid in preprocessor expressions")
DIAG(err_pp_invalid_poison, ERROR,
     "can only poison identifier tokens")
DIAG(err_pp_used_poisoned_id, ERROR,
     "attempt to use a poisoned identifier")
DIAG(err__Pragma_malformed, ERROR,
     "_Pragma takes a parenthesized string literal")
DIAG(err_defined_macro_name, ERROR,
     "\"defined\" cannot be used as a macro name")
DIAG(err_paste_at_start, ERROR,
     "\"##\" cannot appear at start of macro expansion")
DIAG(err_paste_at_end, ERROR,
     "\"##\" cannot appear at end of macro expansion")
DIAG(err_unterm_macro_invoc, ERROR,
     "unterminated function-like macro invocation")
DIAG(err_too_many_args_in_macro_invoc, ERROR,
     "too many arguments provided to function-like macro invocation")
DIAG(err_too_few_args_in_macro_invoc, ERROR,
     "too few arguments provided to function-like macro invocation")
DIAG(err_pp_bad_paste, ERROR,
     "pasting formed \"%s\", an invalid preprocessing token")

// Should be a sorry?
DIAG(err_pp_I_dash_not_supported, ERROR,
     "-I- not supported, please use -iquote instead")
     
//===----------------------------------------------------------------------===//
// Parser Diagnostics
//===----------------------------------------------------------------------===//

DIAG(w_type_defaults_to_int, WARNING,
     "type defaults to 'int'")
DIAG(w_no_declarators, WARNING,
     "declaration does not declare anything")
DIAG(w_asm_qualifier_ignored, WARNING,
     "ignored %s qualifier on asm")

DIAG(ext_empty_source_file, EXTENSION,
     "ISO C forbids an empty source file")
DIAG(ext_top_level_semi, EXTENSION,
     "ISO C does not allow extra ';' outside of a function")
DIAG(ext_duplicate_declspec, EXTENSION,
     "duplicate '%s' declaration specifier")
DIAG(ext_plain_complex, EXTENSION,
     "ISO C does not support plain '_Complex' meaning '_Complex double'")
DIAG(ext_integer_complex, EXTENSION,
     "ISO C does not support complex integer types")
DIAG(ext_thread_before, EXTENSION,
     "'__thread' before 'static'")

DIAG(ext_empty_struct_union_enum, EXTENSION,
     "use of empty %s extension")

DIAG(ext_ident_list_in_param, EXTENSION,
     "type-less parameter names in function declaration")
DIAG(ext_c99_array_usage, EXTENSION,
     "use of C99-specific array features")
DIAG(ext_c99_variable_decl_in_for_loop, EXTENSION,
     "variable declaration in for loop is a C99-specific feature")
DIAG(ext_c99_compound_literal, EXTENSION,
     "compound literals are a C99-specific feature")
DIAG(ext_c99_enumerator_list_comma, EXTENSION,
     "commas at the end of enumerator lists are a C99-specific feature")
     
DIAG(ext_gnu_indirect_goto, EXTENSION,
     "use of GNU indirect-goto extension")
DIAG(ext_gnu_address_of_label, EXTENSION,
     "use of GNU address-of-label extension")
DIAG(ext_gnu_statement_expr, EXTENSION,
     "use of GNU statement expression extension")
DIAG(ext_gnu_conditional_expr, EXTENSION,
     "use of GNU ?: expression extension, eliding middle term")
DIAG(ext_gnu_empty_initializer, EXTENSION,
     "use of GNU empty initializer extension")
DIAG(ext_gnu_array_range, EXTENSION,
     "use of GNU array range extension")
DIAG(ext_gnu_missing_equal_designator, EXTENSION,
     "use of GNU 'missing =' extension in designator")
DIAG(ext_gnu_old_style_field_designator, EXTENSION,
     "use of GNU old-style field designator extension")
DIAG(ext_gnu_case_range, EXTENSION,
     "use of GNU case range extension")
     
// Generic errors.
DIAG(err_parse_error, ERROR,
     "parse error")
DIAG(err_expected_expression, ERROR,
     "expected expression")
DIAG(err_expected_ident, ERROR,
     "expected identifier")
DIAG(err_expected_ident_lparen, ERROR,
     "expected identifier or '('")
DIAG(err_expected_ident_lbrace, ERROR,
     "expected identifier or '{'")
DIAG(err_expected_rparen, ERROR,
     "expected ')'")
DIAG(err_expected_rsquare, ERROR,
     "expected ']'")
DIAG(err_expected_rbrace, ERROR,
     "expected '}'")
DIAG(err_expected_semi_decl_list, ERROR,
     "expected ';' at end of declaration list")
DIAG(err_expected_fn_body, ERROR,
     "expected function body after function declarator")
DIAG(err_expected_after_declarator, ERROR,
     "expected '=', ',', ';', 'asm', or '__attribute__' after declarator")
DIAG(err_expected_statement, ERROR,
     "expected statement")
DIAG(err_expected_lparen_after, ERROR,
     "expected '(' after '%s'")
DIAG(err_expected_comma, ERROR,
     "expected ','")
DIAG(err_expected_lbrace_in_compound_literal, ERROR,
     "expected '{' in compound literal")
DIAG(err_expected_while, ERROR,
     "expected 'while' in do/while loop")
DIAG(err_expected_semi_after, ERROR,
     "expected ';' after %s")
DIAG(err_expected_semi_for, ERROR,
     "expected ';' in 'for' statement specifier")
DIAG(err_expected_colon_after, ERROR,
     "expected ':' after %s")
DIAG(err_label_end_of_compound_statement, ERROR,
     "label at end of compound statement: expected statement")
DIAG(err_expected_colon, ERROR,
     "expected ':'")
DIAG(err_expected_string_literal, ERROR,
     "expected string literal")
DIAG(err_expected_asm_operand, ERROR,
     "expected string literal or '[' for asm operand")

/// err_matching - this is used as a continuation of a previous error, e.g. to 
/// specify the '(' when we expected a ')'.  This should probably be some
/// special sort of diagnostic kind to indicate that it is the second half of
/// the previous diagnostic.
DIAG(err_matching, ERROR,
     "to match this '%s'")

//===----------------------------------------------------------------------===//
// Semantic Analysis
//===----------------------------------------------------------------------===//

DIAG(ext_nonstandard_escape, EXTENSION,
     "use of non-standard escape character '\\%s'")
DIAG(ext_unknown_escape, EXTENSION,
     "unknown escape sequence '\\%s'")

DIAG(err_hex_escape_no_digits, ERROR,
     "\\x used with no following hex digits")

DIAG(err_typename_requires_specqual, ERROR,
     "type name requires a specifier or qualifier")
DIAG(err_typename_invalid_storageclass, ERROR,
     "type name does not allow storage class to be specified")
DIAG(err_typename_invalid_functionspec, ERROR,
     "type name does not allow function specifier to be specified")
DIAG(err_invalid_decl_spec_combination, ERROR,
     "cannot combine with previous '%s' declaration specifier")
DIAG(err_invalid_sign_spec, ERROR,
     "'%s' cannot be signed or unsigned")
DIAG(err_invalid_short_spec, ERROR,
     "'short %s' is invalid")
DIAG(err_invalid_long_spec, ERROR,
     "'long %s' is invalid")
DIAG(err_invalid_longlong_spec, ERROR,
     "'long long %s' is invalid")
DIAG(err_invalid_complex_spec, ERROR,
     "'_Complex %s' is invalid")
DIAG(err_invalid_thread_spec, ERROR,
     "'__thread %s' is invalid")
DIAG(err_ellipsis_first_arg, ERROR,
     "ISO C requires a named argument before '...'")
DIAG(err_unspecified_vla_size_with_static, ERROR,
     "'static' may not be used with an unspecified variable length array size")

#undef DIAG
