xref: /llvm-project/clang/include/clang/Basic/DiagnosticCommonKinds.td (revision e44c28f07ede2bd693e2372317880f57a635fa73)
1//==--- DiagnosticCommonKinds.td - common diagnostics ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9//===----------------------------------------------------------------------===//
10// Common Helpers
11//===----------------------------------------------------------------------===//
12
13let Component = "Common" in {
14
15// Substitutions.
16
17def select_constexpr_spec_kind : TextSubstitution<
18  "%select{<ERROR>|constexpr|consteval|constinit}0">;
19
20// Basic.
21
22def fatal_too_many_errors
23  : Error<"too many errors emitted, stopping now">, DefaultFatal;
24
25def warn_stack_exhausted : Warning<
26  "stack nearly exhausted; compilation time may suffer, and "
27  "crashes due to stack overflow are likely">,
28  InGroup<DiagGroup<"stack-exhausted">>, NoSFINAE;
29
30def note_declared_at : Note<"declared here">;
31def note_previous_definition : Note<"previous definition is here">;
32def note_previous_declaration : Note<"previous declaration is here">;
33def note_previous_implicit_declaration : Note<
34  "previous implicit declaration is here">;
35def note_previous_use : Note<"previous use is here">;
36def note_duplicate_case_prev : Note<"previous case defined here">;
37def note_forward_declaration : Note<"forward declaration of %0">;
38def note_type_being_defined : Note<
39  "definition of %0 is not complete until the closing '}'">;
40/// note_matching - this is used as a continuation of a previous diagnostic,
41/// e.g. to specify the '(' when we expected a ')'.
42def note_matching : Note<"to match this %0">;
43
44def note_using : Note<"using">;
45def note_possibility : Note<"one possibility">;
46def note_also_found : Note<"also found">;
47
48// Parse && Lex
49
50let CategoryName = "Lexical or Preprocessor Issue" in {
51
52def err_expected_colon_after_setter_name : Error<
53  "method name referenced in property setter attribute "
54  "must end with ':'">;
55def err_expected_string_literal : Error<"expected string literal "
56  "%select{in %1|for diagnostic message in static_assert|"
57          "for optional message in 'availability' attribute|"
58          "for %select{language name|source container name|USR}1 in "
59          "'external_source_symbol' attribute|"
60          "as argument of '%1' attribute}0">;
61
62def err_invalid_string_udl : Error<
63  "string literal with user-defined suffix cannot be used here">;
64def err_invalid_character_udl : Error<
65  "character literal with user-defined suffix cannot be used here">;
66def err_invalid_numeric_udl : Error<
67  "numeric literal with user-defined suffix cannot be used here">;
68def warn_pragma_debug_missing_argument : Warning<
69  "missing argument to debug command '%0'">, InGroup<IgnoredPragmas>;
70def warn_pragma_debug_unexpected_argument : Warning<
71  "unexpected argument to debug command">, InGroup<IgnoredPragmas>;
72
73def warn_fp_nan_inf_when_disabled : Warning<
74  "use of %select{infinity|NaN}0%select{| via a macro}1 is undefined behavior "
75  "due to the currently enabled floating-point options">,
76  InGroup<DiagGroup<"nan-infinity-disabled", [], NanInfDisabledDocs>>;
77}
78
79// Parse && Sema
80
81let CategoryName = "Parse Issue" in {
82
83def err_expected : Error<"expected %0">;
84def err_expected_either : Error<"expected %0 or %1">;
85def err_expected_after : Error<"expected %1 after %0">;
86
87def err_param_redefinition : Error<"redefinition of parameter %0">;
88def warn_method_param_redefinition : Warning<"redefinition of method parameter %0">;
89def warn_method_param_declaration : Warning<"redeclaration of method parameter %0">,
90  InGroup<DuplicateArgDecl>, DefaultIgnore;
91def err_invalid_storage_class_in_func_decl : Error<
92  "invalid storage class specifier in function declarator">;
93def err_expected_namespace_name : Error<"expected namespace name">;
94def ext_variadic_templates : ExtWarn<
95  "variadic templates are a C++11 extension">, InGroup<CXX11>;
96def warn_cxx98_compat_variadic_templates :
97  Warning<"variadic templates are incompatible with C++98">,
98  InGroup<CXX98Compat>, DefaultIgnore;
99def err_default_special_members : Error<
100  "only special member functions %select{|and comparison operators }0"
101  "may be defaulted">;
102def err_deleted_non_function : Error<
103  "only functions can have deleted definitions">;
104def err_module_not_found : Error<"module '%0' not found">, DefaultFatal;
105def err_module_not_built : Error<"could not build module '%0'">, DefaultFatal;
106def err_module_build_disabled: Error<
107  "module '%0' is needed but has not been provided, and implicit use of module "
108  "files is disabled">, DefaultFatal;
109def err_module_unavailable : Error<
110  "module '%0' %select{is incompatible with|requires}1 feature '%2'">;
111def err_module_header_missing : Error<
112  "%select{|umbrella }0header '%1' not found">;
113def remark_module_lock_failure : Remark<
114  "could not acquire lock file for module '%0': %1">, InGroup<ModuleBuild>;
115def remark_module_lock_timeout : Remark<
116  "timed out waiting to acquire lock file for module '%0'">, InGroup<ModuleBuild>;
117def err_module_shadowed : Error<"import of shadowed module '%0'">, DefaultFatal;
118def err_module_build_shadowed_submodule : Error<
119  "build a shadowed submodule '%0'">, DefaultFatal;
120def err_module_cycle : Error<"cyclic dependency in module '%0': %1">,
121  DefaultFatal;
122def err_module_prebuilt : Error<
123  "error in loading module '%0' from prebuilt module path">, DefaultFatal;
124def err_module_rebuild_finalized : Error<
125  "cannot rebuild module '%0' as it is already finalized">, DefaultFatal;
126def note_pragma_entered_here : Note<"#pragma entered here">;
127def note_decl_hiding_tag_type : Note<
128  "%1 %0 is hidden by a non-type declaration of %0 here">;
129def err_attribute_not_type_attr : Error<
130  "%0%select{ attribute|}1 cannot be applied to types">;
131def err_enum_template : Error<"enumeration cannot be a template">;
132
133def warn_cxx20_compat_consteval : Warning<
134  "'consteval' specifier is incompatible with C++ standards before C++20">,
135  InGroup<CXX20Compat>, DefaultIgnore;
136def warn_missing_type_specifier : Warning<
137  "type specifier missing, defaults to 'int'">,
138  InGroup<ImplicitInt>, DefaultIgnore;
139
140def ext_c_empty_initializer : Extension<
141  "use of an empty initializer is a C23 extension">, InGroup<C23>;
142def warn_c23_compat_empty_initializer : Warning<
143  "use of an empty initializer is incompatible with C standards before C23">,
144  InGroup<CPre23Compat>, DefaultIgnore;
145}
146
147let CategoryName = "Nullability Issue" in {
148
149def warn_nullability_duplicate : Warning<
150  "duplicate nullability specifier %0">,
151  InGroup<Nullability>;
152
153def warn_conflicting_nullability_attr_overriding_ret_types : Warning<
154  "conflicting nullability specifier on return types, %0 "
155  "conflicts with existing specifier %1">,
156  InGroup<Nullability>;
157
158def warn_conflicting_nullability_attr_overriding_param_types : Warning<
159  "conflicting nullability specifier on parameter types, %0 "
160  "conflicts with existing specifier %1">,
161  InGroup<Nullability>;
162
163def err_nullability_conflicting : Error<
164  "nullability specifier %0 conflicts with existing specifier %1">;
165
166def warn_incompatible_branch_protection_option: Warning <
167  "'-mbranch-protection=' option is incompatible with the '%0' architecture">,
168  InGroup<BranchProtection>;
169
170def warn_target_unsupported_branch_protection_attribute: Warning <
171  "ignoring the 'branch-protection' attribute because the '%0' architecture does not support it">,
172  InGroup<BranchProtection>;
173}
174
175// OpenCL Section 6.8.g
176def err_opencl_unknown_type_specifier : Error<
177  "%0 does not support the '%1' "
178  "%select{type qualifier|storage class specifier}2">;
179
180def warn_unknown_attribute_ignored : Warning<
181  "unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
182def warn_attribute_ignored : Warning<"%0 attribute ignored">,
183  InGroup<IgnoredAttributes>;
184def err_keyword_not_supported_on_target : Error<
185  "%0 is not supported on this target">;
186def err_use_of_tag_name_without_tag : Error<
187  "must use '%1' tag to refer to type %0%select{| in this scope}2">;
188
189def duplicate_declspec : TextSubstitution<
190  "duplicate '%0' declaration specifier">;
191
192def ext_duplicate_declspec : Extension<"%sub{duplicate_declspec}0">,
193  InGroup<DuplicateDeclSpecifier>;
194def ext_warn_duplicate_declspec : ExtWarn<"%sub{duplicate_declspec}0">,
195  InGroup<DuplicateDeclSpecifier>;
196def warn_duplicate_declspec : Warning<"%sub{duplicate_declspec}0">,
197  InGroup<DuplicateDeclSpecifier>;
198
199def err_duplicate_declspec : Error<"%sub{duplicate_declspec}0">;
200
201def err_friend_decl_spec : Error<"'%0' is invalid in friend declarations">;
202
203def err_invalid_member_in_interface : Error<
204  "%select{data member |non-public member function |static member function |"
205          "user-declared constructor|user-declared destructor|operator |"
206          "nested class }0%1 is not permitted within an interface type">;
207
208def err_attribute_uuid_malformed_guid : Error<
209  "uuid attribute contains a malformed GUID">;
210
211// Sema && Lex
212def ext_c99_longlong : Extension<
213  "'long long' is an extension when C99 mode is not enabled">,
214  InGroup<LongLong>;
215def ext_cxx11_longlong : Extension<
216  "'long long' is a C++11 extension">,
217  InGroup<CXX11LongLong>;
218def warn_cxx98_compat_longlong : Warning<
219  "'long long' is incompatible with C++98">,
220  InGroup<CXX98CompatPedantic>, DefaultIgnore;
221def ext_cxx23_size_t_suffix : ExtWarn<
222  "'size_t' suffix for literals is a C++23 extension">,
223  InGroup<CXX23>;
224def warn_cxx20_compat_size_t_suffix : Warning<
225  "'size_t' suffix for literals is incompatible with C++ standards before "
226  "C++23">, InGroup<CXXPre23Compat>, DefaultIgnore;
227def err_cxx23_size_t_suffix: Error<
228  "'size_t' suffix for literals is a C++23 feature">;
229def err_size_t_literal_too_large: Error<
230  "%select{signed |}0'size_t' literal is out of range of possible "
231  "%select{signed |}0'size_t' values">;
232def ext_cxx_bitint_suffix : Extension<
233  "'_BitInt' suffix for literals is a Clang extension">,
234  InGroup<BitIntExtension>;
235def ext_c23_bitint_suffix : ExtWarn<
236  "'_BitInt' suffix for literals is a C23 extension">,
237  InGroup<C23>;
238def warn_c23_compat_bitint_suffix : Warning<
239  "'_BitInt' suffix for literals is incompatible with C standards before C23">,
240  InGroup<CPre23Compat>, DefaultIgnore;
241def err_integer_literal_too_large : Error<
242  "integer literal is too large to be represented in any %select{signed |}0"
243  "integer type">;
244def ext_integer_literal_too_large_for_signed : ExtWarn<
245  "integer literal is too large to be represented in a signed integer type, "
246  "interpreting as unsigned">,
247  InGroup<ImplicitlyUnsignedLiteral>;
248def warn_old_implicitly_unsigned_long : Warning<
249  "integer literal is too large to be represented in type 'long', "
250  "interpreting as 'unsigned long' per C89; this literal will "
251  "%select{have type 'long long'|be ill-formed}0 in C99 onwards">,
252  InGroup<C99Compat>;
253def warn_old_implicitly_unsigned_long_cxx : Warning<
254  "integer literal is too large to be represented in type 'long', "
255  "interpreting as 'unsigned long' per C++98; this literal will "
256  "%select{have type 'long long'|be ill-formed}0 in C++11 onwards">,
257  InGroup<CXX11Compat>;
258def ext_old_implicitly_unsigned_long_cxx : ExtWarn<
259  "integer literal is too large to be represented in type 'long' and is "
260  "subject to undefined behavior under C++98, interpreting as 'unsigned long'; "
261  "this literal will %select{have type 'long long'|be ill-formed}0 "
262  "in C++11 onwards">,
263  InGroup<CXX11Compat>;
264def ext_clang_enable_if : Extension<"'enable_if' is a clang extension">,
265                          InGroup<GccCompat>;
266def ext_clang_diagnose_if : Extension<"'diagnose_if' is a clang extension">,
267                            InGroup<GccCompat>;
268def err_too_large_for_fixed_point : Error<
269  "this value is too large for this fixed point type">;
270def err_unimplemented_conversion_with_fixed_point_type : Error<
271  "conversion between fixed point and %0 is not yet supported">;
272
273def err_requires_positive_value : Error<
274  "%select{invalid value '%0'; must be positive|value '%0' is too large}1">;
275
276// SEH
277def err_seh_expected_handler : Error<
278  "expected '__except' or '__finally' block">;
279def err_seh___except_block : Error<
280  "%0 only allowed in __except block or filter expression">;
281def err_seh___except_filter : Error<
282  "%0 only allowed in __except filter expression">;
283def err_seh___finally_block : Error<
284  "%0 only allowed in __finally block">;
285
286// Sema && AST
287def note_invalid_subexpr_in_const_expr : Note<
288  "subexpression not valid in a constant expression">;
289def note_constexpr_invalid_template_arg : Note<
290  "%select{pointer|reference}0 to %select{|subobject of }1"
291  "%select{type_info object|string literal|temporary object|"
292  "predefined '%3' variable}2 is not allowed in a template argument">;
293def err_constexpr_invalid_template_arg : Error<
294  note_constexpr_invalid_template_arg.Summary>;
295
296// Sema && Frontend
297let CategoryName = "Inline Assembly Issue" in {
298def err_asm_invalid_type_in_input : Error<
299  "invalid type %0 in asm input for constraint '%1'">;
300
301def err_asm_invalid_type : Error<
302  "invalid type %0 in asm %select{input|output}1">;
303
304def err_ms_asm_bitfield_unsupported : Error<
305  "an inline asm block cannot have an operand which is a bit-field">;
306
307def warn_stack_clash_protection_inline_asm : Warning<
308  "unable to protect inline asm that clobbers stack pointer against stack "
309  "clash">, InGroup<DiagGroup<"stack-protector">>;
310
311def warn_slh_does_not_support_asm_goto : Warning<
312  "speculative load hardening does not protect functions with asm goto">,
313  InGroup<DiagGroup<"slh-asm-goto">>;
314}
315
316// Sema && Serialization
317def warn_dup_category_def : Warning<
318  "duplicate definition of category %1 on interface %0">,
319  InGroup<DiagGroup<"objc-duplicate-category-definition">>;
320
321// Targets
322
323def err_target_unknown_triple : Error<
324  "unknown target triple '%0'">;
325def err_target_unknown_cpu : Error<"unknown target CPU '%0'">;
326def note_valid_options : Note<"valid target CPU values are: %0">;
327def err_target_unsupported_cpu_for_micromips : Error<
328  "micromips is not supported for target CPU '%0'">;
329def err_target_unknown_abi : Error<"unknown target ABI '%0'">;
330def err_target_unsupported_abi : Error<"ABI '%0' is not supported on CPU '%1'">;
331def err_target_unsupported_abi_for_triple : Error<
332  "ABI '%0' is not supported for '%1'">;
333def err_unsupported_abi_for_opt : Error<"'%0' can only be used with the '%1' ABI">;
334def err_mips_fp64_req : Error<
335    "'%0' can only be used if the target supports the mfhc1 and mthc1 instructions">;
336def err_target_unknown_fpmath : Error<"unknown FP unit '%0'">;
337def err_target_unsupported_fpmath : Error<
338    "the '%0' unit is not supported with this instruction set">;
339def err_target_unsupported_unaligned : Error<
340  "the %0 sub-architecture does not support unaligned accesses">;
341def err_target_unsupported_execute_only : Error<
342  "execute only is not supported for the %0 sub-architecture">;
343def err_target_unsupported_tp_hard : Error<
344  "hardware TLS register is not supported for the %0 sub-architecture">;
345def err_target_unsupported_mcmse : Error<
346  "-mcmse is not supported for %0">;
347def err_opt_not_valid_with_opt : Error<
348  "option '%0' cannot be specified with '%1'">;
349def err_opt_not_valid_with_opt_on_target : Error<
350  "option '%0' cannot be specified with '%1' for the %2 sub-architecture">;
351def err_opt_not_valid_without_opt : Error<
352  "option '%0' cannot be specified without '%1'">;
353def err_opt_not_valid_on_target : Error<
354  "option '%0' cannot be specified on this target">;
355def err_invalid_feature_combination : Error<
356  "invalid feature combination: %0">;
357def warn_invalid_feature_combination : Warning<
358  "invalid feature combination: %0">, InGroup<DiagGroup<"invalid-feature-combination">>;
359def warn_target_unrecognized_env : Warning<
360  "mismatch between architecture and environment in target triple '%0'; did you mean '%1'?">,
361  InGroup<InvalidCommandLineArgument>;
362def err_target_unsupported_abi_with_fpu : Error<
363  "'%0' ABI is not supported with FPU">;
364
365def err_ppc_impossible_musttail: Error<
366  "'musttail' attribute for this call is impossible because %select{"
367  "long calls cannot be tail called on PPC|"
368  "indirect calls cannot be tail called on PPC|"
369  "external calls cannot be tail called on PPC}0"
370  >;
371def err_aix_musttail_unsupported: Error<
372  "'musttail' attribute is not supported on AIX">;
373
374// Source manager
375def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;
376def err_file_modified : Error<
377  "file '%0' modified since it was first processed">, DefaultFatal;
378def err_file_too_large : Error<
379  "file '%0' is too large for Clang to process">;
380def err_sloc_space_too_large : Error<
381  "translation unit is too large for Clang to process: ran out of source locations">, DefaultFatal;
382def err_unsupported_bom : Error<"%0 byte order mark detected in '%1', but "
383  "encoding is not supported">, DefaultFatal;
384def err_unable_to_rename_temp : Error<
385  "unable to rename temporary '%0' to output file '%1': '%2'">;
386def err_unable_to_make_temp : Error<
387  "unable to make temporary file: %0">;
388def remark_sloc_usage : Remark<
389  "source manager location address space usage:">,
390  InGroup<DiagGroup<"sloc-usage">>, DefaultRemark, ShowInSystemHeader;
391def note_total_sloc_usage : Note<
392  "%0B (%human0B) in local locations, %1B (%human1B) "
393  "in locations loaded from AST files, for a total of %2B (%human2B) "
394  "(%3%% of available space)">;
395def note_file_sloc_usage : Note<
396  "file entered %0 time%s0 using %1B (%human1B) of space"
397  "%plural{0:|: plus %2B (%human2B) for macro expansions}2">;
398def note_file_misc_sloc_usage : Note<
399  "%0 additional files entered using a total of %1B (%human1B) of space">;
400
401// Modules
402def err_module_format_unhandled : Error<
403  "no handler registered for module format '%0'">, DefaultFatal;
404
405// TransformActions
406// TODO: Use a custom category name to distinguish rewriter errors.
407def err_mt_message : Error<"[rewriter] %0">, SuppressInSystemHeader;
408def warn_mt_message : Warning<"[rewriter] %0">;
409def note_mt_message : Note<"[rewriter] %0">;
410
411// ARCMigrate
412def warn_arcmt_nsalloc_realloc : Warning<"[rewriter] call returns pointer to GC managed memory; it will become unmanaged in ARC">;
413def err_arcmt_nsinvocation_ownership : Error<"NSInvocation's %0 is not safe to be used with an object with ownership other than __unsafe_unretained">;
414
415// API notes
416def err_apinotes_message : Error<"%0">;
417def warn_apinotes_message : Warning<"%0">, InGroup<DiagGroup<"apinotes">>;
418def note_apinotes_message : Note<"%0">;
419
420class NonportablePrivateAPINotesPath  : Warning<
421  "private API notes file for module '%0' should be named "
422  "'%0_private.apinotes', not '%1'">;
423def warn_apinotes_private_case : NonportablePrivateAPINotesPath,
424  InGroup<DiagGroup<"nonportable-private-apinotes-path">>;
425def warn_apinotes_private_case_system : NonportablePrivateAPINotesPath,
426  DefaultIgnore, InGroup<DiagGroup<"nonportable-private-system-apinotes-path">>;
427
428// C++ for OpenCL.
429def err_openclcxx_not_supported : Error<
430  "'%0' is not supported in C++ for OpenCL">;
431
432// HIP
433def warn_ignored_hip_only_option : Warning<
434  "'%0' is ignored since it is only supported for HIP">,
435  InGroup<HIPOnly>;
436
437// OpenMP
438def err_omp_more_one_clause : Error<
439  "directive '#pragma omp %0' cannot contain more than one '%1' clause%select{| with '%3' name modifier| with 'source' dependence}2">;
440def err_omp_required_clause : Error<
441  "directive '#pragma omp %0' requires the '%1' clause">;
442
443// Static Analyzer Core
444def err_unknown_analyzer_checker_or_package : Error<
445    "no analyzer checkers or packages are associated with '%0'">;
446def note_suggest_disabling_all_checkers : Note<
447    "use -analyzer-disable-all-checks to disable all static analyzer checkers">;
448
449// Poison system directories.
450def warn_poison_system_directories : Warning <
451  "include location '%0' is unsafe for cross-compilation">,
452  InGroup<DiagGroup<"poison-system-directories">>, DefaultIgnore;
453
454def warn_opencl_unsupported_core_feature : Warning<
455  "%0 is a core feature in %select{OpenCL C|C++ for OpenCL}1 version %2 but not supported on this target">,
456  InGroup<OpenCLCoreFeaturesDiagGroup>, DefaultIgnore;
457
458def err_opencl_extension_and_feature_differs : Error<
459  "options %0 and %1 are set to different values">;
460def err_opencl_feature_requires : Error<
461  "feature %0 requires support of %1 feature">;
462
463def warn_throw_not_valid_on_target : Warning<
464  "target '%0' does not support exception handling;"
465  " 'throw' is assumed to be never reached">,
466  InGroup<OpenMPTargetException>;
467def warn_try_not_valid_on_target : Warning<
468  "target '%0' does not support exception handling;"
469  " 'catch' block is ignored">,
470  InGroup<OpenMPTargetException>;
471}
472