1 /* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack.
2 Copyright (C) 1992-2021 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
22 #include "coretypes.h"
24 #include "function.h" /* For cfun. */
27 #include "tm_p.h" /* For REGISTER_TARGET_PRAGMAS. */
28 #include "stringpool.h"
30 #include "diagnostic.h"
36 #include "opt-suggestions.h"
38 #define GCC_BAD(gmsgid) \
39 do { warning (OPT_Wpragmas, gmsgid); return; } while (0)
40 #define GCC_BAD2(gmsgid, arg) \
41 do { warning (OPT_Wpragmas, gmsgid, arg); return; } while (0)
42 #define GCC_BAD_AT(loc, gmsgid) \
43 do { warning_at (loc, OPT_Wpragmas, gmsgid); return; } while (0)
44 #define GCC_BAD2_AT(loc, gmsgid, arg) \
45 do { warning_at (loc, OPT_Wpragmas, gmsgid, arg); return; } while (0)
47 struct GTY(()) align_stack
{
50 struct align_stack
* prev
;
53 static GTY(()) struct align_stack
* alignment_stack
;
55 static void handle_pragma_pack (cpp_reader
*);
57 /* If we have a "global" #pragma pack(<n>) in effect when the first
58 #pragma pack(push,<n>) is encountered, this stores the value of
59 maximum_field_alignment in effect. When the final pop_alignment()
60 happens, we restore the value to this, not to a value of 0 for
61 maximum_field_alignment. Value is in bits. */
62 static int default_alignment
;
63 #define SET_GLOBAL_ALIGNMENT(ALIGN) (maximum_field_alignment = *(alignment_stack == NULL \
64 ? &default_alignment \
65 : &alignment_stack->alignment) = (ALIGN))
67 static void push_alignment (int, tree
);
68 static void pop_alignment (tree
);
70 /* Push an alignment value onto the stack. */
72 push_alignment (int alignment
, tree id
)
74 align_stack
* entry
= ggc_alloc
<align_stack
> ();
76 entry
->alignment
= alignment
;
78 entry
->prev
= alignment_stack
;
80 /* The current value of maximum_field_alignment is not necessarily
81 0 since there may be a #pragma pack(<n>) in effect; remember it
82 so that we can restore it after the final #pragma pop(). */
83 if (alignment_stack
== NULL
)
84 default_alignment
= maximum_field_alignment
;
86 alignment_stack
= entry
;
88 maximum_field_alignment
= alignment
;
91 /* Undo a push of an alignment onto the stack. */
93 pop_alignment (tree id
)
97 if (alignment_stack
== NULL
)
98 GCC_BAD ("%<#pragma pack (pop)%> encountered without matching "
99 "%<#pragma pack (push)%>");
101 /* If we got an identifier, strip away everything above the target
102 entry so that the next step will restore the state just below it. */
105 for (entry
= alignment_stack
; entry
; entry
= entry
->prev
)
108 alignment_stack
= entry
;
112 warning (OPT_Wpragmas
,
113 "%<#pragma pack(pop, %E)%> encountered without matching "
114 "%<#pragma pack(push, %E)%>"
118 entry
= alignment_stack
->prev
;
120 maximum_field_alignment
= entry
? entry
->alignment
: default_alignment
;
122 alignment_stack
= entry
;
129 #pragma pack (push, N)
130 #pragma pack (push, ID)
131 #pragma pack (push, ID, N)
133 #pragma pack (pop, ID) */
135 handle_pragma_pack (cpp_reader
* ARG_UNUSED (dummy
))
140 enum cpp_ttype token
;
141 enum { set
, push
, pop
} action
;
143 if (pragma_lex (&x
) != CPP_OPEN_PAREN
)
144 GCC_BAD ("missing %<(%> after %<#pragma pack%> - ignored");
146 token
= pragma_lex (&x
, &loc
);
147 if (token
== CPP_CLOSE_PAREN
)
150 align
= initial_max_fld_align
;
152 else if (token
== CPP_NUMBER
)
154 if (TREE_CODE (x
) != INTEGER_CST
)
155 GCC_BAD_AT (loc
, "invalid constant in %<#pragma pack%> - ignored");
156 align
= TREE_INT_CST_LOW (x
);
158 if (pragma_lex (&x
) != CPP_CLOSE_PAREN
)
159 GCC_BAD ("malformed %<#pragma pack%> - ignored");
161 else if (token
== CPP_NAME
)
163 #define GCC_BAD_ACTION do { if (action != pop) \
164 GCC_BAD ("malformed %<#pragma pack(push[, id][, <n>])%> - ignored"); \
166 GCC_BAD ("malformed %<#pragma pack(pop[, id])%> - ignored"); \
169 const char *op
= IDENTIFIER_POINTER (x
);
170 if (!strcmp (op
, "push"))
172 else if (!strcmp (op
, "pop"))
175 GCC_BAD2_AT (loc
, "unknown action %qE for %<#pragma pack%> - ignored",
178 while ((token
= pragma_lex (&x
)) == CPP_COMMA
)
180 token
= pragma_lex (&x
, &loc
);
181 if (token
== CPP_NAME
&& id
== 0)
185 else if (token
== CPP_NUMBER
&& action
== push
&& align
== -1)
187 if (TREE_CODE (x
) != INTEGER_CST
)
189 "invalid constant in %<#pragma pack%> - ignored");
190 align
= TREE_INT_CST_LOW (x
);
198 if (token
!= CPP_CLOSE_PAREN
)
200 #undef GCC_BAD_ACTION
203 GCC_BAD ("malformed %<#pragma pack%> - ignored");
205 if (pragma_lex (&x
, &loc
) != CPP_EOF
)
206 warning_at (loc
, OPT_Wpragmas
, "junk at end of %<#pragma pack%>");
208 if (flag_pack_struct
)
209 GCC_BAD ("%<#pragma pack%> has no effect with %<-fpack-struct%> - ignored");
220 align
*= BITS_PER_UNIT
;
225 align
= maximum_field_alignment
;
230 GCC_BAD2 ("alignment must be a small power of two, not %d", align
);
235 case set
: SET_GLOBAL_ALIGNMENT (align
); break;
236 case push
: push_alignment (align
, id
); break;
237 case pop
: pop_alignment (id
); break;
241 struct GTY(()) pending_weak
248 static GTY(()) vec
<pending_weak
, va_gc
> *pending_weaks
;
250 static void apply_pragma_weak (tree
, tree
);
251 static void handle_pragma_weak (cpp_reader
*);
254 apply_pragma_weak (tree decl
, tree value
)
258 value
= build_string (IDENTIFIER_LENGTH (value
),
259 IDENTIFIER_POINTER (value
));
260 decl_attributes (&decl
, build_tree_list (get_identifier ("alias"),
261 build_tree_list (NULL
, value
)),
265 if (SUPPORTS_WEAK
&& DECL_EXTERNAL (decl
) && TREE_USED (decl
)
266 && !DECL_WEAK (decl
) /* Don't complain about a redundant #pragma. */
267 && DECL_ASSEMBLER_NAME_SET_P (decl
)
268 && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
269 warning (OPT_Wpragmas
, "applying %<#pragma weak %+D%> after first use "
270 "results in unspecified behavior", decl
);
276 maybe_apply_pragma_weak (tree decl
)
282 /* Avoid asking for DECL_ASSEMBLER_NAME when it's not needed. */
284 /* No weak symbols pending, take the short-cut. */
285 if (vec_safe_is_empty (pending_weaks
))
287 /* If it's not visible outside this file, it doesn't matter whether
289 if (!DECL_EXTERNAL (decl
) && !TREE_PUBLIC (decl
))
291 /* If it's not a function or a variable, it can't be weak.
292 FIXME: what kinds of things are visible outside this file but
293 aren't functions or variables? Should this be an assert instead? */
294 if (!VAR_OR_FUNCTION_DECL_P (decl
))
297 if (DECL_ASSEMBLER_NAME_SET_P (decl
))
298 id
= DECL_ASSEMBLER_NAME (decl
);
301 id
= DECL_ASSEMBLER_NAME (decl
);
302 SET_DECL_ASSEMBLER_NAME (decl
, NULL_TREE
);
305 FOR_EACH_VEC_ELT (*pending_weaks
, i
, pe
)
308 apply_pragma_weak (decl
, pe
->value
);
309 pending_weaks
->unordered_remove (i
);
314 /* Process all "#pragma weak A = B" directives where we have not seen
317 maybe_apply_pending_pragma_weaks (void)
319 tree alias_id
, id
, decl
;
324 if (vec_safe_is_empty (pending_weaks
))
327 FOR_EACH_VEC_ELT (*pending_weaks
, i
, pe
)
335 target
= symtab_node::get_for_asmname (id
);
336 decl
= build_decl (UNKNOWN_LOCATION
,
337 target
? TREE_CODE (target
->decl
) : FUNCTION_DECL
,
338 alias_id
, default_function_type
);
340 DECL_ARTIFICIAL (decl
) = 1;
341 TREE_PUBLIC (decl
) = 1;
342 DECL_WEAK (decl
) = 1;
344 TREE_STATIC (decl
) = 1;
347 error ("%q+D aliased to undefined symbol %qE",
352 assemble_alias (decl
, id
);
356 /* #pragma weak name [= value] */
358 handle_pragma_weak (cpp_reader
* ARG_UNUSED (dummy
))
360 tree name
, value
, x
, decl
;
365 if (pragma_lex (&name
) != CPP_NAME
)
366 GCC_BAD ("malformed %<#pragma weak%>, ignored");
370 if (pragma_lex (&value
) != CPP_NAME
)
371 GCC_BAD ("malformed %<#pragma weak%>, ignored");
375 warning (OPT_Wpragmas
, "junk at end of %<#pragma weak%>");
377 decl
= identifier_global_value (name
);
378 if (decl
&& DECL_P (decl
))
380 if (!VAR_OR_FUNCTION_DECL_P (decl
))
381 GCC_BAD2 ("%<#pragma weak%> declaration of %q+D not allowed,"
383 apply_pragma_weak (decl
, value
);
386 DECL_EXTERNAL (decl
) = 0;
388 TREE_STATIC (decl
) = 1;
389 assemble_alias (decl
, value
);
394 pending_weak pe
= {name
, value
};
395 vec_safe_push (pending_weaks
, pe
);
399 static enum scalar_storage_order_kind global_sso
;
402 maybe_apply_pragma_scalar_storage_order (tree type
)
404 if (global_sso
== SSO_NATIVE
)
407 gcc_assert (RECORD_OR_UNION_TYPE_P (type
));
409 if (lookup_attribute ("scalar_storage_order", TYPE_ATTRIBUTES (type
)))
412 if (global_sso
== SSO_BIG_ENDIAN
)
413 TYPE_REVERSE_STORAGE_ORDER (type
) = !BYTES_BIG_ENDIAN
;
414 else if (global_sso
== SSO_LITTLE_ENDIAN
)
415 TYPE_REVERSE_STORAGE_ORDER (type
) = BYTES_BIG_ENDIAN
;
421 handle_pragma_scalar_storage_order (cpp_reader
*ARG_UNUSED(dummy
))
423 const char *kind_string
;
424 enum cpp_ttype token
;
427 if (BYTES_BIG_ENDIAN
!= WORDS_BIG_ENDIAN
)
429 error ("%<scalar_storage_order%> is not supported because endianness "
434 if (c_dialect_cxx ())
436 if (warn_unknown_pragmas
> in_system_header_at (input_location
))
437 warning (OPT_Wunknown_pragmas
,
438 "%<#pragma scalar_storage_order%> is not supported for C++");
442 token
= pragma_lex (&x
);
443 if (token
!= CPP_NAME
)
444 GCC_BAD ("missing [big-endian|little-endian|default] after %<#pragma scalar_storage_order%>");
445 kind_string
= IDENTIFIER_POINTER (x
);
446 if (strcmp (kind_string
, "default") == 0)
447 global_sso
= default_sso
;
448 else if (strcmp (kind_string
, "big") == 0)
449 global_sso
= SSO_BIG_ENDIAN
;
450 else if (strcmp (kind_string
, "little") == 0)
451 global_sso
= SSO_LITTLE_ENDIAN
;
453 GCC_BAD ("expected [big-endian|little-endian|default] after %<#pragma scalar_storage_order%>");
456 /* GCC supports two #pragma directives for renaming the external
457 symbol associated with a declaration (DECL_ASSEMBLER_NAME), for
458 compatibility with the Solaris and VMS system headers. GCC also
459 has its own notation for this, __asm__("name") annotations.
461 Corner cases of these features and their interaction:
463 1) Both pragmas silently apply only to declarations with external
464 linkage (that is, TREE_PUBLIC || DECL_EXTERNAL). Asm labels
465 do not have this restriction.
467 2) In C++, both #pragmas silently apply only to extern "C" declarations.
468 Asm labels do not have this restriction.
470 3) If any of the three ways of changing DECL_ASSEMBLER_NAME is
471 applied to a decl whose DECL_ASSEMBLER_NAME is already set, and the
472 new name is different, a warning issues and the name does not change.
474 4) The "source name" for #pragma redefine_extname is the DECL_NAME,
475 *not* the DECL_ASSEMBLER_NAME.
477 5) If #pragma extern_prefix is in effect and a declaration occurs
478 with an __asm__ name, the #pragma extern_prefix is silently
479 ignored for that declaration.
481 6) If #pragma extern_prefix and #pragma redefine_extname apply to
482 the same declaration, whichever triggered first wins, and a warning
483 is issued. (We would like to have #pragma redefine_extname always
484 win, but it can appear either before or after the declaration, and
485 if it appears afterward, we have no way of knowing whether a modified
486 DECL_ASSEMBLER_NAME is due to #pragma extern_prefix.) */
488 struct GTY(()) pending_redefinition
{
494 static GTY(()) vec
<pending_redefinition
, va_gc
> *pending_redefine_extname
;
496 static void handle_pragma_redefine_extname (cpp_reader
*);
498 /* #pragma redefine_extname oldname newname */
500 handle_pragma_redefine_extname (cpp_reader
* ARG_UNUSED (dummy
))
502 tree oldname
, newname
, decls
, x
;
506 if (pragma_lex (&oldname
) != CPP_NAME
)
507 GCC_BAD ("malformed %<#pragma redefine_extname%>, ignored");
508 if (pragma_lex (&newname
) != CPP_NAME
)
509 GCC_BAD ("malformed %<#pragma redefine_extname%>, ignored");
512 warning (OPT_Wpragmas
, "junk at end of %<#pragma redefine_extname%>");
515 for (decls
= c_linkage_bindings (oldname
);
519 if (TREE_CODE (decls
) == TREE_LIST
)
521 decl
= TREE_VALUE (decls
);
522 decls
= TREE_CHAIN (decls
);
530 if ((TREE_PUBLIC (decl
) || DECL_EXTERNAL (decl
))
531 && VAR_OR_FUNCTION_DECL_P (decl
))
534 if (DECL_ASSEMBLER_NAME_SET_P (decl
))
536 const char *name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
537 name
= targetm
.strip_name_encoding (name
);
539 if (!id_equal (newname
, name
))
540 warning (OPT_Wpragmas
, "%<#pragma redefine_extname%> "
541 "ignored due to conflict with previous rename");
544 symtab
->change_decl_assembler_name (decl
, newname
);
549 /* We have to add this to the rename list even if there's already
550 a global value that doesn't meet the above criteria, because in
551 C++ "struct foo {...};" puts "foo" in the current namespace but
552 does *not* conflict with a subsequent declaration of a function
553 or variable foo. See g++.dg/other/pragma-re-2.C. */
554 add_to_renaming_pragma_list (oldname
, newname
);
557 /* This is called from here and from ia64-c.c. */
559 add_to_renaming_pragma_list (tree oldname
, tree newname
)
562 pending_redefinition
*p
;
564 FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname
, ix
, p
)
565 if (oldname
== p
->oldname
)
567 if (p
->newname
!= newname
)
568 warning (OPT_Wpragmas
, "%<#pragma redefine_extname%> ignored due to "
569 "conflict with previous %<#pragma redefine_extname%>");
573 pending_redefinition e
= {oldname
, newname
};
574 vec_safe_push (pending_redefine_extname
, e
);
577 /* The current prefix set by #pragma extern_prefix. */
578 GTY(()) tree pragma_extern_prefix
;
580 /* Hook from the front ends to apply the results of one of the preceding
581 pragmas that rename variables. */
584 maybe_apply_renaming_pragma (tree decl
, tree asmname
)
587 pending_redefinition
*p
;
589 /* The renaming pragmas are only applied to declarations with
591 if (!VAR_OR_FUNCTION_DECL_P (decl
)
592 || (!TREE_PUBLIC (decl
) && !DECL_EXTERNAL (decl
))
593 || !has_c_linkage (decl
))
596 /* If the DECL_ASSEMBLER_NAME is already set, it does not change,
597 but we may warn about a rename that conflicts. */
598 if (DECL_ASSEMBLER_NAME_SET_P (decl
))
600 const char *oldname
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
601 oldname
= targetm
.strip_name_encoding (oldname
);
603 if (asmname
&& strcmp (TREE_STRING_POINTER (asmname
), oldname
))
604 warning (OPT_Wpragmas
, "%<asm%> declaration ignored due to "
605 "conflict with previous rename");
607 /* Take any pending redefine_extname off the list. */
608 FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname
, ix
, p
)
609 if (DECL_NAME (decl
) == p
->oldname
)
611 /* Only warn if there is a conflict. */
612 if (!id_equal (p
->newname
, oldname
))
613 warning (OPT_Wpragmas
, "%<#pragma redefine_extname%> ignored "
614 "due to conflict with previous rename");
616 pending_redefine_extname
->unordered_remove (ix
);
622 /* Find out if we have a pending #pragma redefine_extname. */
623 FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname
, ix
, p
)
624 if (DECL_NAME (decl
) == p
->oldname
)
626 tree newname
= p
->newname
;
627 pending_redefine_extname
->unordered_remove (ix
);
629 /* If we already have an asmname, #pragma redefine_extname is
630 ignored (with a warning if it conflicts). */
633 if (strcmp (TREE_STRING_POINTER (asmname
),
634 IDENTIFIER_POINTER (newname
)) != 0)
635 warning (OPT_Wpragmas
, "%<#pragma redefine_extname%> ignored "
636 "due to conflict with %<asm%> declaration");
640 /* Otherwise we use what we've got; #pragma extern_prefix is
642 return build_string (IDENTIFIER_LENGTH (newname
),
643 IDENTIFIER_POINTER (newname
));
646 /* If we've got an asmname, #pragma extern_prefix is silently ignored. */
650 /* If #pragma extern_prefix is in effect, apply it. */
651 if (pragma_extern_prefix
)
653 const char *prefix
= TREE_STRING_POINTER (pragma_extern_prefix
);
654 size_t plen
= TREE_STRING_LENGTH (pragma_extern_prefix
) - 1;
656 const char *id
= IDENTIFIER_POINTER (DECL_NAME (decl
));
657 size_t ilen
= IDENTIFIER_LENGTH (DECL_NAME (decl
));
659 char *newname
= (char *) alloca (plen
+ ilen
+ 1);
661 memcpy (newname
, prefix
, plen
);
662 memcpy (newname
+ plen
, id
, ilen
+ 1);
664 return build_string (plen
+ ilen
, newname
);
672 static void handle_pragma_visibility (cpp_reader
*);
674 static vec
<int> visstack
;
676 /* Push the visibility indicated by STR onto the top of the #pragma
677 visibility stack. KIND is 0 for #pragma GCC visibility, 1 for
678 C++ namespace with visibility attribute and 2 for C++ builtin
679 ABI namespace. push_visibility/pop_visibility calls must have
680 matching KIND, it is not allowed to push visibility using one
681 KIND and pop using a different one. */
684 push_visibility (const char *str
, int kind
)
686 visstack
.safe_push (((int) default_visibility
) | (kind
<< 8));
687 if (!strcmp (str
, "default"))
688 default_visibility
= VISIBILITY_DEFAULT
;
689 else if (!strcmp (str
, "internal"))
690 default_visibility
= VISIBILITY_INTERNAL
;
691 else if (!strcmp (str
, "hidden"))
692 default_visibility
= VISIBILITY_HIDDEN
;
693 else if (!strcmp (str
, "protected"))
694 default_visibility
= VISIBILITY_PROTECTED
;
696 GCC_BAD ("%<#pragma GCC visibility push()%> must specify %<default%>, "
697 "%<internal%>, %<hidden%> or %<protected%>");
698 visibility_options
.inpragma
= 1;
701 /* Pop a level of the #pragma visibility stack. Return true if
705 pop_visibility (int kind
)
707 if (!visstack
.length ())
709 if ((visstack
.last () >> 8) != kind
)
712 = (enum symbol_visibility
) (visstack
.pop () & 0xff);
713 visibility_options
.inpragma
714 = visstack
.length () != 0;
718 /* Sets the default visibility for symbols to something other than that
719 specified on the command line. */
722 handle_pragma_visibility (cpp_reader
*dummy ATTRIBUTE_UNUSED
)
724 /* Form is #pragma GCC visibility push(hidden)|pop */
726 enum cpp_ttype token
;
727 enum { bad
, push
, pop
} action
= bad
;
729 token
= pragma_lex (&x
);
730 if (token
== CPP_NAME
)
732 const char *op
= IDENTIFIER_POINTER (x
);
733 if (!strcmp (op
, "push"))
735 else if (!strcmp (op
, "pop"))
739 GCC_BAD ("%<#pragma GCC visibility%> must be followed by %<push%> "
745 if (! pop_visibility (0))
746 GCC_BAD ("no matching push for %<#pragma GCC visibility pop%>");
750 if (pragma_lex (&x
) != CPP_OPEN_PAREN
)
751 GCC_BAD ("missing %<(%> after %<#pragma GCC visibility push%> - ignored");
752 token
= pragma_lex (&x
);
753 if (token
!= CPP_NAME
)
754 GCC_BAD ("malformed %<#pragma GCC visibility push%>");
756 push_visibility (IDENTIFIER_POINTER (x
), 0);
757 if (pragma_lex (&x
) != CPP_CLOSE_PAREN
)
758 GCC_BAD ("missing %<(%> after %<#pragma GCC visibility push%> - ignored");
761 if (pragma_lex (&x
) != CPP_EOF
)
762 warning (OPT_Wpragmas
, "junk at end of %<#pragma GCC visibility%>");
766 handle_pragma_diagnostic(cpp_reader
*ARG_UNUSED(dummy
))
770 enum cpp_ttype token
= pragma_lex (&x
, &loc
);
771 if (token
!= CPP_NAME
)
773 warning_at (loc
, OPT_Wpragmas
,
774 "missing [error|warning|ignored|push|pop|ignored_attributes]"
775 " after %<#pragma GCC diagnostic%>");
780 const char *kind_string
= IDENTIFIER_POINTER (x
);
781 if (strcmp (kind_string
, "error") == 0)
783 else if (strcmp (kind_string
, "warning") == 0)
785 else if (strcmp (kind_string
, "ignored") == 0)
787 else if (strcmp (kind_string
, "push") == 0)
789 diagnostic_push_diagnostics (global_dc
, input_location
);
792 else if (strcmp (kind_string
, "pop") == 0)
794 diagnostic_pop_diagnostics (global_dc
, input_location
);
797 else if (strcmp (kind_string
, "ignored_attributes") == 0)
799 token
= pragma_lex (&x
, &loc
);
800 if (token
!= CPP_STRING
)
802 warning_at (loc
, OPT_Wpragmas
,
803 "missing attribute name after %<#pragma GCC diagnostic "
804 "ignored_attributes%>");
807 char *args
= xstrdup (TREE_STRING_POINTER (x
));
808 const size_t l
= strlen (args
);
811 warning_at (loc
, OPT_Wpragmas
, "missing argument to %<#pragma GCC "
812 "diagnostic ignored_attributes%>");
816 else if (args
[l
- 1] == ',')
818 warning_at (loc
, OPT_Wpragmas
, "trailing %<,%> in arguments for "
819 "%<#pragma GCC diagnostic ignored_attributes%>");
824 for (char *p
= strtok (args
, ","); p
; p
= strtok (NULL
, ","))
826 handle_ignored_attributes_option (&v
);
832 warning_at (loc
, OPT_Wpragmas
,
833 "expected [error|warning|ignored|push|pop|ignored_attributes]"
834 " after %<#pragma GCC diagnostic%>");
838 token
= pragma_lex (&x
, &loc
);
839 if (token
!= CPP_STRING
)
841 warning_at (loc
, OPT_Wpragmas
,
842 "missing option after %<#pragma GCC diagnostic%> kind");
846 const char *option_string
= TREE_STRING_POINTER (x
);
847 unsigned int lang_mask
= c_common_option_lang_mask () | CL_COMMON
;
848 /* option_string + 1 to skip the initial '-' */
849 unsigned int option_index
= find_opt (option_string
+ 1, lang_mask
);
850 if (option_index
== OPT_SPECIAL_unknown
)
852 auto_diagnostic_group d
;
853 if (warning_at (loc
, OPT_Wpragmas
,
854 "unknown option after %<#pragma GCC diagnostic%> kind"))
857 const char *hint
= op
.suggest_option (option_string
+ 1);
859 inform (loc
, "did you mean %<-%s%>?", hint
);
863 else if (!(cl_options
[option_index
].flags
& CL_WARNING
))
865 warning_at (loc
, OPT_Wpragmas
,
866 "%qs is not an option that controls warnings", option_string
);
869 else if (!(cl_options
[option_index
].flags
& lang_mask
))
871 char *ok_langs
= write_langs (cl_options
[option_index
].flags
);
872 char *bad_lang
= write_langs (c_common_option_lang_mask ());
873 warning_at (loc
, OPT_Wpragmas
,
874 "option %qs is valid for %s but not for %s",
875 option_string
, ok_langs
, bad_lang
);
881 struct cl_option_handlers handlers
;
882 set_default_handlers (&handlers
, NULL
);
883 const char *arg
= NULL
;
884 if (cl_options
[option_index
].flags
& CL_JOINED
)
885 arg
= option_string
+ 1 + cl_options
[option_index
].opt_len
;
886 /* FIXME: input_location isn't the best location here, but it is
887 what we used to do here before and changing it breaks e.g.
888 PR69543 and PR69558. */
889 control_warning_option (option_index
, (int) kind
,
890 arg
, kind
!= DK_IGNORED
,
891 input_location
, lang_mask
, &handlers
,
892 &global_options
, &global_options_set
,
896 /* Parse #pragma GCC target (xxx) to set target specific options. */
898 handle_pragma_target(cpp_reader
*ARG_UNUSED(dummy
))
901 enum cpp_ttype token
;
903 bool close_paren_needed_p
= false;
907 error ("%<#pragma GCC option%> is not allowed inside functions");
911 token
= pragma_lex (&x
, &loc
);
912 if (token
== CPP_OPEN_PAREN
)
914 close_paren_needed_p
= true;
915 token
= pragma_lex (&x
, &loc
);
918 if (token
!= CPP_STRING
)
920 GCC_BAD_AT (loc
, "%<#pragma GCC option%> is not a string");
924 /* Strings are user options. */
927 tree args
= NULL_TREE
;
931 /* Build up the strings now as a tree linked list. Skip empty
933 if (TREE_STRING_LENGTH (x
) > 0)
934 args
= tree_cons (NULL_TREE
, x
, args
);
936 token
= pragma_lex (&x
);
937 while (token
== CPP_COMMA
)
938 token
= pragma_lex (&x
);
940 while (token
== CPP_STRING
);
942 if (close_paren_needed_p
)
944 if (token
== CPP_CLOSE_PAREN
)
945 token
= pragma_lex (&x
);
947 GCC_BAD ("%<#pragma GCC target (string [,string]...)%> does "
948 "not have a final %<)%>");
951 if (token
!= CPP_EOF
)
953 error ("%<#pragma GCC target%> string is badly formed");
957 /* put arguments in the order the user typed them. */
958 args
= nreverse (args
);
960 if (targetm
.target_option
.pragma_parse (args
, NULL_TREE
))
961 current_target_pragma
= chainon (current_target_pragma
, args
);
963 /* A target pragma can also influence optimization options. */
964 tree current_optimize
965 = build_optimization_node (&global_options
, &global_options_set
);
966 if (current_optimize
!= optimization_current_node
)
967 optimization_current_node
= current_optimize
;
971 /* Handle #pragma GCC optimize to set optimization options. */
973 handle_pragma_optimize (cpp_reader
*ARG_UNUSED(dummy
))
975 enum cpp_ttype token
;
977 bool close_paren_needed_p
= false;
978 tree optimization_previous_node
= optimization_current_node
;
982 error ("%<#pragma GCC optimize%> is not allowed inside functions");
986 token
= pragma_lex (&x
);
987 if (token
== CPP_OPEN_PAREN
)
989 close_paren_needed_p
= true;
990 token
= pragma_lex (&x
);
993 if (token
!= CPP_STRING
&& token
!= CPP_NUMBER
)
995 GCC_BAD ("%<#pragma GCC optimize%> is not a string or number");
999 /* Strings/numbers are user options. */
1002 tree args
= NULL_TREE
;
1006 /* Build up the numbers/strings now as a list. */
1007 if (token
!= CPP_STRING
|| TREE_STRING_LENGTH (x
) > 0)
1008 args
= tree_cons (NULL_TREE
, x
, args
);
1010 token
= pragma_lex (&x
);
1011 while (token
== CPP_COMMA
)
1012 token
= pragma_lex (&x
);
1014 while (token
== CPP_STRING
|| token
== CPP_NUMBER
);
1016 if (close_paren_needed_p
)
1018 if (token
== CPP_CLOSE_PAREN
)
1019 token
= pragma_lex (&x
);
1021 GCC_BAD ("%<#pragma GCC optimize (string [,string]...)%> does "
1022 "not have a final %<)%>");
1025 if (token
!= CPP_EOF
)
1027 error ("%<#pragma GCC optimize%> string is badly formed");
1031 /* put arguments in the order the user typed them. */
1032 args
= nreverse (args
);
1034 parse_optimize_options (args
, false);
1035 current_optimize_pragma
= chainon (current_optimize_pragma
, args
);
1036 optimization_current_node
1037 = build_optimization_node (&global_options
, &global_options_set
);
1038 c_cpp_builtins_optimize_pragma (parse_in
,
1039 optimization_previous_node
,
1040 optimization_current_node
);
1044 /* Stack of the #pragma GCC options created with #pragma GCC push_option. Save
1045 both the binary representation of the options and the TREE_LIST of
1046 strings that will be added to the function's attribute list. */
1047 struct GTY(()) opt_stack
{
1048 struct opt_stack
*prev
;
1050 tree target_strings
;
1051 tree optimize_binary
;
1052 tree optimize_strings
;
1053 gcc_options
* GTY ((skip
)) saved_global_options
;
1056 static GTY(()) struct opt_stack
* options_stack
;
1058 /* Handle #pragma GCC push_options to save the current target and optimization
1062 handle_pragma_push_options (cpp_reader
*ARG_UNUSED(dummy
))
1064 enum cpp_ttype token
;
1067 token
= pragma_lex (&x
);
1068 if (token
!= CPP_EOF
)
1070 warning (OPT_Wpragmas
, "junk at end of %<#pragma push_options%>");
1074 opt_stack
*p
= ggc_alloc
<opt_stack
> ();
1075 p
->prev
= options_stack
;
1078 /* Save optimization and target flags in binary format. */
1081 p
->saved_global_options
= XNEW (gcc_options
);
1082 *p
->saved_global_options
= global_options
;
1084 p
->optimize_binary
= build_optimization_node (&global_options
,
1085 &global_options_set
);
1086 p
->target_binary
= build_target_option_node (&global_options
,
1087 &global_options_set
);
1089 /* Save optimization and target flags in string list format. */
1090 p
->optimize_strings
= copy_list (current_optimize_pragma
);
1091 p
->target_strings
= copy_list (current_target_pragma
);
1094 /* Handle #pragma GCC pop_options to restore the current target and
1095 optimization options from a previous push_options. */
1098 handle_pragma_pop_options (cpp_reader
*ARG_UNUSED(dummy
))
1100 enum cpp_ttype token
;
1104 token
= pragma_lex (&x
);
1105 if (token
!= CPP_EOF
)
1107 warning (OPT_Wpragmas
, "junk at end of %<#pragma pop_options%>");
1111 if (! options_stack
)
1113 warning (OPT_Wpragmas
,
1114 "%<#pragma GCC pop_options%> without a corresponding "
1115 "%<#pragma GCC push_options%>");
1120 options_stack
= p
->prev
;
1122 if (p
->target_binary
!= target_option_current_node
)
1124 (void) targetm
.target_option
.pragma_parse (NULL_TREE
, p
->target_binary
);
1125 target_option_current_node
= p
->target_binary
;
1128 /* Always restore optimization options as optimization_current_node is
1129 * overwritten by invoke_set_current_function_hook. */
1130 cl_optimization_restore (&global_options
, &global_options_set
,
1131 TREE_OPTIMIZATION (p
->optimize_binary
));
1132 cl_target_option_restore (&global_options
, &global_options_set
,
1133 TREE_TARGET_OPTION (p
->target_binary
));
1135 if (p
->optimize_binary
!= optimization_current_node
)
1137 c_cpp_builtins_optimize_pragma (parse_in
, optimization_current_node
,
1138 p
->optimize_binary
);
1139 optimization_current_node
= p
->optimize_binary
;
1143 cl_optimization_compare (p
->saved_global_options
, &global_options
);
1144 free (p
->saved_global_options
);
1147 current_target_pragma
= p
->target_strings
;
1148 current_optimize_pragma
= p
->optimize_strings
;
1151 /* Handle #pragma GCC reset_options to restore the current target and
1152 optimization options to the original options used on the command line. */
1155 handle_pragma_reset_options (cpp_reader
*ARG_UNUSED(dummy
))
1157 enum cpp_ttype token
;
1159 tree new_optimize
= optimization_default_node
;
1160 tree new_target
= target_option_default_node
;
1162 token
= pragma_lex (&x
);
1163 if (token
!= CPP_EOF
)
1165 warning (OPT_Wpragmas
, "junk at end of %<#pragma reset_options%>");
1169 if (new_target
!= target_option_current_node
)
1171 (void) targetm
.target_option
.pragma_parse (NULL_TREE
, new_target
);
1172 target_option_current_node
= new_target
;
1175 if (new_optimize
!= optimization_current_node
)
1177 tree old_optimize
= optimization_current_node
;
1178 cl_optimization_restore (&global_options
, &global_options_set
,
1179 TREE_OPTIMIZATION (new_optimize
));
1180 c_cpp_builtins_optimize_pragma (parse_in
, old_optimize
, new_optimize
);
1181 optimization_current_node
= new_optimize
;
1184 current_target_pragma
= NULL_TREE
;
1185 current_optimize_pragma
= NULL_TREE
;
1188 /* Print a plain user-specified message. */
1191 handle_pragma_message (cpp_reader
*ARG_UNUSED(dummy
))
1194 enum cpp_ttype token
;
1195 tree x
, message
= 0;
1197 token
= pragma_lex (&x
);
1198 if (token
== CPP_OPEN_PAREN
)
1200 token
= pragma_lex (&x
);
1201 if (token
== CPP_STRING
)
1204 GCC_BAD ("expected a string after %<#pragma message%>");
1205 if (pragma_lex (&x
) != CPP_CLOSE_PAREN
)
1206 GCC_BAD ("malformed %<#pragma message%>, ignored");
1208 else if (token
== CPP_STRING
)
1211 GCC_BAD ("expected a string after %<#pragma message%>");
1213 gcc_assert (message
);
1215 if (pragma_lex (&x
, &loc
) != CPP_EOF
)
1216 warning_at (loc
, OPT_Wpragmas
, "junk at end of %<#pragma message%>");
1218 if (TREE_STRING_LENGTH (message
) > 1)
1219 inform (input_location
, "%<#pragma message: %s%>",
1220 TREE_STRING_POINTER (message
));
1223 /* Mark whether the current location is valid for a STDC pragma. */
1225 static bool valid_location_for_stdc_pragma
;
1228 mark_valid_location_for_stdc_pragma (bool flag
)
1230 valid_location_for_stdc_pragma
= flag
;
1233 /* Return true if the current location is valid for a STDC pragma. */
1236 valid_location_for_stdc_pragma_p (void)
1238 return valid_location_for_stdc_pragma
;
1241 enum pragma_switch_t
{ PRAGMA_ON
, PRAGMA_OFF
, PRAGMA_DEFAULT
, PRAGMA_BAD
};
1243 /* A STDC pragma must appear outside of external declarations or
1244 preceding all explicit declarations and statements inside a compound
1245 statement; its behavior is undefined if used in any other context.
1246 It takes a switch of ON, OFF, or DEFAULT. */
1248 static enum pragma_switch_t
1249 handle_stdc_pragma (const char *pname
)
1253 enum pragma_switch_t ret
;
1255 if (!valid_location_for_stdc_pragma_p ())
1257 warning (OPT_Wpragmas
, "invalid location for %<pragma %s%>, ignored",
1262 if (pragma_lex (&t
) != CPP_NAME
)
1264 warning (OPT_Wpragmas
, "malformed %<#pragma %s%>, ignored", pname
);
1268 arg
= IDENTIFIER_POINTER (t
);
1270 if (!strcmp (arg
, "ON"))
1272 else if (!strcmp (arg
, "OFF"))
1274 else if (!strcmp (arg
, "DEFAULT"))
1275 ret
= PRAGMA_DEFAULT
;
1278 warning (OPT_Wpragmas
, "malformed %<#pragma %s%>, ignored", pname
);
1282 if (pragma_lex (&t
) != CPP_EOF
)
1284 warning (OPT_Wpragmas
, "junk at end of %<#pragma %s%>", pname
);
1291 /* #pragma STDC FLOAT_CONST_DECIMAL64 ON
1292 #pragma STDC FLOAT_CONST_DECIMAL64 OFF
1293 #pragma STDC FLOAT_CONST_DECIMAL64 DEFAULT */
1296 handle_pragma_float_const_decimal64 (cpp_reader
*ARG_UNUSED (dummy
))
1298 if (c_dialect_cxx ())
1300 if (warn_unknown_pragmas
> in_system_header_at (input_location
))
1301 warning (OPT_Wunknown_pragmas
,
1302 "%<#pragma STDC FLOAT_CONST_DECIMAL64%> is not supported"
1307 if (!targetm
.decimal_float_supported_p ())
1309 if (warn_unknown_pragmas
> in_system_header_at (input_location
))
1310 warning (OPT_Wunknown_pragmas
,
1311 "%<#pragma STDC FLOAT_CONST_DECIMAL64%> is not supported"
1316 pedwarn (input_location
, OPT_Wpedantic
,
1317 "ISO C does not support %<#pragma STDC FLOAT_CONST_DECIMAL64%>");
1319 switch (handle_stdc_pragma ("STDC FLOAT_CONST_DECIMAL64"))
1322 set_float_const_decimal64 ();
1325 case PRAGMA_DEFAULT
:
1326 clear_float_const_decimal64 ();
1333 /* A vector of registered pragma callbacks, which is never freed. */
1335 static vec
<internal_pragma_handler
> registered_pragmas
;
1337 struct pragma_ns_name
1344 static vec
<pragma_ns_name
> registered_pp_pragmas
;
1346 struct omp_pragma_def
{ const char *name
; unsigned int id
; };
1347 static const struct omp_pragma_def oacc_pragmas
[] = {
1348 { "atomic", PRAGMA_OACC_ATOMIC
},
1349 { "cache", PRAGMA_OACC_CACHE
},
1350 { "data", PRAGMA_OACC_DATA
},
1351 { "declare", PRAGMA_OACC_DECLARE
},
1352 { "enter", PRAGMA_OACC_ENTER_DATA
},
1353 { "exit", PRAGMA_OACC_EXIT_DATA
},
1354 { "host_data", PRAGMA_OACC_HOST_DATA
},
1355 { "kernels", PRAGMA_OACC_KERNELS
},
1356 { "loop", PRAGMA_OACC_LOOP
},
1357 { "parallel", PRAGMA_OACC_PARALLEL
},
1358 { "routine", PRAGMA_OACC_ROUTINE
},
1359 { "serial", PRAGMA_OACC_SERIAL
},
1360 { "update", PRAGMA_OACC_UPDATE
},
1361 { "wait", PRAGMA_OACC_WAIT
}
1363 static const struct omp_pragma_def omp_pragmas
[] = {
1364 { "allocate", PRAGMA_OMP_ALLOCATE
},
1365 { "atomic", PRAGMA_OMP_ATOMIC
},
1366 { "barrier", PRAGMA_OMP_BARRIER
},
1367 { "cancel", PRAGMA_OMP_CANCEL
},
1368 { "cancellation", PRAGMA_OMP_CANCELLATION_POINT
},
1369 { "critical", PRAGMA_OMP_CRITICAL
},
1370 { "depobj", PRAGMA_OMP_DEPOBJ
},
1371 { "error", PRAGMA_OMP_ERROR
},
1372 { "end", PRAGMA_OMP_END_DECLARE_TARGET
},
1373 { "flush", PRAGMA_OMP_FLUSH
},
1374 { "nothing", PRAGMA_OMP_NOTHING
},
1375 { "requires", PRAGMA_OMP_REQUIRES
},
1376 { "scope", PRAGMA_OMP_SCOPE
},
1377 { "section", PRAGMA_OMP_SECTION
},
1378 { "sections", PRAGMA_OMP_SECTIONS
},
1379 { "single", PRAGMA_OMP_SINGLE
},
1380 { "task", PRAGMA_OMP_TASK
},
1381 { "taskgroup", PRAGMA_OMP_TASKGROUP
},
1382 { "taskwait", PRAGMA_OMP_TASKWAIT
},
1383 { "taskyield", PRAGMA_OMP_TASKYIELD
},
1384 { "threadprivate", PRAGMA_OMP_THREADPRIVATE
}
1386 static const struct omp_pragma_def omp_pragmas_simd
[] = {
1387 { "declare", PRAGMA_OMP_DECLARE
},
1388 { "distribute", PRAGMA_OMP_DISTRIBUTE
},
1389 { "for", PRAGMA_OMP_FOR
},
1390 { "loop", PRAGMA_OMP_LOOP
},
1391 { "masked", PRAGMA_OMP_MASKED
},
1392 { "master", PRAGMA_OMP_MASTER
},
1393 { "ordered", PRAGMA_OMP_ORDERED
},
1394 { "parallel", PRAGMA_OMP_PARALLEL
},
1395 { "scan", PRAGMA_OMP_SCAN
},
1396 { "simd", PRAGMA_OMP_SIMD
},
1397 { "target", PRAGMA_OMP_TARGET
},
1398 { "taskloop", PRAGMA_OMP_TASKLOOP
},
1399 { "teams", PRAGMA_OMP_TEAMS
},
1403 c_pp_lookup_pragma (unsigned int id
, const char **space
, const char **name
)
1405 const int n_oacc_pragmas
= sizeof (oacc_pragmas
) / sizeof (*oacc_pragmas
);
1406 const int n_omp_pragmas
= sizeof (omp_pragmas
) / sizeof (*omp_pragmas
);
1407 const int n_omp_pragmas_simd
= sizeof (omp_pragmas_simd
)
1408 / sizeof (*omp_pragmas
);
1411 for (i
= 0; i
< n_oacc_pragmas
; ++i
)
1412 if (oacc_pragmas
[i
].id
== id
)
1415 *name
= oacc_pragmas
[i
].name
;
1419 for (i
= 0; i
< n_omp_pragmas
; ++i
)
1420 if (omp_pragmas
[i
].id
== id
)
1423 *name
= omp_pragmas
[i
].name
;
1427 for (i
= 0; i
< n_omp_pragmas_simd
; ++i
)
1428 if (omp_pragmas_simd
[i
].id
== id
)
1431 *name
= omp_pragmas_simd
[i
].name
;
1435 if (id
>= PRAGMA_FIRST_EXTERNAL
1436 && (id
< PRAGMA_FIRST_EXTERNAL
+ registered_pp_pragmas
.length ()))
1438 *space
= registered_pp_pragmas
[id
- PRAGMA_FIRST_EXTERNAL
].space
;
1439 *name
= registered_pp_pragmas
[id
- PRAGMA_FIRST_EXTERNAL
].name
;
1446 /* Front-end wrappers for pragma registration to avoid dragging
1447 cpplib.h in almost everywhere. */
1450 c_register_pragma_1 (const char *space
, const char *name
,
1451 internal_pragma_handler ihandler
, bool allow_expansion
)
1455 if (flag_preprocess_only
)
1457 pragma_ns_name ns_name
;
1459 if (!allow_expansion
)
1462 ns_name
.space
= space
;
1463 ns_name
.name
= name
;
1464 registered_pp_pragmas
.safe_push (ns_name
);
1465 id
= registered_pp_pragmas
.length ();
1466 id
+= PRAGMA_FIRST_EXTERNAL
- 1;
1470 registered_pragmas
.safe_push (ihandler
);
1471 id
= registered_pragmas
.length ();
1472 id
+= PRAGMA_FIRST_EXTERNAL
- 1;
1474 /* The C front end allocates 8 bits in c_token. The C++ front end
1475 keeps the pragma kind in the form of INTEGER_CST, so no small
1476 limit applies. At present this is sufficient. */
1477 gcc_assert (id
< 256);
1480 cpp_register_deferred_pragma (parse_in
, space
, name
, id
,
1481 allow_expansion
, false);
1484 /* Register a C pragma handler, using a space and a name. It disallows pragma
1485 expansion (if you want it, use c_register_pragma_with_expansion instead). */
1487 c_register_pragma (const char *space
, const char *name
,
1488 pragma_handler_1arg handler
)
1490 internal_pragma_handler ihandler
;
1492 ihandler
.handler
.handler_1arg
= handler
;
1493 ihandler
.extra_data
= false;
1494 ihandler
.data
= NULL
;
1495 c_register_pragma_1 (space
, name
, ihandler
, false);
1498 /* Register a C pragma handler, using a space and a name, it also carries an
1499 extra data field which can be used by the handler. It disallows pragma
1500 expansion (if you want it, use c_register_pragma_with_expansion_and_data
1503 c_register_pragma_with_data (const char *space
, const char *name
,
1504 pragma_handler_2arg handler
, void * data
)
1506 internal_pragma_handler ihandler
;
1508 ihandler
.handler
.handler_2arg
= handler
;
1509 ihandler
.extra_data
= true;
1510 ihandler
.data
= data
;
1511 c_register_pragma_1 (space
, name
, ihandler
, false);
1514 /* Register a C pragma handler, using a space and a name. It allows pragma
1515 expansion as in the following example:
1518 #pragma count (NUMBER)
1520 Name expansion is still disallowed. */
1522 c_register_pragma_with_expansion (const char *space
, const char *name
,
1523 pragma_handler_1arg handler
)
1525 internal_pragma_handler ihandler
;
1527 ihandler
.handler
.handler_1arg
= handler
;
1528 ihandler
.extra_data
= false;
1529 ihandler
.data
= NULL
;
1530 c_register_pragma_1 (space
, name
, ihandler
, true);
1533 /* Register a C pragma handler, using a space and a name, it also carries an
1534 extra data field which can be used by the handler. It allows pragma
1535 expansion as in the following example:
1538 #pragma count (NUMBER)
1540 Name expansion is still disallowed. */
1542 c_register_pragma_with_expansion_and_data (const char *space
, const char *name
,
1543 pragma_handler_2arg handler
,
1546 internal_pragma_handler ihandler
;
1548 ihandler
.handler
.handler_2arg
= handler
;
1549 ihandler
.extra_data
= true;
1550 ihandler
.data
= data
;
1551 c_register_pragma_1 (space
, name
, ihandler
, true);
1555 c_invoke_pragma_handler (unsigned int id
)
1557 internal_pragma_handler
*ihandler
;
1558 pragma_handler_1arg handler_1arg
;
1559 pragma_handler_2arg handler_2arg
;
1561 id
-= PRAGMA_FIRST_EXTERNAL
;
1562 ihandler
= ®istered_pragmas
[id
];
1563 if (ihandler
->extra_data
)
1565 handler_2arg
= ihandler
->handler
.handler_2arg
;
1566 handler_2arg (parse_in
, ihandler
->data
);
1570 handler_1arg
= ihandler
->handler
.handler_1arg
;
1571 handler_1arg (parse_in
);
1575 /* Set up front-end pragmas. */
1581 const int n_oacc_pragmas
1582 = sizeof (oacc_pragmas
) / sizeof (*oacc_pragmas
);
1585 for (i
= 0; i
< n_oacc_pragmas
; ++i
)
1586 cpp_register_deferred_pragma (parse_in
, "acc", oacc_pragmas
[i
].name
,
1587 oacc_pragmas
[i
].id
, true, true);
1592 const int n_omp_pragmas
= sizeof (omp_pragmas
) / sizeof (*omp_pragmas
);
1595 for (i
= 0; i
< n_omp_pragmas
; ++i
)
1596 cpp_register_deferred_pragma (parse_in
, "omp", omp_pragmas
[i
].name
,
1597 omp_pragmas
[i
].id
, true, true);
1599 if (flag_openmp
|| flag_openmp_simd
)
1601 const int n_omp_pragmas_simd
= sizeof (omp_pragmas_simd
)
1602 / sizeof (*omp_pragmas
);
1605 for (i
= 0; i
< n_omp_pragmas_simd
; ++i
)
1606 cpp_register_deferred_pragma (parse_in
, "omp", omp_pragmas_simd
[i
].name
,
1607 omp_pragmas_simd
[i
].id
, true, true);
1610 if (!flag_preprocess_only
)
1611 cpp_register_deferred_pragma (parse_in
, "GCC", "pch_preprocess",
1612 PRAGMA_GCC_PCH_PREPROCESS
, false, false);
1614 if (!flag_preprocess_only
)
1615 cpp_register_deferred_pragma (parse_in
, "GCC", "ivdep", PRAGMA_IVDEP
, false,
1618 if (!flag_preprocess_only
)
1619 cpp_register_deferred_pragma (parse_in
, "GCC", "unroll", PRAGMA_UNROLL
,
1622 #ifdef HANDLE_PRAGMA_PACK_WITH_EXPANSION
1623 c_register_pragma_with_expansion (0, "pack", handle_pragma_pack
);
1625 c_register_pragma (0, "pack", handle_pragma_pack
);
1627 c_register_pragma (0, "weak", handle_pragma_weak
);
1629 c_register_pragma ("GCC", "visibility", handle_pragma_visibility
);
1631 c_register_pragma ("GCC", "diagnostic", handle_pragma_diagnostic
);
1632 c_register_pragma ("GCC", "target", handle_pragma_target
);
1633 c_register_pragma ("GCC", "optimize", handle_pragma_optimize
);
1634 c_register_pragma ("GCC", "push_options", handle_pragma_push_options
);
1635 c_register_pragma ("GCC", "pop_options", handle_pragma_pop_options
);
1636 c_register_pragma ("GCC", "reset_options", handle_pragma_reset_options
);
1638 c_register_pragma ("STDC", "FLOAT_CONST_DECIMAL64",
1639 handle_pragma_float_const_decimal64
);
1641 c_register_pragma_with_expansion (0, "redefine_extname",
1642 handle_pragma_redefine_extname
);
1644 c_register_pragma_with_expansion (0, "message", handle_pragma_message
);
1646 #ifdef REGISTER_TARGET_PRAGMAS
1647 REGISTER_TARGET_PRAGMAS ();
1650 global_sso
= default_sso
;
1651 c_register_pragma (0, "scalar_storage_order",
1652 handle_pragma_scalar_storage_order
);
1654 /* Allow plugins to register their own pragmas. */
1655 invoke_plugin_callbacks (PLUGIN_PRAGMAS
, NULL
);
1658 #include "gt-c-family-c-pragma.h"