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;
126
127}
128
129let CategoryName = "Nullability Issue" in {
130
131def warn_nullability_duplicate : Warning<
132  "duplicate nullability specifier %0">,
133  InGroup<Nullability>;
134
135def warn_conflicting_nullability_attr_overriding_ret_types : Warning<
136  "conflicting nullability specifier on return types, %0 "
137  "conflicts with existing specifier %1">,
138  InGroup<Nullability>;
139
140def warn_conflicting_nullability_attr_overriding_param_types : Warning<
141  "conflicting nullability specifier on parameter types, %0 "
142  "conflicts with existing specifier %1">,
143  InGroup<Nullability>;
144
145def err_nullability_conflicting : Error<
146  "nullability specifier %0 conflicts with existing specifier %1">;
147
148}
149
150// OpenCL Section 6.8.g
151def err_opencl_unknown_type_specifier : Error<
152  "%select{OpenCL C|C++ for OpenCL}0 version %1 does not support the "
153  "'%2' %select{type qualifier|storage class specifier}3">;
154
155def warn_unknown_attribute_ignored : Warning<
156  "unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
157def err_use_of_tag_name_without_tag : Error<
158  "must use '%1' tag to refer to type %0%select{| in this scope}2">;
159
160def duplicate_declspec : TextSubstitution<
161  "duplicate '%0' declaration specifier">;
162
163def ext_duplicate_declspec : Extension<"%sub{duplicate_declspec}0">,
164  InGroup<DuplicateDeclSpecifier>;
165def ext_warn_duplicate_declspec : ExtWarn<"%sub{duplicate_declspec}0">,
166  InGroup<DuplicateDeclSpecifier>;
167def warn_duplicate_declspec : Warning<"%sub{duplicate_declspec}0">,
168  InGroup<DuplicateDeclSpecifier>;
169
170def err_duplicate_declspec : Error<"%sub{duplicate_declspec}0">;
171
172def err_friend_decl_spec : Error<"'%0' is invalid in friend declarations">;
173
174def err_invalid_member_in_interface : Error<
175  "%select{data member |non-public member function |static member function |"
176          "user-declared constructor|user-declared destructor|operator |"
177          "nested class }0%1 is not permitted within an interface type">;
178
179def err_attribute_uuid_malformed_guid : Error<
180  "uuid attribute contains a malformed GUID">;
181
182// Sema && Lex
183def ext_c99_longlong : Extension<
184  "'long long' is an extension when C99 mode is not enabled">,
185  InGroup<LongLong>;
186def ext_cxx11_longlong : Extension<
187  "'long long' is a C++11 extension">,
188  InGroup<CXX11LongLong>;
189def warn_cxx98_compat_longlong : Warning<
190  "'long long' is incompatible with C++98">,
191  InGroup<CXX98CompatPedantic>, DefaultIgnore;
192def ext_cxx2b_size_t_suffix : ExtWarn<
193  "'size_t' suffix for literals is a C++2b extension">,
194  InGroup<CXX2b>;
195def warn_cxx20_compat_size_t_suffix : Warning<
196  "'size_t' suffix for literals is incompatible with C++ standards before "
197  "C++2b">, InGroup<CXXPre2bCompat>, DefaultIgnore;
198def err_cxx2b_size_t_suffix: Error<
199  "'size_t' suffix for literals is a C++2b feature">;
200def err_size_t_literal_too_large: Error<
201  "%select{signed |}0'size_t' literal is out of range of possible "
202  "%select{signed |}0'size_t' values">;
203def err_integer_literal_too_large : Error<
204  "integer literal is too large to be represented in any %select{signed |}0"
205  "integer type">;
206def ext_integer_literal_too_large_for_signed : ExtWarn<
207  "integer literal is too large to be represented in a signed integer type, "
208  "interpreting as unsigned">,
209  InGroup<ImplicitlyUnsignedLiteral>;
210def warn_old_implicitly_unsigned_long : Warning<
211  "integer literal is too large to be represented in type 'long', "
212  "interpreting as 'unsigned long' per C89; this literal will "
213  "%select{have type 'long long'|be ill-formed}0 in C99 onwards">,
214  InGroup<C99Compat>;
215def warn_old_implicitly_unsigned_long_cxx : Warning<
216  "integer literal is too large to be represented in type 'long', "
217  "interpreting as 'unsigned long' per C++98; this literal will "
218  "%select{have type 'long long'|be ill-formed}0 in C++11 onwards">,
219  InGroup<CXX11Compat>;
220def ext_old_implicitly_unsigned_long_cxx : ExtWarn<
221  "integer literal is too large to be represented in type 'long' and is "
222  "subject to undefined behavior under C++98, interpreting as 'unsigned long'; "
223  "this literal will %select{have type 'long long'|be ill-formed}0 "
224  "in C++11 onwards">,
225  InGroup<CXX11Compat>;
226def ext_clang_enable_if : Extension<"'enable_if' is a clang extension">,
227                          InGroup<GccCompat>;
228def ext_clang_diagnose_if : Extension<"'diagnose_if' is a clang extension">,
229                            InGroup<GccCompat>;
230def err_too_large_for_fixed_point : Error<
231  "this value is too large for this fixed point type">;
232def err_fixed_point_not_enabled : Error<"compile with "
233  "'-ffixed-point' to enable fixed point types">;
234def err_unimplemented_conversion_with_fixed_point_type : Error<
235  "conversion between fixed point and %0 is not yet supported">;
236
237// SEH
238def err_seh_expected_handler : Error<
239  "expected '__except' or '__finally' block">;
240def err_seh___except_block : Error<
241  "%0 only allowed in __except block or filter expression">;
242def err_seh___except_filter : Error<
243  "%0 only allowed in __except filter expression">;
244def err_seh___finally_block : Error<
245  "%0 only allowed in __finally block">;
246
247// Sema && AST
248def note_invalid_subexpr_in_const_expr : Note<
249  "subexpression not valid in a constant expression">;
250def note_constexpr_invalid_template_arg : Note<
251  "%select{pointer|reference}0 to %select{|subobject of }1"
252  "%select{type_info object|string literal|temporary object|"
253  "predefined '%3' variable}2 is not allowed in a template argument">;
254def err_constexpr_invalid_template_arg : Error<
255  note_constexpr_invalid_template_arg.Text>;
256
257// Sema && Frontend
258let CategoryName = "Inline Assembly Issue" in {
259  def err_asm_invalid_type_in_input : Error<
260    "invalid type %0 in asm input for constraint '%1'">;
261
262  def err_asm_invalid_type : Error<
263    "invalid type %0 in asm %select{input|output}1">;
264
265  def warn_stack_clash_protection_inline_asm : Warning<
266    "Unable to protect inline asm that clobbers stack pointer against stack clash">,
267    InGroup<DiagGroup<"stack-protector">>;
268
269  def warn_slh_does_not_support_asm_goto
270      : Warning<"Speculative load hardening does not protect functions with "
271                "asm goto">,
272        InGroup<DiagGroup<"slh-asm-goto">>;
273}
274
275// Sema && Serialization
276def warn_dup_category_def : Warning<
277  "duplicate definition of category %1 on interface %0">;
278
279// Targets
280
281def err_target_unknown_triple : Error<
282  "unknown target triple '%0', please use -triple or -arch">;
283def err_target_unknown_cpu : Error<"unknown target CPU '%0'">;
284def note_valid_options : Note<"valid target CPU values are: %0">;
285def err_target_unsupported_cpu_for_micromips : Error<
286  "micromips is not supported for target CPU '%0'">;
287def err_target_unknown_abi : Error<"unknown target ABI '%0'">;
288def err_target_unsupported_abi : Error<"ABI '%0' is not supported on CPU '%1'">;
289def err_target_unsupported_abi_for_triple : Error<
290  "ABI '%0' is not supported for '%1'">;
291def err_unsupported_abi_for_opt : Error<"'%0' can only be used with the '%1' ABI">;
292def err_mips_fp64_req : Error<
293    "'%0' can only be used if the target supports the mfhc1 and mthc1 instructions">;
294def err_target_unknown_fpmath : Error<"unknown FP unit '%0'">;
295def err_target_unsupported_fpmath : Error<
296    "the '%0' unit is not supported with this instruction set">;
297def err_target_unsupported_unaligned : Error<
298  "the %0 sub-architecture does not support unaligned accesses">;
299def err_target_unsupported_execute_only : Error<
300  "execute only is not supported for the %0 sub-architecture">;
301def err_target_unsupported_mcmse : Error<
302  "-mcmse is not supported for %0">;
303def err_opt_not_valid_with_opt : Error<
304  "option '%0' cannot be specified with '%1'">;
305def err_opt_not_valid_without_opt : Error<
306  "option '%0' cannot be specified without '%1'">;
307def err_opt_not_valid_on_target : Error<
308  "option '%0' cannot be specified on this target">;
309
310// Source manager
311def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;
312def err_file_modified : Error<
313  "file '%0' modified since it was first processed">, DefaultFatal;
314def err_file_too_large : Error<
315  "sorry, unsupported: file '%0' is too large for Clang to process">;
316def err_include_too_large : Error<
317  "sorry, this include generates a translation unit too large for"
318  " Clang to process.">, DefaultFatal;
319def err_unsupported_bom : Error<"%0 byte order mark detected in '%1', but "
320  "encoding is not supported">, DefaultFatal;
321def err_unable_to_rename_temp : Error<
322  "unable to rename temporary '%0' to output file '%1': '%2'">;
323def err_unable_to_make_temp : Error<
324  "unable to make temporary file: %0">;
325
326// Modules
327def err_module_format_unhandled : Error<
328  "no handler registered for module format '%0'">, DefaultFatal;
329
330// TransformActions
331// TODO: Use a custom category name to distinguish rewriter errors.
332def err_mt_message : Error<"[rewriter] %0">, SuppressInSystemHeader;
333def warn_mt_message : Warning<"[rewriter] %0">;
334def note_mt_message : Note<"[rewriter] %0">;
335
336// ARCMigrate
337def warn_arcmt_nsalloc_realloc : Warning<"[rewriter] call returns pointer to GC managed memory; it will become unmanaged in ARC">;
338def err_arcmt_nsinvocation_ownership : Error<"NSInvocation's %0 is not safe to be used with an object with ownership other than __unsafe_unretained">;
339
340// C++ for OpenCL.
341def err_openclcxx_not_supported : Error<
342  "'%0' is not supported in C++ for OpenCL">;
343
344// HIP
345def warn_ignored_hip_only_option : Warning<
346  "'%0' is ignored since it is only supported for HIP">,
347  InGroup<HIPOnly>;
348
349// OpenMP
350def err_omp_more_one_clause : Error<
351  "directive '#pragma omp %0' cannot contain more than one '%1' clause%select{| with '%3' name modifier| with 'source' dependence}2">;
352def err_omp_required_clause : Error<
353  "directive '#pragma omp %0' requires the '%1' clause">;
354
355// Static Analyzer Core
356def err_unknown_analyzer_checker_or_package : Error<
357    "no analyzer checkers or packages are associated with '%0'">;
358def note_suggest_disabling_all_checkers : Note<
359    "use -analyzer-disable-all-checks to disable all static analyzer checkers">;
360
361// Poison system directories.
362def warn_poison_system_directories : Warning <
363  "include location '%0' is unsafe for cross-compilation">,
364  InGroup<DiagGroup<"poison-system-directories">>, DefaultIgnore;
365
366def warn_opencl_unsupported_core_feature : Warning<
367  "%0 is a core feature in %select{OpenCL C|C++ for OpenCL}1 version %2 but not supported on this target">,
368  InGroup<OpenCLCoreFeaturesDiagGroup>, DefaultIgnore;
369
370def err_opencl_extension_and_feature_differs : Error<
371  "options %0 and %1 are set to different values">;
372def err_opencl_feature_requires : Error<
373  "feature %0 requires support of %1 feature">;
374}
375