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}0">;
60def err_invalid_string_udl : Error<
61  "string literal with user-defined suffix cannot be used here">;
62def err_invalid_character_udl : Error<
63  "character literal with user-defined suffix cannot be used here">;
64def err_invalid_numeric_udl : Error<
65  "numeric literal with user-defined suffix cannot be used here">;
66def warn_pragma_debug_missing_argument : Warning<
67  "missing argument to debug command '%0'">, InGroup<IgnoredPragmas>;
68def warn_pragma_debug_unexpected_argument : Warning<
69  "unexpected argument to debug command">, InGroup<IgnoredPragmas>;
70
71}
72
73// Parse && Sema
74
75let CategoryName = "Parse Issue" in {
76
77def err_expected : Error<"expected %0">;
78def err_expected_either : Error<"expected %0 or %1">;
79def err_expected_after : Error<"expected %1 after %0">;
80
81def err_param_redefinition : Error<"redefinition of parameter %0">;
82def warn_method_param_redefinition : Warning<"redefinition of method parameter %0">;
83def warn_method_param_declaration : Warning<"redeclaration of method parameter %0">,
84  InGroup<DuplicateArgDecl>, DefaultIgnore;
85def err_invalid_storage_class_in_func_decl : Error<
86  "invalid storage class specifier in function declarator">;
87def err_expected_namespace_name : Error<"expected namespace name">;
88def ext_variadic_templates : ExtWarn<
89  "variadic templates are a C++11 extension">, InGroup<CXX11>;
90def warn_cxx98_compat_variadic_templates :
91  Warning<"variadic templates are incompatible with C++98">,
92  InGroup<CXX98Compat>, DefaultIgnore;
93def err_default_special_members : Error<
94  "only special member functions %select{|and comparison operators }0"
95  "may be defaulted">;
96def err_deleted_non_function : Error<
97  "only functions can have deleted definitions">;
98def err_module_not_found : Error<"module '%0' not found">, DefaultFatal;
99def err_module_not_built : Error<"could not build module '%0'">, DefaultFatal;
100def err_module_build_disabled: Error<
101  "module '%0' is needed but has not been provided, and implicit use of module "
102  "files is disabled">, DefaultFatal;
103def err_module_unavailable : Error<
104  "module '%0' %select{is incompatible with|requires}1 feature '%2'">;
105def err_module_header_missing : Error<
106  "%select{|umbrella }0header '%1' not found">;
107def remark_module_lock_failure : Remark<
108  "could not acquire lock file for module '%0': %1">, InGroup<ModuleBuild>;
109def remark_module_lock_timeout : Remark<
110  "timed out waiting to acquire lock file for module '%0'">, InGroup<ModuleBuild>;
111def err_module_shadowed : Error<"import of shadowed module '%0'">, DefaultFatal;
112def err_module_build_shadowed_submodule : Error<
113  "build a shadowed submodule '%0'">, DefaultFatal;
114def err_module_cycle : Error<"cyclic dependency in module '%0': %1">,
115  DefaultFatal;
116def err_module_prebuilt : Error<
117  "error in loading module '%0' from prebuilt module path">, DefaultFatal;
118def err_module_rebuild_finalized : Error<
119  "cannot rebuild module '%0' as it is already finalized">, DefaultFatal;
120def note_pragma_entered_here : Note<"#pragma entered here">;
121def note_decl_hiding_tag_type : Note<
122  "%1 %0 is hidden by a non-type declaration of %0 here">;
123def err_attribute_not_type_attr : Error<
124  "%0%select{ attribute|}1 cannot be applied to types">;
125def err_enum_template : Error<"enumeration cannot be a template">;
126
127def warn_cxx20_compat_consteval : Warning<
128  "'consteval' specifier is incompatible with C++ standards before C++20">,
129  InGroup<CXX20Compat>, DefaultIgnore;
130def warn_missing_type_specifier : Warning<
131  "type specifier missing, defaults to 'int'">,
132  InGroup<ImplicitInt>, DefaultIgnore;
133
134def ext_c_empty_initializer : Extension<
135  "use of an empty initializer is a C2x extension">, InGroup<C2x>;
136def warn_c2x_compat_empty_initializer : Warning<
137  "use of an empty initializer is incompatible with C standards before C2x">,
138  InGroup<CPre2xCompat>, DefaultIgnore;
139}
140
141let CategoryName = "Nullability Issue" in {
142
143def warn_nullability_duplicate : Warning<
144  "duplicate nullability specifier %0">,
145  InGroup<Nullability>;
146
147def warn_conflicting_nullability_attr_overriding_ret_types : Warning<
148  "conflicting nullability specifier on return types, %0 "
149  "conflicts with existing specifier %1">,
150  InGroup<Nullability>;
151
152def warn_conflicting_nullability_attr_overriding_param_types : Warning<
153  "conflicting nullability specifier on parameter types, %0 "
154  "conflicts with existing specifier %1">,
155  InGroup<Nullability>;
156
157def err_nullability_conflicting : Error<
158  "nullability specifier %0 conflicts with existing specifier %1">;
159
160def warn_incompatible_branch_protection_option: Warning <
161  "'-mbranch-protection=' option is incompatible with the '%0' architecture">,
162  InGroup<BranchProtection>;
163
164def warn_target_unsupported_branch_protection_attribute: Warning <
165  "ignoring the 'branch-protection' attribute because the '%0' architecture does not support it">,
166  InGroup<BranchProtection>;
167}
168
169// OpenCL Section 6.8.g
170def err_opencl_unknown_type_specifier : Error<
171  "%0 does not support the '%1' "
172  "%select{type qualifier|storage class specifier}2">;
173
174def warn_unknown_attribute_ignored : Warning<
175  "unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
176def warn_attribute_ignored : Warning<"%0 attribute ignored">,
177  InGroup<IgnoredAttributes>;
178def err_keyword_not_supported_on_target : Error<
179  "%0 is not supported on this target">;
180def err_use_of_tag_name_without_tag : Error<
181  "must use '%1' tag to refer to type %0%select{| in this scope}2">;
182
183def duplicate_declspec : TextSubstitution<
184  "duplicate '%0' declaration specifier">;
185
186def ext_duplicate_declspec : Extension<"%sub{duplicate_declspec}0">,
187  InGroup<DuplicateDeclSpecifier>;
188def ext_warn_duplicate_declspec : ExtWarn<"%sub{duplicate_declspec}0">,
189  InGroup<DuplicateDeclSpecifier>;
190def warn_duplicate_declspec : Warning<"%sub{duplicate_declspec}0">,
191  InGroup<DuplicateDeclSpecifier>;
192
193def err_duplicate_declspec : Error<"%sub{duplicate_declspec}0">;
194
195def err_friend_decl_spec : Error<"'%0' is invalid in friend declarations">;
196
197def err_invalid_member_in_interface : Error<
198  "%select{data member |non-public member function |static member function |"
199          "user-declared constructor|user-declared destructor|operator |"
200          "nested class }0%1 is not permitted within an interface type">;
201
202def err_attribute_uuid_malformed_guid : Error<
203  "uuid attribute contains a malformed GUID">;
204
205// Sema && Lex
206def ext_c99_longlong : Extension<
207  "'long long' is an extension when C99 mode is not enabled">,
208  InGroup<LongLong>;
209def ext_cxx11_longlong : Extension<
210  "'long long' is a C++11 extension">,
211  InGroup<CXX11LongLong>;
212def warn_cxx98_compat_longlong : Warning<
213  "'long long' is incompatible with C++98">,
214  InGroup<CXX98CompatPedantic>, DefaultIgnore;
215def ext_cxx23_size_t_suffix : ExtWarn<
216  "'size_t' suffix for literals is a C++23 extension">,
217  InGroup<CXX23>;
218def warn_cxx20_compat_size_t_suffix : Warning<
219  "'size_t' suffix for literals is incompatible with C++ standards before "
220  "C++23">, InGroup<CXXPre23Compat>, DefaultIgnore;
221def err_cxx23_size_t_suffix: Error<
222  "'size_t' suffix for literals is a C++23 feature">;
223def err_size_t_literal_too_large: Error<
224  "%select{signed |}0'size_t' literal is out of range of possible "
225  "%select{signed |}0'size_t' values">;
226def ext_c2x_bitint_suffix : ExtWarn<
227  "'_BitInt' suffix for literals is a C2x extension">,
228  InGroup<C2x>;
229def warn_c2x_compat_bitint_suffix : Warning<
230  "'_BitInt' suffix for literals is incompatible with C standards before C2x">,
231  InGroup<CPre2xCompat>, DefaultIgnore;
232def err_integer_literal_too_large : Error<
233  "integer literal is too large to be represented in any %select{signed |}0"
234  "integer type">;
235def ext_integer_literal_too_large_for_signed : ExtWarn<
236  "integer literal is too large to be represented in a signed integer type, "
237  "interpreting as unsigned">,
238  InGroup<ImplicitlyUnsignedLiteral>;
239def warn_old_implicitly_unsigned_long : Warning<
240  "integer literal is too large to be represented in type 'long', "
241  "interpreting as 'unsigned long' per C89; this literal will "
242  "%select{have type 'long long'|be ill-formed}0 in C99 onwards">,
243  InGroup<C99Compat>;
244def warn_old_implicitly_unsigned_long_cxx : Warning<
245  "integer literal is too large to be represented in type 'long', "
246  "interpreting as 'unsigned long' per C++98; this literal will "
247  "%select{have type 'long long'|be ill-formed}0 in C++11 onwards">,
248  InGroup<CXX11Compat>;
249def ext_old_implicitly_unsigned_long_cxx : ExtWarn<
250  "integer literal is too large to be represented in type 'long' and is "
251  "subject to undefined behavior under C++98, interpreting as 'unsigned long'; "
252  "this literal will %select{have type 'long long'|be ill-formed}0 "
253  "in C++11 onwards">,
254  InGroup<CXX11Compat>;
255def ext_clang_enable_if : Extension<"'enable_if' is a clang extension">,
256                          InGroup<GccCompat>;
257def ext_clang_diagnose_if : Extension<"'diagnose_if' is a clang extension">,
258                            InGroup<GccCompat>;
259def err_too_large_for_fixed_point : Error<
260  "this value is too large for this fixed point type">;
261def err_fixed_point_not_enabled : Error<"compile with "
262  "'-ffixed-point' to enable fixed point types">;
263def err_unimplemented_conversion_with_fixed_point_type : Error<
264  "conversion between fixed point and %0 is not yet supported">;
265
266// SEH
267def err_seh_expected_handler : Error<
268  "expected '__except' or '__finally' block">;
269def err_seh___except_block : Error<
270  "%0 only allowed in __except block or filter expression">;
271def err_seh___except_filter : Error<
272  "%0 only allowed in __except filter expression">;
273def err_seh___finally_block : Error<
274  "%0 only allowed in __finally block">;
275
276// Sema && AST
277def note_invalid_subexpr_in_const_expr : Note<
278  "subexpression not valid in a constant expression">;
279def note_constexpr_invalid_template_arg : Note<
280  "%select{pointer|reference}0 to %select{|subobject of }1"
281  "%select{type_info object|string literal|temporary object|"
282  "predefined '%3' variable}2 is not allowed in a template argument">;
283def err_constexpr_invalid_template_arg : Error<
284  note_constexpr_invalid_template_arg.Summary>;
285
286// Sema && Frontend
287let CategoryName = "Inline Assembly Issue" in {
288def err_asm_invalid_type_in_input : Error<
289  "invalid type %0 in asm input for constraint '%1'">;
290
291def err_asm_invalid_type : Error<
292  "invalid type %0 in asm %select{input|output}1">;
293
294def err_ms_asm_bitfield_unsupported : Error<
295  "an inline asm block cannot have an operand which is a bit-field">;
296
297def warn_stack_clash_protection_inline_asm : Warning<
298  "unable to protect inline asm that clobbers stack pointer against stack "
299  "clash">, InGroup<DiagGroup<"stack-protector">>;
300
301def warn_slh_does_not_support_asm_goto : Warning<
302  "speculative load hardening does not protect functions with asm goto">,
303  InGroup<DiagGroup<"slh-asm-goto">>;
304}
305
306// Sema && Serialization
307def warn_dup_category_def : Warning<
308  "duplicate definition of category %1 on interface %0">,
309  InGroup<DiagGroup<"objc-duplicate-category-definition">>;
310
311// Targets
312
313def err_target_unknown_triple : Error<
314  "unknown target triple '%0'">;
315def err_target_unknown_cpu : Error<"unknown target CPU '%0'">;
316def note_valid_options : Note<"valid target CPU values are: %0">;
317def err_target_unsupported_cpu_for_micromips : Error<
318  "micromips is not supported for target CPU '%0'">;
319def err_target_unknown_abi : Error<"unknown target ABI '%0'">;
320def err_target_unsupported_abi : Error<"ABI '%0' is not supported on CPU '%1'">;
321def err_target_unsupported_abi_for_triple : Error<
322  "ABI '%0' is not supported for '%1'">;
323def err_unsupported_abi_for_opt : Error<"'%0' can only be used with the '%1' ABI">;
324def err_mips_fp64_req : Error<
325    "'%0' can only be used if the target supports the mfhc1 and mthc1 instructions">;
326def err_target_unknown_fpmath : Error<"unknown FP unit '%0'">;
327def err_target_unsupported_fpmath : Error<
328    "the '%0' unit is not supported with this instruction set">;
329def err_target_unsupported_unaligned : Error<
330  "the %0 sub-architecture does not support unaligned accesses">;
331def err_target_unsupported_execute_only : Error<
332  "execute only is not supported for the %0 sub-architecture">;
333def err_target_unsupported_tp_hard : Error<
334  "hardware TLS register is not supported for the %0 sub-architecture">;
335def err_target_unsupported_mcmse : Error<
336  "-mcmse is not supported for %0">;
337def err_opt_not_valid_with_opt : Error<
338  "option '%0' cannot be specified with '%1'">;
339def err_opt_not_valid_without_opt : Error<
340  "option '%0' cannot be specified without '%1'">;
341def err_opt_not_valid_on_target : Error<
342  "option '%0' cannot be specified on this target">;
343def err_invalid_feature_combination : Error<
344  "invalid feature combination: %0">;
345def warn_target_unrecognized_env : Warning<
346  "mismatch between architecture and environment in target triple '%0'; did you mean '%1'?">,
347  InGroup<InvalidCommandLineArgument>;
348
349// Source manager
350def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;
351def err_file_modified : Error<
352  "file '%0' modified since it was first processed">, DefaultFatal;
353def err_file_too_large : Error<
354  "sorry, unsupported: file '%0' is too large for Clang to process">;
355def err_include_too_large : Error<
356  "sorry, this include generates a translation unit too large for"
357  " Clang to process.">, DefaultFatal;
358def err_unsupported_bom : Error<"%0 byte order mark detected in '%1', but "
359  "encoding is not supported">, DefaultFatal;
360def err_unable_to_rename_temp : Error<
361  "unable to rename temporary '%0' to output file '%1': '%2'">;
362def err_unable_to_make_temp : Error<
363  "unable to make temporary file: %0">;
364def remark_sloc_usage : Remark<
365  "source manager location address space usage:">,
366  InGroup<DiagGroup<"sloc-usage">>, DefaultRemark, ShowInSystemHeader;
367def note_total_sloc_usage : Note<
368  "%0B in local locations, %1B in locations loaded from AST files, for a total "
369  "of %2B (%3%% of available space)">;
370def note_file_sloc_usage : Note<
371  "file entered %0 time%s0 using %1B of space"
372  "%plural{0:|: plus %2B for macro expansions}2">;
373def note_file_misc_sloc_usage : Note<
374  "%0 additional files entered using a total of %1B of space">;
375
376// Modules
377def err_module_format_unhandled : Error<
378  "no handler registered for module format '%0'">, DefaultFatal;
379
380// TransformActions
381// TODO: Use a custom category name to distinguish rewriter errors.
382def err_mt_message : Error<"[rewriter] %0">, SuppressInSystemHeader;
383def warn_mt_message : Warning<"[rewriter] %0">;
384def note_mt_message : Note<"[rewriter] %0">;
385
386// ARCMigrate
387def warn_arcmt_nsalloc_realloc : Warning<"[rewriter] call returns pointer to GC managed memory; it will become unmanaged in ARC">;
388def err_arcmt_nsinvocation_ownership : Error<"NSInvocation's %0 is not safe to be used with an object with ownership other than __unsafe_unretained">;
389
390// C++ for OpenCL.
391def err_openclcxx_not_supported : Error<
392  "'%0' is not supported in C++ for OpenCL">;
393
394// HIP
395def warn_ignored_hip_only_option : Warning<
396  "'%0' is ignored since it is only supported for HIP">,
397  InGroup<HIPOnly>;
398
399// OpenMP
400def err_omp_more_one_clause : Error<
401  "directive '#pragma omp %0' cannot contain more than one '%1' clause%select{| with '%3' name modifier| with 'source' dependence}2">;
402def err_omp_required_clause : Error<
403  "directive '#pragma omp %0' requires the '%1' clause">;
404
405// Static Analyzer Core
406def err_unknown_analyzer_checker_or_package : Error<
407    "no analyzer checkers or packages are associated with '%0'">;
408def note_suggest_disabling_all_checkers : Note<
409    "use -analyzer-disable-all-checks to disable all static analyzer checkers">;
410
411// Poison system directories.
412def warn_poison_system_directories : Warning <
413  "include location '%0' is unsafe for cross-compilation">,
414  InGroup<DiagGroup<"poison-system-directories">>, DefaultIgnore;
415
416def warn_opencl_unsupported_core_feature : Warning<
417  "%0 is a core feature in %select{OpenCL C|C++ for OpenCL}1 version %2 but not supported on this target">,
418  InGroup<OpenCLCoreFeaturesDiagGroup>, DefaultIgnore;
419
420def err_opencl_extension_and_feature_differs : Error<
421  "options %0 and %1 are set to different values">;
422def err_opencl_feature_requires : Error<
423  "feature %0 requires support of %1 feature">;
424}
425