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_c23_bitint_suffix : ExtWarn<
233  "'_BitInt' suffix for literals is a C23 extension">,
234  InGroup<C23>;
235def warn_c23_compat_bitint_suffix : Warning<
236  "'_BitInt' suffix for literals is incompatible with C standards before C23">,
237  InGroup<CPre23Compat>, DefaultIgnore;
238def err_integer_literal_too_large : Error<
239  "integer literal is too large to be represented in any %select{signed |}0"
240  "integer type">;
241def ext_integer_literal_too_large_for_signed : ExtWarn<
242  "integer literal is too large to be represented in a signed integer type, "
243  "interpreting as unsigned">,
244  InGroup<ImplicitlyUnsignedLiteral>;
245def warn_old_implicitly_unsigned_long : Warning<
246  "integer literal is too large to be represented in type 'long', "
247  "interpreting as 'unsigned long' per C89; this literal will "
248  "%select{have type 'long long'|be ill-formed}0 in C99 onwards">,
249  InGroup<C99Compat>;
250def warn_old_implicitly_unsigned_long_cxx : Warning<
251  "integer literal is too large to be represented in type 'long', "
252  "interpreting as 'unsigned long' per C++98; this literal will "
253  "%select{have type 'long long'|be ill-formed}0 in C++11 onwards">,
254  InGroup<CXX11Compat>;
255def ext_old_implicitly_unsigned_long_cxx : ExtWarn<
256  "integer literal is too large to be represented in type 'long' and is "
257  "subject to undefined behavior under C++98, interpreting as 'unsigned long'; "
258  "this literal will %select{have type 'long long'|be ill-formed}0 "
259  "in C++11 onwards">,
260  InGroup<CXX11Compat>;
261def ext_clang_enable_if : Extension<"'enable_if' is a clang extension">,
262                          InGroup<GccCompat>;
263def ext_clang_diagnose_if : Extension<"'diagnose_if' is a clang extension">,
264                            InGroup<GccCompat>;
265def err_too_large_for_fixed_point : Error<
266  "this value is too large for this fixed point type">;
267def err_unimplemented_conversion_with_fixed_point_type : Error<
268  "conversion between fixed point and %0 is not yet supported">;
269
270// SEH
271def err_seh_expected_handler : Error<
272  "expected '__except' or '__finally' block">;
273def err_seh___except_block : Error<
274  "%0 only allowed in __except block or filter expression">;
275def err_seh___except_filter : Error<
276  "%0 only allowed in __except filter expression">;
277def err_seh___finally_block : Error<
278  "%0 only allowed in __finally block">;
279
280// Sema && AST
281def note_invalid_subexpr_in_const_expr : Note<
282  "subexpression not valid in a constant expression">;
283def note_constexpr_invalid_template_arg : Note<
284  "%select{pointer|reference}0 to %select{|subobject of }1"
285  "%select{type_info object|string literal|temporary object|"
286  "predefined '%3' variable}2 is not allowed in a template argument">;
287def err_constexpr_invalid_template_arg : Error<
288  note_constexpr_invalid_template_arg.Summary>;
289
290// Sema && Frontend
291let CategoryName = "Inline Assembly Issue" in {
292def err_asm_invalid_type_in_input : Error<
293  "invalid type %0 in asm input for constraint '%1'">;
294
295def err_asm_invalid_type : Error<
296  "invalid type %0 in asm %select{input|output}1">;
297
298def err_ms_asm_bitfield_unsupported : Error<
299  "an inline asm block cannot have an operand which is a bit-field">;
300
301def warn_stack_clash_protection_inline_asm : Warning<
302  "unable to protect inline asm that clobbers stack pointer against stack "
303  "clash">, InGroup<DiagGroup<"stack-protector">>;
304
305def warn_slh_does_not_support_asm_goto : Warning<
306  "speculative load hardening does not protect functions with asm goto">,
307  InGroup<DiagGroup<"slh-asm-goto">>;
308}
309
310// Sema && Serialization
311def warn_dup_category_def : Warning<
312  "duplicate definition of category %1 on interface %0">,
313  InGroup<DiagGroup<"objc-duplicate-category-definition">>;
314
315// Targets
316
317def err_target_unknown_triple : Error<
318  "unknown target triple '%0'">;
319def err_target_unknown_cpu : Error<"unknown target CPU '%0'">;
320def note_valid_options : Note<"valid target CPU values are: %0">;
321def err_target_unsupported_cpu_for_micromips : Error<
322  "micromips is not supported for target CPU '%0'">;
323def err_target_unknown_abi : Error<"unknown target ABI '%0'">;
324def err_target_unsupported_abi : Error<"ABI '%0' is not supported on CPU '%1'">;
325def err_target_unsupported_abi_for_triple : Error<
326  "ABI '%0' is not supported for '%1'">;
327def err_unsupported_abi_for_opt : Error<"'%0' can only be used with the '%1' ABI">;
328def err_mips_fp64_req : Error<
329    "'%0' can only be used if the target supports the mfhc1 and mthc1 instructions">;
330def err_target_unknown_fpmath : Error<"unknown FP unit '%0'">;
331def err_target_unsupported_fpmath : Error<
332    "the '%0' unit is not supported with this instruction set">;
333def err_target_unsupported_unaligned : Error<
334  "the %0 sub-architecture does not support unaligned accesses">;
335def err_target_unsupported_execute_only : Error<
336  "execute only is not supported for the %0 sub-architecture">;
337def err_target_unsupported_tp_hard : Error<
338  "hardware TLS register is not supported for the %0 sub-architecture">;
339def err_target_unsupported_mcmse : Error<
340  "-mcmse is not supported for %0">;
341def err_opt_not_valid_with_opt : Error<
342  "option '%0' cannot be specified with '%1'">;
343def err_opt_not_valid_with_opt_on_target : Error<
344  "option '%0' cannot be specified with '%1' for the %2 sub-architecture">;
345def err_opt_not_valid_without_opt : Error<
346  "option '%0' cannot be specified without '%1'">;
347def err_opt_not_valid_on_target : Error<
348  "option '%0' cannot be specified on this target">;
349def err_invalid_feature_combination : Error<
350  "invalid feature combination: %0">;
351def warn_invalid_feature_combination : Warning<
352  "invalid feature combination: %0">, InGroup<DiagGroup<"invalid-feature-combination">>;
353def warn_target_unrecognized_env : Warning<
354  "mismatch between architecture and environment in target triple '%0'; did you mean '%1'?">,
355  InGroup<InvalidCommandLineArgument>;
356def warn_knl_knm_isa_support_removed : Warning<
357  "KNL, KNM related Intel Xeon Phi CPU's specific ISA's supports will be removed in LLVM 19.">,
358  InGroup<DiagGroup<"knl-knm-isa-support-removed">>;
359
360// Source manager
361def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;
362def err_file_modified : Error<
363  "file '%0' modified since it was first processed">, DefaultFatal;
364def err_file_too_large : Error<
365  "file '%0' is too large for Clang to process">;
366def err_sloc_space_too_large : Error<
367  "translation unit is too large for Clang to process: ran out of source locations">, DefaultFatal;
368def err_unsupported_bom : Error<"%0 byte order mark detected in '%1', but "
369  "encoding is not supported">, DefaultFatal;
370def err_unable_to_rename_temp : Error<
371  "unable to rename temporary '%0' to output file '%1': '%2'">;
372def err_unable_to_make_temp : Error<
373  "unable to make temporary file: %0">;
374def remark_sloc_usage : Remark<
375  "source manager location address space usage:">,
376  InGroup<DiagGroup<"sloc-usage">>, DefaultRemark, ShowInSystemHeader;
377def note_total_sloc_usage : Note<
378  "%0B in local locations, %1B in locations loaded from AST files, for a total "
379  "of %2B (%3%% of available space)">;
380def note_file_sloc_usage : Note<
381  "file entered %0 time%s0 using %1B of space"
382  "%plural{0:|: plus %2B for macro expansions}2">;
383def note_file_misc_sloc_usage : Note<
384  "%0 additional files entered using a total of %1B of space">;
385
386// Modules
387def err_module_format_unhandled : Error<
388  "no handler registered for module format '%0'">, DefaultFatal;
389
390// TransformActions
391// TODO: Use a custom category name to distinguish rewriter errors.
392def err_mt_message : Error<"[rewriter] %0">, SuppressInSystemHeader;
393def warn_mt_message : Warning<"[rewriter] %0">;
394def note_mt_message : Note<"[rewriter] %0">;
395
396// ARCMigrate
397def warn_arcmt_nsalloc_realloc : Warning<"[rewriter] call returns pointer to GC managed memory; it will become unmanaged in ARC">;
398def err_arcmt_nsinvocation_ownership : Error<"NSInvocation's %0 is not safe to be used with an object with ownership other than __unsafe_unretained">;
399
400// API notes
401def err_apinotes_message : Error<"%0">;
402def warn_apinotes_message : Warning<"%0">, InGroup<DiagGroup<"apinotes">>;
403def note_apinotes_message : Note<"%0">;
404
405class NonportablePrivateAPINotesPath  : Warning<
406  "private API notes file for module '%0' should be named "
407  "'%0_private.apinotes', not '%1'">;
408def warn_apinotes_private_case : NonportablePrivateAPINotesPath,
409  InGroup<DiagGroup<"nonportable-private-apinotes-path">>;
410def warn_apinotes_private_case_system : NonportablePrivateAPINotesPath,
411  DefaultIgnore, InGroup<DiagGroup<"nonportable-private-system-apinotes-path">>;
412
413// C++ for OpenCL.
414def err_openclcxx_not_supported : Error<
415  "'%0' is not supported in C++ for OpenCL">;
416
417// HIP
418def warn_ignored_hip_only_option : Warning<
419  "'%0' is ignored since it is only supported for HIP">,
420  InGroup<HIPOnly>;
421
422// OpenMP
423def err_omp_more_one_clause : Error<
424  "directive '#pragma omp %0' cannot contain more than one '%1' clause%select{| with '%3' name modifier| with 'source' dependence}2">;
425def err_omp_required_clause : Error<
426  "directive '#pragma omp %0' requires the '%1' clause">;
427
428// Static Analyzer Core
429def err_unknown_analyzer_checker_or_package : Error<
430    "no analyzer checkers or packages are associated with '%0'">;
431def note_suggest_disabling_all_checkers : Note<
432    "use -analyzer-disable-all-checks to disable all static analyzer checkers">;
433
434// Poison system directories.
435def warn_poison_system_directories : Warning <
436  "include location '%0' is unsafe for cross-compilation">,
437  InGroup<DiagGroup<"poison-system-directories">>, DefaultIgnore;
438
439def warn_opencl_unsupported_core_feature : Warning<
440  "%0 is a core feature in %select{OpenCL C|C++ for OpenCL}1 version %2 but not supported on this target">,
441  InGroup<OpenCLCoreFeaturesDiagGroup>, DefaultIgnore;
442
443def err_opencl_extension_and_feature_differs : Error<
444  "options %0 and %1 are set to different values">;
445def err_opencl_feature_requires : Error<
446  "feature %0 requires support of %1 feature">;
447
448def warn_throw_not_valid_on_target : Warning<
449  "target '%0' does not support exception handling;"
450  " 'throw' is assumed to be never reached">,
451  InGroup<OpenMPTargetException>;
452def warn_try_not_valid_on_target : Warning<
453  "target '%0' does not support exception handling;"
454  " 'catch' block is ignored">,
455  InGroup<OpenMPTargetException>;
456}
457