xref: /aosp_15_r20/external/emboss/compiler/front_end/reserved_words (revision 99e0aae7469b87d12f0ad23e61142c2d74c1ef70)
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Reserved words for Emboss.
16#
17# In the interest of avoiding problems during codegen, Emboss disallows fields,
18# types, and enum values that would collide with reserved words from a number
19# of languages.  This (mostly) avoids cases where the back-end code generator
20# would want to emit a field accessor with the same name as a keyword.  (Proto,
21# for example, handles this case by appending "_" to the field name if it
22# collides with a keyword; however, this is not documented, and Proto still
23# breaks if you happen to have fields named "struct" and "struct_" in the same
24# message.)
25#
26# Emboss reserves words from many languages, on the off chance that they will
27# someday have code generators, but there is an emphasis on systems languages
28# (such as C), hardware definition languages (such as Verilog), and languages
29# which can easily be used for handling binary data (such as Erlang).
30#
31# Non-blank/comment lines in this file take one of two forms:
32#
33# -- Source
34# word
35#
36# e.g.:
37#
38# -- C
39# int
40# long
41# _Bool  # C99
42#
43# -- Verilog
44# always
45# case
46#
47# A word may appear in multiple language sections.  The first language name for
48# a word will be used in error messages when names matching that word are
49# found.
50
51# TODO(bolms): There still needs to be a way to override field names in
52# generated code.  This list is *not* a complete list of every possible
53# reserved word -- such a list is impossible, given that language designers
54# continue to add new keywords to existing languages, new languages pop up,
55# standards such as POSIX reserve huge swathes of namespace for future
56# expansion (i.e., anything starting with E[A-Z0-9]), and different C and C++
57# code bases may have custom preprocessor macros that collide with *anything*.
58
59-- C
60asm
61auto
62break
63case
64char
65const
66continue
67default
68do
69double
70else
71extern
72float
73for
74fortran
75goto
76if
77inline  # C99
78int
79long
80register
81restrict  # C99
82return
83short
84signed
85sizeof
86static
87switch
88typedef
89unsigned
90void
91volatile
92while
93_Alignas  # C11
94_Alignof  # C11
95_Atomic  # C11
96_Bool  # C99
97_Complex  # C99
98_Generic  # C11
99_Imaginary  # C99
100_Noreturn  # C11
101_Pragma  # C99
102_Static_assert  # C11
103_Thread_local  # C11
104
105# The following are *macros* defined in the C standard library.  For the most
106# part, I do not think banning these will inconvenience many people.
107
108# <assert.h>
109NDEBUG
110static_assert
111assert
112
113# <complex.h>
114__STDC_NO_COMPLEX__
115complex
116_Complex_I
117imaginary
118_Imaginary_I
119I
120CMPLX
121CMPLXF
122CMPLXL
123
124# <errno.h>
125errno
126EDOM
127EILSEQ
128ERANGE
129
130# <fenv.h>
131FE_DIVBYZERO
132FE_INEXACT
133FE_INVALID
134FE_OVERFLOW
135FE_UNDERFLOW
136FE_ALL_EXCEPT
137FE_DOWNWARD
138FE_TONEAREST
139FE_TOWARDZERO
140FE_UPWARD
141FE_DFL_ENV
142
143# <float.h>
144FLT_ROUNDS
145FLT_EVAL_METHOD
146FLT_HAS_SUBNORM
147DBL_HAS_SUBNORM
148LDBL_HAS_SUBNORM
149FLT_RADIX
150FLT_MANT_DIG
151DBL_MANT_DIG
152LDBL_MANT_DIG
153FLT_DECIMAL_DIG
154DBL_DECIMAL_DIG
155LDBL_DECIMAL_DIG
156DECIMAL_DIG
157FLT_DIG
158DBL_DIG
159LDBL_DIG
160FLT_MIN_EXP
161DBL_MIN_EXP
162LDBL_MIN_EXP
163FLT_MIN_10_EXP
164DBL_MIN_10_EXP
165LDBL_MIN_10_EXP
166FLT_MAX_EXP
167DBL_MAX_EXP
168LDBL_MAX_EXP
169FLT_MAX_10_EXP
170DBL_MAX_10_EXP
171LDBL_MAX_10_EXP
172FLT_MAX
173DBL_MAX
174LDBL_MAX
175FLT_EPSILON
176DBL_EPSILON
177LDBL_EPSILON
178FLT_MIN
179DBL_MIN
180LDBL_MIN
181FLT_TRUE_MIN
182DBL_TRUE_MIN
183LDBL_TRUE_MIN
184
185# <iso646.h>
186# These are not frequently used in real C code, but then, it is hard to think
187# of a good reason to use these as field names.
188and
189and_eq
190bitand
191bitor
192compl
193not
194not_eq
195or
196or_eq
197xor
198xor_eq
199
200# <limits.h>
201CHAR_BIT
202SCHAR_MIN
203SCHAR_MAX
204UCHAR_MAX
205CHAR_MIN
206CHAR_MAX
207MB_LEN_MAX
208SHRT_MIN
209SHRT_MAX
210USHRT_MAX
211INT_MIN
212INT_MAX
213UINT_MAX
214LONG_MIN
215LONG_MAX
216ULONG_MAX
217LLONG_MIN
218LLONG_MAX
219ULLONG_MAX
220
221# <locale.h>
222NULL
223LC_ALL
224LC_COLLATE
225LC_CTYPE
226LC_MONETARY
227LC_NUMERIC
228LC_TIME
229
230# <math.h>
231HUGE_VAL
232HUGE_VALF
233HUGE_VALL
234INFINITY
235NAN
236FP_INFINITE
237FP_NAN
238FP_NORMAL
239FP_SUBNORMAL
240FP_ZERO
241FP_FAST_FMA
242FP_FAST_FMAF
243FP_FAST_FMAL
244FP_ILOGB0
245FP_ILOGBNAN
246MATH_ERRNO
247MATH_ERREXCEPT
248math_errhandling
249fpclassify
250isfinite
251isinf
252isnan
253isnormal
254signbit
255isgreater
256isgreaterequal
257isless
258islessequal
259islessgreater
260isunordered
261
262# <setjmp.h>
263setjmp
264# Oddly, setjmp is a macro, but longjmp is not.
265
266# <signal.h>
267SIG_DFL
268SIG_ERR
269SIG_IGN
270SIGABRT
271SIGFPE
272SIGILL
273SIGINT
274SIGSEGV
275SIGTERM
276
277# <stdalign.h>
278alignas
279__alignas_is_defined
280
281# <stdarg.h>
282va_arg
283va_copy
284va_end
285va_start
286
287# <stdatomic.h>
288__STDC_NO_ATOMICS__
289ATOMIC_BOOL_LOCK_FREE
290ATOMIC_CHAR_LOCK_FREE
291ATOMIC_CHAR16_T_LOCK_FREE
292ATOMIC_CHAR32_T_LOCK_FREE
293ATOMIC_WCHAR_T_LOCK_FREE
294ATOMIC_SHORT_LOCK_FREE
295ATOMIC_INT_LOCK_FREE
296ATOMIC_LONG_LOCK_FREE
297ATOMIC_LLONG_LOCK_FREE
298ATOMIC_POINTER_LOCK_FREE
299ATOMIC_FLAG_INIT
300ATOMIC_VAR_INIT
301# Many of the following are listed by the standard as "generic functions"
302# instead of explicitly calling them out as macros.
303atomic_init
304kill_dependency
305atomic_is_lock_free
306atomic_store
307atomic_store_explicit
308atomic_load
309atomic_load_explicit
310atomic_exchange
311atomic_exchange_explicit
312atomic_compare_exchange_strong
313atomic_compare_exchange_strong_explicit
314atomic_compare_exchange_weak
315atomic_compare_exchange_weak_explicit
316atomic_fetch_add
317atomic_fetch_sub
318atomic_fetch_or
319atomic_fetch_xor
320atomic_fetch_and
321atomic_fetch_add_explicit
322atomic_fetch_sub_explicit
323atomic_fetch_or_explicit
324atomic_fetch_xor_explicit
325atomic_fetch_and_explicit
326
327# <stdbool.h>
328bool
329__bool_true_false_are_defined
330
331# <stddef.h>
332NULL
333offsetof
334
335# <stdint.h>
336INT16_C
337INT16_MAX
338INT16_MIN
339INT32_C
340INT32_MAX
341INT32_MIN
342INT64_C
343INT64_MAX
344INT64_MIN
345INT8_C
346INT8_MAX
347INT8_MIN
348INT_FAST16_MAX
349INT_FAST16_MIN
350INT_FAST32_MAX
351INT_FAST32_MIN
352INT_FAST64_MAX
353INT_FAST64_MIN
354INT_FAST8_MAX
355INT_FAST8_MIN
356INT_LEAST16_MAX
357INT_LEAST16_MIN
358INT_LEAST32_MAX
359INT_LEAST32_MIN
360INT_LEAST64_MAX
361INT_LEAST64_MIN
362INT_LEAST8_MAX
363INT_LEAST8_MIN
364INTMAX_C
365INTMAX_MAX
366INTMAX_MIN
367INTPTR_MAX
368INTPTR_MIN
369PTRDIFF_MAX
370PTRDIFF_MIN
371SIG_ATOMIC_MAX
372SIG_ATOMIC_MIN
373SIZE_MAX
374UINT16_C
375UINT16_MAX
376UINT32_C
377UINT32_MAX
378UINT64_C
379UINT64_MAX
380UINT8_C
381UINT8_MAX
382UINT_FAST16_MAX
383UINT_FAST32_MAX
384UINT_FAST64_MAX
385UINT_FAST8_MAX
386UINT_LEAST16_MAX
387UINT_LEAST32_MAX
388UINT_LEAST64_MAX
389UINT_LEAST8_MAX
390UINTMAX_C
391UINTMAX_MAX
392UINTPTR_MAX
393WCHAR_MAX
394WCHAR_MIN
395WINT_MAX
396WINT_MIN
397
398# <stdio.h>
399NULL
400_IOFBF
401_IOLBF
402_IONBF
403BUFSIZ
404EOF
405FOPEN_MAX
406FILENAME_MAX
407L_tmpnam
408SEEK_CUR
409SEEK_END
410SEEK_SET
411TMP_MAX
412stderr
413stdin
414stdout
415L_tmpnam_s
416TMP_MAX_S
417
418# <stdlib.h>
419NULL
420EXIT_FAILURE
421EXIT_SUCCESS
422RAND_MAX
423MB_CUR_MAX
424
425# <stdnoreturn.h>
426noreturn
427
428# <string.h>
429NULL
430
431# <tgmath.h>
432acos
433asin
434atan
435acosh
436asinh
437atanh
438cos
439sin
440tan
441cosh
442sinh
443tanh
444exp
445log
446pow
447sqrt
448fabs
449atan2
450cbrt
451ceil
452copysign
453erf
454erfc
455exp2
456expm1
457fdim
458floor
459fma
460fmax
461fmin
462fmod
463frexp
464hypot
465ilogb
466ldexp
467lgamma
468llrint
469llround
470log10
471log1p
472log2
473logb
474lrint
475lround
476nearbyint
477nextafter
478nexttoward
479remainder
480remquo
481rint
482round
483scalbn
484scalbln
485tgamma
486trunc
487carg
488cimag
489conj
490cproj
491creal
492
493# <threads.h>
494__STD_C_NO_THREADS__
495thread_local
496ONCE_FLAG_INIT
497TSS_DTOR_ITERATIONS
498
499# <time.h>
500NULL
501CLOCKS_PER_SEC
502TIME_UTC
503
504# <uchar.h> has no macros.
505
506# <wchar.h>
507NULL
508WCHAR_MAX
509WCHAR_MIN
510WEOF
511
512# <wctype.h>
513WEOF
514
515
516-- C++
517alignas # C++11
518alignof # C++11
519and
520and_eq
521asm
522auto
523bitand
524bitor
525bool
526break
527case
528catch
529char
530char16_t # C++11
531char32_t # C++11
532class
533compl
534concept # concepts TS
535const
536constexpr # C++11
537const_cast
538continue
539decltype # C++11
540default
541delete
542do
543double
544dynamic_cast
545else
546enum
547explicit
548export
549extern
550false
551float
552for
553friend
554goto
555if
556inline
557int
558long
559mutable
560namespace
561new
562noexcept # C++11
563not
564not_eq
565nullptr # C++11
566operator
567or
568or_eq
569private
570protected
571public
572register
573reinterpret_cast
574requires # concepts TS
575return
576short
577signed
578sizeof
579static
580static_assert # C++11
581static_cast
582struct
583switch
584template
585this
586thread_local # C++11
587throw
588true
589try
590typedef
591typeid
592typename
593union
594unsigned
595using
596virtual
597void
598volatile
599wchar_t
600while
601xor
602xor_eq
603
604
605-- System V libc
606# <math.h>
607DOMAIN
608SING
609OVERFLOW
610UNDERFLOW
611TLOSS
612PLOSS
613
614
615-- BSD libc
616# <math.h>
617MAXFLOAT
618M_E
619M_LOG2E
620M_LOG10E
621M_LN2
622M_LN10
623M_PI
624M_PI_2
625M_PI_4
626M_1_PI
627M_2_PI
628M_2_SQRTPI
629M_SQRT2
630M_SQRT1_2
631M_TWOPI
632M_3PI_4
633M_SQRTPI
634M_LN2LO
635M_LN2HI
636M_SQRT3
637M_IVLN10
638M_LOG2_E
639M_INVLN2
640
641
642-- Verilog
643# Verilog and System Verilog allow any keyword to be used as an identifier as
644# long as it is prefixed with '\' and followed by whitespace; e.g., \if .
645
646
647-- VHDL
648# VHDL allows any keyword to be used as an identifier by surrounding it with
649# '\' characters; e.g. \if\.
650
651
652-- Go
653break
654case
655chan
656const
657continue
658default
659defer
660else
661fallthrough
662for
663func
664go
665goto
666if
667import
668interface
669map
670package
671range
672return
673select
674switch
675type
676var
677
678
679-- Python 2
680# Python 2-only keywords.
681exec
682print
683
684
685-- Python
686# Keywords in both Python 2 and 3.
687and
688as
689assert
690break
691class
692continue
693def
694del
695elif
696else
697except
698finally
699for
700from
701global
702if
703import
704in
705is
706lambda
707not
708or
709pass
710raise
711return
712try
713while
714with
715yield
716
717
718-- Python 3
719# Python 3-only keywords.
720False
721None
722nonlocal
723print
724True
725
726
727-- Java
728abstract
729assert
730boolean
731break
732byte
733case
734catch
735char
736class
737const
738continue
739default
740do
741double
742else
743extends
744final
745finally
746float
747for
748goto
749if
750implements
751import
752instanceof
753int
754interface
755long
756native
757new
758package
759private
760protected
761public
762return
763short
764static
765strictfp
766super
767switch
768synchronized
769this
770throw
771throws
772transient
773try
774void
775volatile
776while
777
778
779-- Protocol Buffers
780# The protobuf compiler does not reserve *any* words.  The following is a
781# perfectly valid .proto file:
782#
783# message message {
784#   optional optional optional = 1;
785# };
786#
787# message optional {
788#   optional message message = 1;
789# };
790#
791# Unsurprisingly, the same appears to be true of Cap'n'Proto.
792
793
794-- Dart
795assert
796break
797case
798catch
799class
800const
801continue
802default
803do
804else
805enum
806extends
807false
808final
809finally
810for
811if
812in
813is
814new
815null
816rethrow
817return
818super
819switch
820this
821throw
822true
823try
824var
825void
826while
827with
828
829
830-- Objective C
831auto
832break
833case
834CGFloat
835char
836const
837continue
838default
839do
840double
841else
842enum
843extern
844float
845for
846goto
847if
848implementation
849int
850interface
851long
852nonatomic
853NSInteger
854NSNumber
855NSObject
856_Packed
857property
858protocol
859readonly
860readwrite
861register
862retain
863return
864short
865signed
866sizeof
867static
868strong
869struct
870switch
871typedef
872union
873unsafe_unretained
874unsigned
875void
876volatile
877weak
878while
879
880
881-- Swift
882# Swift allows any name to be used as an identifier if it is enclosed in
883# backticks (e.g., `if`).
884
885
886-- Erlang
887after
888and
889andalso
890band
891begin
892bnot
893bor
894bsl
895bsr
896bxor
897case
898catch
899cond
900div
901end
902fun
903if
904let
905not
906of
907or
908orelse
909receive
910rem
911try
912when
913xor
914
915
916-- Rust
917abstract
918alignof
919as
920become
921box
922break
923const
924continue
925crate
926do
927else
928extern
929final
930fn
931for
932if
933impl
934in
935let
936loop
937macro
938match
939mod
940move
941mut
942offsetof
943override
944priv
945proc
946pub
947pure
948ref
949return
950self
951Self
952sizeof
953static
954super
955trait
956type
957typeof
958unsafe
959unsized
960use
961virtual
962where
963while
964yield
965
966
967-- C#
968# C# allows any name to be used as an identifier if it is prefixed with '@';
969# e.g., @if.
970
971
972-- MATLAB
973break
974case
975catch
976classdef
977continue
978else
979elseif
980end
981for
982function
983global
984if
985otherwise
986parfor
987persistent
988return
989spmd
990switch
991try
992while
993