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