1 /* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack.
2 Copyright (C) 1992-2015 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"
27 #include "double-int.h"
35 #include "stringpool.h"
42 #include "hard-reg-set.h"
44 #include "function.h" /* For cfun. FIXME: Does the parser know
45 when it is inside a function, so that
46 we don't have to look at cfun? */
50 #include "langhooks.h"
53 #include "tm_p.h" /* For REGISTER_TARGET_PRAGMAS (why is
54 this not a target hook?). */
56 #include "diagnostic.h"
61 #include "plugin-api.h"
65 #define GCC_BAD(gmsgid) \
66 do { warning (OPT_Wpragmas, gmsgid); return; } while (0)
67 #define GCC_BAD2(gmsgid, arg) \
68 do { warning (OPT_Wpragmas, gmsgid, arg); return; } while (0)
70 typedef struct GTY(()) align_stack
{
73 struct align_stack
* prev
;
76 static GTY(()) struct align_stack
* alignment_stack
;
78 static void handle_pragma_pack (cpp_reader
*);
80 /* If we have a "global" #pragma pack(<n>) in effect when the first
81 #pragma pack(push,<n>) is encountered, this stores the value of
82 maximum_field_alignment in effect. When the final pop_alignment()
83 happens, we restore the value to this, not to a value of 0 for
84 maximum_field_alignment. Value is in bits. */
85 static int default_alignment
;
86 #define SET_GLOBAL_ALIGNMENT(ALIGN) (maximum_field_alignment = *(alignment_stack == NULL \
87 ? &default_alignment \
88 : &alignment_stack->alignment) = (ALIGN))
90 static void push_alignment (int, tree
);
91 static void pop_alignment (tree
);
93 /* Push an alignment value onto the stack. */
95 push_alignment (int alignment
, tree id
)
97 align_stack
* entry
= ggc_alloc
<align_stack
> ();
99 entry
->alignment
= alignment
;
101 entry
->prev
= alignment_stack
;
103 /* The current value of maximum_field_alignment is not necessarily
104 0 since there may be a #pragma pack(<n>) in effect; remember it
105 so that we can restore it after the final #pragma pop(). */
106 if (alignment_stack
== NULL
)
107 default_alignment
= maximum_field_alignment
;
109 alignment_stack
= entry
;
111 maximum_field_alignment
= alignment
;
114 /* Undo a push of an alignment onto the stack. */
116 pop_alignment (tree id
)
120 if (alignment_stack
== NULL
)
121 GCC_BAD ("#pragma pack (pop) encountered without matching #pragma pack (push)");
123 /* If we got an identifier, strip away everything above the target
124 entry so that the next step will restore the state just below it. */
127 for (entry
= alignment_stack
; entry
; entry
= entry
->prev
)
130 alignment_stack
= entry
;
134 warning (OPT_Wpragmas
, "\
135 #pragma pack(pop, %E) encountered without matching #pragma pack(push, %E)"
139 entry
= alignment_stack
->prev
;
141 maximum_field_alignment
= entry
? entry
->alignment
: default_alignment
;
143 alignment_stack
= entry
;
150 #pragma pack (push, N)
151 #pragma pack (push, ID)
152 #pragma pack (push, ID, N)
154 #pragma pack (pop, ID) */
156 handle_pragma_pack (cpp_reader
* ARG_UNUSED (dummy
))
160 enum cpp_ttype token
;
161 enum { set
, push
, pop
} action
;
163 if (pragma_lex (&x
) != CPP_OPEN_PAREN
)
164 GCC_BAD ("missing %<(%> after %<#pragma pack%> - ignored");
166 token
= pragma_lex (&x
);
167 if (token
== CPP_CLOSE_PAREN
)
170 align
= initial_max_fld_align
;
172 else if (token
== CPP_NUMBER
)
174 if (TREE_CODE (x
) != INTEGER_CST
)
175 GCC_BAD ("invalid constant in %<#pragma pack%> - ignored");
176 align
= TREE_INT_CST_LOW (x
);
178 if (pragma_lex (&x
) != CPP_CLOSE_PAREN
)
179 GCC_BAD ("malformed %<#pragma pack%> - ignored");
181 else if (token
== CPP_NAME
)
183 #define GCC_BAD_ACTION do { if (action != pop) \
184 GCC_BAD ("malformed %<#pragma pack(push[, id][, <n>])%> - ignored"); \
186 GCC_BAD ("malformed %<#pragma pack(pop[, id])%> - ignored"); \
189 const char *op
= IDENTIFIER_POINTER (x
);
190 if (!strcmp (op
, "push"))
192 else if (!strcmp (op
, "pop"))
195 GCC_BAD2 ("unknown action %qE for %<#pragma pack%> - ignored", x
);
197 while ((token
= pragma_lex (&x
)) == CPP_COMMA
)
199 token
= pragma_lex (&x
);
200 if (token
== CPP_NAME
&& id
== 0)
204 else if (token
== CPP_NUMBER
&& action
== push
&& align
== -1)
206 if (TREE_CODE (x
) != INTEGER_CST
)
207 GCC_BAD ("invalid constant in %<#pragma pack%> - ignored");
208 align
= TREE_INT_CST_LOW (x
);
216 if (token
!= CPP_CLOSE_PAREN
)
218 #undef GCC_BAD_ACTION
221 GCC_BAD ("malformed %<#pragma pack%> - ignored");
223 if (pragma_lex (&x
) != CPP_EOF
)
224 warning (OPT_Wpragmas
, "junk at end of %<#pragma pack%>");
226 if (flag_pack_struct
)
227 GCC_BAD ("#pragma pack has no effect with -fpack-struct - ignored");
238 align
*= BITS_PER_UNIT
;
243 align
= maximum_field_alignment
;
247 GCC_BAD2 ("alignment must be a small power of two, not %d", align
);
252 case set
: SET_GLOBAL_ALIGNMENT (align
); break;
253 case push
: push_alignment (align
, id
); break;
254 case pop
: pop_alignment (id
); break;
258 typedef struct GTY(()) pending_weak_d
265 static GTY(()) vec
<pending_weak
, va_gc
> *pending_weaks
;
267 static void apply_pragma_weak (tree
, tree
);
268 static void handle_pragma_weak (cpp_reader
*);
271 apply_pragma_weak (tree decl
, tree value
)
275 value
= build_string (IDENTIFIER_LENGTH (value
),
276 IDENTIFIER_POINTER (value
));
277 decl_attributes (&decl
, build_tree_list (get_identifier ("alias"),
278 build_tree_list (NULL
, value
)),
282 if (SUPPORTS_WEAK
&& DECL_EXTERNAL (decl
) && TREE_USED (decl
)
283 && !DECL_WEAK (decl
) /* Don't complain about a redundant #pragma. */
284 && DECL_ASSEMBLER_NAME_SET_P (decl
)
285 && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
286 warning (OPT_Wpragmas
, "applying #pragma weak %q+D after first use "
287 "results in unspecified behavior", decl
);
293 maybe_apply_pragma_weak (tree decl
)
299 /* Avoid asking for DECL_ASSEMBLER_NAME when it's not needed. */
301 /* No weak symbols pending, take the short-cut. */
302 if (vec_safe_is_empty (pending_weaks
))
304 /* If it's not visible outside this file, it doesn't matter whether
306 if (!DECL_EXTERNAL (decl
) && !TREE_PUBLIC (decl
))
308 /* If it's not a function or a variable, it can't be weak.
309 FIXME: what kinds of things are visible outside this file but
310 aren't functions or variables? Should this be an assert instead? */
311 if (TREE_CODE (decl
) != FUNCTION_DECL
&& TREE_CODE (decl
) != VAR_DECL
)
314 if (DECL_ASSEMBLER_NAME_SET_P (decl
))
315 id
= DECL_ASSEMBLER_NAME (decl
);
318 id
= DECL_ASSEMBLER_NAME (decl
);
319 SET_DECL_ASSEMBLER_NAME (decl
, NULL_TREE
);
322 FOR_EACH_VEC_ELT (*pending_weaks
, i
, pe
)
325 apply_pragma_weak (decl
, pe
->value
);
326 pending_weaks
->unordered_remove (i
);
331 /* Process all "#pragma weak A = B" directives where we have not seen
334 maybe_apply_pending_pragma_weaks (void)
336 tree alias_id
, id
, decl
;
341 if (vec_safe_is_empty (pending_weaks
))
344 FOR_EACH_VEC_ELT (*pending_weaks
, i
, pe
)
352 target
= symtab_node::get_for_asmname (id
);
353 decl
= build_decl (UNKNOWN_LOCATION
,
354 target
? TREE_CODE (target
->decl
) : FUNCTION_DECL
,
355 alias_id
, default_function_type
);
357 DECL_ARTIFICIAL (decl
) = 1;
358 TREE_PUBLIC (decl
) = 1;
359 DECL_WEAK (decl
) = 1;
360 if (TREE_CODE (decl
) == VAR_DECL
)
361 TREE_STATIC (decl
) = 1;
364 error ("%q+D aliased to undefined symbol %qE",
369 assemble_alias (decl
, id
);
373 /* #pragma weak name [= value] */
375 handle_pragma_weak (cpp_reader
* ARG_UNUSED (dummy
))
377 tree name
, value
, x
, decl
;
382 if (pragma_lex (&name
) != CPP_NAME
)
383 GCC_BAD ("malformed #pragma weak, ignored");
387 if (pragma_lex (&value
) != CPP_NAME
)
388 GCC_BAD ("malformed #pragma weak, ignored");
392 warning (OPT_Wpragmas
, "junk at end of %<#pragma weak%>");
394 decl
= identifier_global_value (name
);
395 if (decl
&& DECL_P (decl
))
397 if (!VAR_OR_FUNCTION_DECL_P (decl
))
398 GCC_BAD2 ("%<#pragma weak%> declaration of %q+D not allowed,"
400 apply_pragma_weak (decl
, value
);
403 DECL_EXTERNAL (decl
) = 0;
404 if (TREE_CODE (decl
) == VAR_DECL
)
405 TREE_STATIC (decl
) = 1;
406 assemble_alias (decl
, value
);
411 pending_weak pe
= {name
, value
};
412 vec_safe_push (pending_weaks
, pe
);
416 /* GCC supports two #pragma directives for renaming the external
417 symbol associated with a declaration (DECL_ASSEMBLER_NAME), for
418 compatibility with the Solaris and VMS system headers. GCC also
419 has its own notation for this, __asm__("name") annotations.
421 Corner cases of these features and their interaction:
423 1) Both pragmas silently apply only to declarations with external
424 linkage (that is, TREE_PUBLIC || DECL_EXTERNAL). Asm labels
425 do not have this restriction.
427 2) In C++, both #pragmas silently apply only to extern "C" declarations.
428 Asm labels do not have this restriction.
430 3) If any of the three ways of changing DECL_ASSEMBLER_NAME is
431 applied to a decl whose DECL_ASSEMBLER_NAME is already set, and the
432 new name is different, a warning issues and the name does not change.
434 4) The "source name" for #pragma redefine_extname is the DECL_NAME,
435 *not* the DECL_ASSEMBLER_NAME.
437 5) If #pragma extern_prefix is in effect and a declaration occurs
438 with an __asm__ name, the #pragma extern_prefix is silently
439 ignored for that declaration.
441 6) If #pragma extern_prefix and #pragma redefine_extname apply to
442 the same declaration, whichever triggered first wins, and a warning
443 is issued. (We would like to have #pragma redefine_extname always
444 win, but it can appear either before or after the declaration, and
445 if it appears afterward, we have no way of knowing whether a modified
446 DECL_ASSEMBLER_NAME is due to #pragma extern_prefix.) */
448 typedef struct GTY(()) pending_redefinition_d
{
451 } pending_redefinition
;
454 static GTY(()) vec
<pending_redefinition
, va_gc
> *pending_redefine_extname
;
456 static void handle_pragma_redefine_extname (cpp_reader
*);
458 /* #pragma redefine_extname oldname newname */
460 handle_pragma_redefine_extname (cpp_reader
* ARG_UNUSED (dummy
))
462 tree oldname
, newname
, decls
, x
;
466 if (pragma_lex (&oldname
) != CPP_NAME
)
467 GCC_BAD ("malformed #pragma redefine_extname, ignored");
468 if (pragma_lex (&newname
) != CPP_NAME
)
469 GCC_BAD ("malformed #pragma redefine_extname, ignored");
472 warning (OPT_Wpragmas
, "junk at end of %<#pragma redefine_extname%>");
475 for (decls
= c_linkage_bindings (oldname
);
479 if (TREE_CODE (decls
) == TREE_LIST
)
481 decl
= TREE_VALUE (decls
);
482 decls
= TREE_CHAIN (decls
);
490 if ((TREE_PUBLIC (decl
) || DECL_EXTERNAL (decl
))
491 && (TREE_CODE (decl
) == FUNCTION_DECL
492 || TREE_CODE (decl
) == VAR_DECL
))
495 if (DECL_ASSEMBLER_NAME_SET_P (decl
))
497 const char *name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
498 name
= targetm
.strip_name_encoding (name
);
500 if (strcmp (name
, IDENTIFIER_POINTER (newname
)))
501 warning (OPT_Wpragmas
, "#pragma redefine_extname ignored due to "
502 "conflict with previous rename");
505 symtab
->change_decl_assembler_name (decl
, newname
);
510 /* We have to add this to the rename list even if there's already
511 a global value that doesn't meet the above criteria, because in
512 C++ "struct foo {...};" puts "foo" in the current namespace but
513 does *not* conflict with a subsequent declaration of a function
514 or variable foo. See g++.dg/other/pragma-re-2.C. */
515 add_to_renaming_pragma_list (oldname
, newname
);
518 /* This is called from here and from ia64-c.c. */
520 add_to_renaming_pragma_list (tree oldname
, tree newname
)
523 pending_redefinition
*p
;
525 FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname
, ix
, p
)
526 if (oldname
== p
->oldname
)
528 if (p
->newname
!= newname
)
529 warning (OPT_Wpragmas
, "#pragma redefine_extname ignored due to "
530 "conflict with previous #pragma redefine_extname");
534 pending_redefinition e
= {oldname
, newname
};
535 vec_safe_push (pending_redefine_extname
, e
);
538 /* The current prefix set by #pragma extern_prefix. */
539 GTY(()) tree pragma_extern_prefix
;
541 /* variables used to implement #pragma upc semantics */
542 #ifndef UPC_CMODE_STACK_INCREMENT
543 #define UPC_CMODE_STACK_INCREMENT 32
545 static int pragma_upc_permitted
;
546 static int upc_cmode
;
547 static int *upc_cmode_stack
;
548 static int upc_cmode_stack_in_use
;
549 static int upc_cmode_stack_allocated
;
551 static void init_pragma_upc (void);
552 static void handle_pragma_upc (cpp_reader
* ARG_UNUSED (dummy
));
554 /* Initialize the variables used to manage the current UPC consistency
555 mode (strict/relaxed) */
558 init_pragma_upc (void)
560 pragma_upc_permitted
= 0;
562 upc_cmode_stack
= (int *) xcalloc (UPC_CMODE_STACK_INCREMENT
,
564 upc_cmode_stack_allocated
= UPC_CMODE_STACK_INCREMENT
;
565 upc_cmode_stack_in_use
= 0;
570 * #pragma upc relaxed
571 * #pragma upc upc_code
575 handle_pragma_upc (cpp_reader
* ARG_UNUSED (dummy
))
579 enum upc_pragma_op
{p_strict
, p_relaxed
, p_upc_code
,
580 p_c_code
, p_detect_upc
, p_unknown
};
581 enum upc_pragma_op upc_pragma
= p_unknown
;
586 const char *op
= IDENTIFIER_POINTER (x
);
587 if (!strcmp (op
, "strict"))
588 upc_pragma
= p_strict
;
589 else if (!strcmp (op
, "relaxed"))
590 upc_pragma
= p_relaxed
;
591 else if (!strcmp (op
, "upc_code"))
592 upc_pragma
= p_upc_code
;
593 else if (!strcmp (op
, "c_code"))
594 upc_pragma
= p_c_code
;
595 else if (!strcmp (op
, "detect_upc"))
597 const char *detect_op
;
598 upc_pragma
= p_detect_upc
;
601 GCC_BAD ("missing [suspend_insertion|resume_insertion]"
602 " after %<#pragma UPC detect_upc%>");
603 detect_op
= IDENTIFIER_POINTER (x
);
604 if (strcmp (detect_op
, "suspend_insertion") == 0)
606 else if (strcmp (detect_op
, "resume_insertion") == 0)
609 GCC_BAD ("expected [suspend_insertion|resume_insertion]"
610 " after %<#pragma UPC detect_upc%>");
613 GCC_BAD2 ("unknown action '%s' for '#pragma upc' - ignored", op
);
616 warning (OPT_Wpragmas
, "missing parameter after #pragma upc");
620 warning (OPT_Wpragmas
, "junk at end of #pragma upc");
622 if ((upc_pragma
== p_strict
) || (upc_pragma
== p_relaxed
))
624 if (pragma_upc_permitted_p ())
626 int consistency_mode
= (upc_pragma
== p_strict
);
627 set_upc_consistency_mode (consistency_mode
);
630 warning (OPT_Wpragmas
, "#pragma upc not allowed in this context");
632 else if ((upc_pragma
== p_upc_code
) || (upc_pragma
== p_c_code
))
634 flag_upc
= (upc_pragma
== p_upc_code
);
635 lang_hooks
.upc
.toggle_keywords (flag_upc
);
637 else if (upc_pragma
== p_detect_upc
)
639 /* Skip: This is a Berkeley-specific pragma that requires no action. */
643 /* Set the current setting of the UPC consistency mode
644 that is in effect. */
647 set_upc_consistency_mode (int mode
)
652 /* Return the current setting of the UPC consistency mode. */
655 get_upc_consistency_mode (void)
660 /* Called from the parser just after the bracket that opens a compound
661 statement has been parsed. Set the flag that allows the pragma
665 permit_pragma_upc (void)
667 pragma_upc_permitted
= 1;
670 /* Called just before the body of a compound statement is parsed.
671 Clear the flag that allows the pragma. */
674 deny_pragma_upc (void)
676 pragma_upc_permitted
= 0;
679 /* A #pragma upc is permitted either at the outermost scope,
680 or directly after the bracket that opens a compound statement. */
683 pragma_upc_permitted_p (void)
685 return !current_function_decl
|| pragma_upc_permitted
;
688 /* Called at the beginning of every compound statement.
689 Pushes the old value of the current UPC consistency mode
693 push_upc_consistency_mode (void)
695 if (upc_cmode_stack_in_use
== upc_cmode_stack_allocated
)
697 upc_cmode_stack_allocated
+= UPC_CMODE_STACK_INCREMENT
;
698 upc_cmode_stack
= (int *) xrealloc (upc_cmode_stack
,
699 upc_cmode_stack_allocated
* sizeof (int));
701 upc_cmode_stack
[upc_cmode_stack_in_use
++] = upc_cmode
;
704 /* Called at the end of every compound statement.
705 Sets the current consistency mode to the previously saved value. */
708 pop_upc_consistency_mode (void)
710 if (upc_cmode_stack_in_use
<= 0)
712 upc_cmode
= upc_cmode_stack
[--upc_cmode_stack_in_use
];
715 static int pragma_pupc_on
;
716 static void init_pragma_pupc (void);
717 static void handle_pragma_pupc (cpp_reader
*);
719 /* Pragma pupc defaults to being on */
721 init_pragma_pupc (void)
727 get_upc_pupc_mode (void)
729 return pragma_pupc_on
;
733 disable_pupc_mode (void)
735 int old_pupc
= pragma_pupc_on
;
741 set_pupc_mode (int new_pupc
)
743 pragma_pupc_on
= new_pupc
;
751 handle_pragma_pupc (cpp_reader
*dummy ATTRIBUTE_UNUSED
)
758 const char *op
= IDENTIFIER_POINTER (x
);
759 if (!strcmp (op
, "on"))
761 else if (!strcmp (op
, "off"))
764 GCC_BAD2 ("unknown action '%s' for '#pragma pupc' - ignored", op
);
769 warning (OPT_Wpragmas
, "junk at end of #pragma pupc");
772 /* Hook from the front ends to apply the results of one of the preceding
773 pragmas that rename variables. */
776 maybe_apply_renaming_pragma (tree decl
, tree asmname
)
779 pending_redefinition
*p
;
781 /* The renaming pragmas are only applied to declarations with
783 if ((TREE_CODE (decl
) != FUNCTION_DECL
&& TREE_CODE (decl
) != VAR_DECL
)
784 || (!TREE_PUBLIC (decl
) && !DECL_EXTERNAL (decl
))
785 || !has_c_linkage (decl
))
788 /* If the DECL_ASSEMBLER_NAME is already set, it does not change,
789 but we may warn about a rename that conflicts. */
790 if (DECL_ASSEMBLER_NAME_SET_P (decl
))
792 const char *oldname
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
793 oldname
= targetm
.strip_name_encoding (oldname
);
795 if (asmname
&& strcmp (TREE_STRING_POINTER (asmname
), oldname
))
796 warning (OPT_Wpragmas
, "asm declaration ignored due to "
797 "conflict with previous rename");
799 /* Take any pending redefine_extname off the list. */
800 FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname
, ix
, p
)
801 if (DECL_NAME (decl
) == p
->oldname
)
803 /* Only warn if there is a conflict. */
804 if (strcmp (IDENTIFIER_POINTER (p
->newname
), oldname
))
805 warning (OPT_Wpragmas
, "#pragma redefine_extname ignored due to "
806 "conflict with previous rename");
808 pending_redefine_extname
->unordered_remove (ix
);
814 /* Find out if we have a pending #pragma redefine_extname. */
815 FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname
, ix
, p
)
816 if (DECL_NAME (decl
) == p
->oldname
)
818 tree newname
= p
->newname
;
819 pending_redefine_extname
->unordered_remove (ix
);
821 /* If we already have an asmname, #pragma redefine_extname is
822 ignored (with a warning if it conflicts). */
825 if (strcmp (TREE_STRING_POINTER (asmname
),
826 IDENTIFIER_POINTER (newname
)) != 0)
827 warning (OPT_Wpragmas
, "#pragma redefine_extname ignored due to "
828 "conflict with __asm__ declaration");
832 /* Otherwise we use what we've got; #pragma extern_prefix is
834 return build_string (IDENTIFIER_LENGTH (newname
),
835 IDENTIFIER_POINTER (newname
));
838 /* If we've got an asmname, #pragma extern_prefix is silently ignored. */
842 /* If #pragma extern_prefix is in effect, apply it. */
843 if (pragma_extern_prefix
)
845 const char *prefix
= TREE_STRING_POINTER (pragma_extern_prefix
);
846 size_t plen
= TREE_STRING_LENGTH (pragma_extern_prefix
) - 1;
848 const char *id
= IDENTIFIER_POINTER (DECL_NAME (decl
));
849 size_t ilen
= IDENTIFIER_LENGTH (DECL_NAME (decl
));
851 char *newname
= (char *) alloca (plen
+ ilen
+ 1);
853 memcpy (newname
, prefix
, plen
);
854 memcpy (newname
+ plen
, id
, ilen
+ 1);
856 return build_string (plen
+ ilen
, newname
);
864 static void handle_pragma_visibility (cpp_reader
*);
866 static vec
<int> visstack
;
868 /* Push the visibility indicated by STR onto the top of the #pragma
869 visibility stack. KIND is 0 for #pragma GCC visibility, 1 for
870 C++ namespace with visibility attribute and 2 for C++ builtin
871 ABI namespace. push_visibility/pop_visibility calls must have
872 matching KIND, it is not allowed to push visibility using one
873 KIND and pop using a different one. */
876 push_visibility (const char *str
, int kind
)
878 visstack
.safe_push (((int) default_visibility
) | (kind
<< 8));
879 if (!strcmp (str
, "default"))
880 default_visibility
= VISIBILITY_DEFAULT
;
881 else if (!strcmp (str
, "internal"))
882 default_visibility
= VISIBILITY_INTERNAL
;
883 else if (!strcmp (str
, "hidden"))
884 default_visibility
= VISIBILITY_HIDDEN
;
885 else if (!strcmp (str
, "protected"))
886 default_visibility
= VISIBILITY_PROTECTED
;
888 GCC_BAD ("#pragma GCC visibility push() must specify default, internal, hidden or protected");
889 visibility_options
.inpragma
= 1;
892 /* Pop a level of the #pragma visibility stack. Return true if
896 pop_visibility (int kind
)
898 if (!visstack
.length ())
900 if ((visstack
.last () >> 8) != kind
)
903 = (enum symbol_visibility
) (visstack
.pop () & 0xff);
904 visibility_options
.inpragma
905 = visstack
.length () != 0;
909 /* Sets the default visibility for symbols to something other than that
910 specified on the command line. */
913 handle_pragma_visibility (cpp_reader
*dummy ATTRIBUTE_UNUSED
)
915 /* Form is #pragma GCC visibility push(hidden)|pop */
917 enum cpp_ttype token
;
918 enum { bad
, push
, pop
} action
= bad
;
920 token
= pragma_lex (&x
);
921 if (token
== CPP_NAME
)
923 const char *op
= IDENTIFIER_POINTER (x
);
924 if (!strcmp (op
, "push"))
926 else if (!strcmp (op
, "pop"))
930 GCC_BAD ("#pragma GCC visibility must be followed by push or pop");
935 if (! pop_visibility (0))
936 GCC_BAD ("no matching push for %<#pragma GCC visibility pop%>");
940 if (pragma_lex (&x
) != CPP_OPEN_PAREN
)
941 GCC_BAD ("missing %<(%> after %<#pragma GCC visibility push%> - ignored");
942 token
= pragma_lex (&x
);
943 if (token
!= CPP_NAME
)
944 GCC_BAD ("malformed #pragma GCC visibility push");
946 push_visibility (IDENTIFIER_POINTER (x
), 0);
947 if (pragma_lex (&x
) != CPP_CLOSE_PAREN
)
948 GCC_BAD ("missing %<(%> after %<#pragma GCC visibility push%> - ignored");
951 if (pragma_lex (&x
) != CPP_EOF
)
952 warning (OPT_Wpragmas
, "junk at end of %<#pragma GCC visibility%>");
956 handle_pragma_diagnostic(cpp_reader
*ARG_UNUSED(dummy
))
958 const char *kind_string
, *option_string
;
959 unsigned int option_index
;
960 enum cpp_ttype token
;
963 struct cl_option_handlers handlers
;
965 token
= pragma_lex (&x
);
966 if (token
!= CPP_NAME
)
967 GCC_BAD ("missing [error|warning|ignored] after %<#pragma GCC diagnostic%>");
968 kind_string
= IDENTIFIER_POINTER (x
);
969 if (strcmp (kind_string
, "error") == 0)
971 else if (strcmp (kind_string
, "warning") == 0)
973 else if (strcmp (kind_string
, "ignored") == 0)
975 else if (strcmp (kind_string
, "push") == 0)
977 diagnostic_push_diagnostics (global_dc
, input_location
);
980 else if (strcmp (kind_string
, "pop") == 0)
982 diagnostic_pop_diagnostics (global_dc
, input_location
);
986 GCC_BAD ("expected [error|warning|ignored|push|pop] after %<#pragma GCC diagnostic%>");
988 token
= pragma_lex (&x
);
989 if (token
!= CPP_STRING
)
990 GCC_BAD ("missing option after %<#pragma GCC diagnostic%> kind");
991 option_string
= TREE_STRING_POINTER (x
);
992 set_default_handlers (&handlers
);
993 for (option_index
= 0; option_index
< cl_options_count
; option_index
++)
994 if (strcmp (cl_options
[option_index
].opt_text
, option_string
) == 0)
996 control_warning_option (option_index
, (int) kind
, kind
!= DK_IGNORED
,
997 input_location
, c_family_lang_mask
, &handlers
,
998 &global_options
, &global_options_set
,
1002 GCC_BAD ("unknown option after %<#pragma GCC diagnostic%> kind");
1005 /* Parse #pragma GCC target (xxx) to set target specific options. */
1007 handle_pragma_target(cpp_reader
*ARG_UNUSED(dummy
))
1009 enum cpp_ttype token
;
1011 bool close_paren_needed_p
= false;
1015 error ("#pragma GCC option is not allowed inside functions");
1019 token
= pragma_lex (&x
);
1020 if (token
== CPP_OPEN_PAREN
)
1022 close_paren_needed_p
= true;
1023 token
= pragma_lex (&x
);
1026 if (token
!= CPP_STRING
)
1028 GCC_BAD ("%<#pragma GCC option%> is not a string");
1032 /* Strings are user options. */
1035 tree args
= NULL_TREE
;
1039 /* Build up the strings now as a tree linked list. Skip empty
1041 if (TREE_STRING_LENGTH (x
) > 0)
1042 args
= tree_cons (NULL_TREE
, x
, args
);
1044 token
= pragma_lex (&x
);
1045 while (token
== CPP_COMMA
)
1046 token
= pragma_lex (&x
);
1048 while (token
== CPP_STRING
);
1050 if (close_paren_needed_p
)
1052 if (token
== CPP_CLOSE_PAREN
)
1053 token
= pragma_lex (&x
);
1055 GCC_BAD ("%<#pragma GCC target (string [,string]...)%> does "
1056 "not have a final %<)%>");
1059 if (token
!= CPP_EOF
)
1061 error ("#pragma GCC target string... is badly formed");
1065 /* put arguments in the order the user typed them. */
1066 args
= nreverse (args
);
1068 if (targetm
.target_option
.pragma_parse (args
, NULL_TREE
))
1069 current_target_pragma
= args
;
1073 /* Handle #pragma GCC optimize to set optimization options. */
1075 handle_pragma_optimize (cpp_reader
*ARG_UNUSED(dummy
))
1077 enum cpp_ttype token
;
1079 bool close_paren_needed_p
= false;
1080 tree optimization_previous_node
= optimization_current_node
;
1084 error ("#pragma GCC optimize is not allowed inside functions");
1088 token
= pragma_lex (&x
);
1089 if (token
== CPP_OPEN_PAREN
)
1091 close_paren_needed_p
= true;
1092 token
= pragma_lex (&x
);
1095 if (token
!= CPP_STRING
&& token
!= CPP_NUMBER
)
1097 GCC_BAD ("%<#pragma GCC optimize%> is not a string or number");
1101 /* Strings/numbers are user options. */
1104 tree args
= NULL_TREE
;
1108 /* Build up the numbers/strings now as a list. */
1109 if (token
!= CPP_STRING
|| TREE_STRING_LENGTH (x
) > 0)
1110 args
= tree_cons (NULL_TREE
, x
, args
);
1112 token
= pragma_lex (&x
);
1113 while (token
== CPP_COMMA
)
1114 token
= pragma_lex (&x
);
1116 while (token
== CPP_STRING
|| token
== CPP_NUMBER
);
1118 if (close_paren_needed_p
)
1120 if (token
== CPP_CLOSE_PAREN
)
1121 token
= pragma_lex (&x
);
1123 GCC_BAD ("%<#pragma GCC optimize (string [,string]...)%> does "
1124 "not have a final %<)%>");
1127 if (token
!= CPP_EOF
)
1129 error ("#pragma GCC optimize string... is badly formed");
1133 /* put arguments in the order the user typed them. */
1134 args
= nreverse (args
);
1136 parse_optimize_options (args
, false);
1137 current_optimize_pragma
= chainon (current_optimize_pragma
, args
);
1138 optimization_current_node
= build_optimization_node (&global_options
);
1139 c_cpp_builtins_optimize_pragma (parse_in
,
1140 optimization_previous_node
,
1141 optimization_current_node
);
1145 /* Stack of the #pragma GCC options created with #pragma GCC push_option. Save
1146 both the binary representation of the options and the TREE_LIST of
1147 strings that will be added to the function's attribute list. */
1148 typedef struct GTY(()) opt_stack
{
1149 struct opt_stack
*prev
;
1151 tree target_strings
;
1152 tree optimize_binary
;
1153 tree optimize_strings
;
1156 static GTY(()) struct opt_stack
* options_stack
;
1158 /* Handle #pragma GCC push_options to save the current target and optimization
1162 handle_pragma_push_options (cpp_reader
*ARG_UNUSED(dummy
))
1164 enum cpp_ttype token
;
1167 token
= pragma_lex (&x
);
1168 if (token
!= CPP_EOF
)
1170 warning (OPT_Wpragmas
, "junk at end of %<#pragma push_options%>");
1174 opt_stack
*p
= ggc_alloc
<opt_stack
> ();
1175 p
->prev
= options_stack
;
1178 /* Save optimization and target flags in binary format. */
1179 p
->optimize_binary
= build_optimization_node (&global_options
);
1180 p
->target_binary
= build_target_option_node (&global_options
);
1182 /* Save optimization and target flags in string list format. */
1183 p
->optimize_strings
= copy_list (current_optimize_pragma
);
1184 p
->target_strings
= copy_list (current_target_pragma
);
1187 /* Handle #pragma GCC pop_options to restore the current target and
1188 optimization options from a previous push_options. */
1191 handle_pragma_pop_options (cpp_reader
*ARG_UNUSED(dummy
))
1193 enum cpp_ttype token
;
1197 token
= pragma_lex (&x
);
1198 if (token
!= CPP_EOF
)
1200 warning (OPT_Wpragmas
, "junk at end of %<#pragma pop_options%>");
1204 if (! options_stack
)
1206 warning (OPT_Wpragmas
,
1207 "%<#pragma GCC pop_options%> without a corresponding "
1208 "%<#pragma GCC push_options%>");
1213 options_stack
= p
->prev
;
1215 if (p
->target_binary
!= target_option_current_node
)
1217 (void) targetm
.target_option
.pragma_parse (NULL_TREE
, p
->target_binary
);
1218 target_option_current_node
= p
->target_binary
;
1221 if (p
->optimize_binary
!= optimization_current_node
)
1223 tree old_optimize
= optimization_current_node
;
1224 cl_optimization_restore (&global_options
,
1225 TREE_OPTIMIZATION (p
->optimize_binary
));
1226 c_cpp_builtins_optimize_pragma (parse_in
, old_optimize
,
1227 p
->optimize_binary
);
1228 optimization_current_node
= p
->optimize_binary
;
1231 current_target_pragma
= p
->target_strings
;
1232 current_optimize_pragma
= p
->optimize_strings
;
1235 /* Handle #pragma GCC reset_options to restore the current target and
1236 optimization options to the original options used on the command line. */
1239 handle_pragma_reset_options (cpp_reader
*ARG_UNUSED(dummy
))
1241 enum cpp_ttype token
;
1243 tree new_optimize
= optimization_default_node
;
1244 tree new_target
= target_option_default_node
;
1246 token
= pragma_lex (&x
);
1247 if (token
!= CPP_EOF
)
1249 warning (OPT_Wpragmas
, "junk at end of %<#pragma reset_options%>");
1253 if (new_target
!= target_option_current_node
)
1255 (void) targetm
.target_option
.pragma_parse (NULL_TREE
, new_target
);
1256 target_option_current_node
= new_target
;
1259 if (new_optimize
!= optimization_current_node
)
1261 tree old_optimize
= optimization_current_node
;
1262 cl_optimization_restore (&global_options
,
1263 TREE_OPTIMIZATION (new_optimize
));
1264 c_cpp_builtins_optimize_pragma (parse_in
, old_optimize
, new_optimize
);
1265 optimization_current_node
= new_optimize
;
1268 current_target_pragma
= NULL_TREE
;
1269 current_optimize_pragma
= NULL_TREE
;
1272 /* Print a plain user-specified message. */
1275 handle_pragma_message (cpp_reader
*ARG_UNUSED(dummy
))
1277 enum cpp_ttype token
;
1278 tree x
, message
= 0;
1280 token
= pragma_lex (&x
);
1281 if (token
== CPP_OPEN_PAREN
)
1283 token
= pragma_lex (&x
);
1284 if (token
== CPP_STRING
)
1287 GCC_BAD ("expected a string after %<#pragma message%>");
1288 if (pragma_lex (&x
) != CPP_CLOSE_PAREN
)
1289 GCC_BAD ("malformed %<#pragma message%>, ignored");
1291 else if (token
== CPP_STRING
)
1294 GCC_BAD ("expected a string after %<#pragma message%>");
1296 gcc_assert (message
);
1298 if (pragma_lex (&x
) != CPP_EOF
)
1299 warning (OPT_Wpragmas
, "junk at end of %<#pragma message%>");
1301 if (TREE_STRING_LENGTH (message
) > 1)
1302 inform (input_location
, "#pragma message: %s", TREE_STRING_POINTER (message
));
1305 /* Mark whether the current location is valid for a STDC pragma. */
1307 static bool valid_location_for_stdc_pragma
;
1310 mark_valid_location_for_stdc_pragma (bool flag
)
1312 valid_location_for_stdc_pragma
= flag
;
1315 /* Return true if the current location is valid for a STDC pragma. */
1318 valid_location_for_stdc_pragma_p (void)
1320 return valid_location_for_stdc_pragma
;
1323 enum pragma_switch_t
{ PRAGMA_ON
, PRAGMA_OFF
, PRAGMA_DEFAULT
, PRAGMA_BAD
};
1325 /* A STDC pragma must appear outside of external declarations or
1326 preceding all explicit declarations and statements inside a compound
1327 statement; its behavior is undefined if used in any other context.
1328 It takes a switch of ON, OFF, or DEFAULT. */
1330 static enum pragma_switch_t
1331 handle_stdc_pragma (const char *pname
)
1335 enum pragma_switch_t ret
;
1337 if (!valid_location_for_stdc_pragma_p ())
1339 warning (OPT_Wpragmas
, "invalid location for %<pragma %s%>, ignored",
1344 if (pragma_lex (&t
) != CPP_NAME
)
1346 warning (OPT_Wpragmas
, "malformed %<#pragma %s%>, ignored", pname
);
1350 arg
= IDENTIFIER_POINTER (t
);
1352 if (!strcmp (arg
, "ON"))
1354 else if (!strcmp (arg
, "OFF"))
1356 else if (!strcmp (arg
, "DEFAULT"))
1357 ret
= PRAGMA_DEFAULT
;
1360 warning (OPT_Wpragmas
, "malformed %<#pragma %s%>, ignored", pname
);
1364 if (pragma_lex (&t
) != CPP_EOF
)
1366 warning (OPT_Wpragmas
, "junk at end of %<#pragma %s%>", pname
);
1373 /* #pragma STDC FLOAT_CONST_DECIMAL64 ON
1374 #pragma STDC FLOAT_CONST_DECIMAL64 OFF
1375 #pragma STDC FLOAT_CONST_DECIMAL64 DEFAULT */
1378 handle_pragma_float_const_decimal64 (cpp_reader
*ARG_UNUSED (dummy
))
1380 if (c_dialect_cxx ())
1382 if (warn_unknown_pragmas
> in_system_header_at (input_location
))
1383 warning (OPT_Wunknown_pragmas
,
1384 "%<#pragma STDC FLOAT_CONST_DECIMAL64%> is not supported"
1389 if (!targetm
.decimal_float_supported_p ())
1391 if (warn_unknown_pragmas
> in_system_header_at (input_location
))
1392 warning (OPT_Wunknown_pragmas
,
1393 "%<#pragma STDC FLOAT_CONST_DECIMAL64%> is not supported"
1398 pedwarn (input_location
, OPT_Wpedantic
,
1399 "ISO C does not support %<#pragma STDC FLOAT_CONST_DECIMAL64%>");
1401 switch (handle_stdc_pragma ("STDC FLOAT_CONST_DECIMAL64"))
1404 set_float_const_decimal64 ();
1407 case PRAGMA_DEFAULT
:
1408 clear_float_const_decimal64 ();
1415 /* A vector of registered pragma callbacks, which is never freed. */
1417 static vec
<internal_pragma_handler
> registered_pragmas
;
1426 static vec
<pragma_ns_name
> registered_pp_pragmas
;
1428 struct omp_pragma_def
{ const char *name
; unsigned int id
; };
1429 static const struct omp_pragma_def oacc_pragmas
[] = {
1430 { "cache", PRAGMA_OACC_CACHE
},
1431 { "data", PRAGMA_OACC_DATA
},
1432 { "enter", PRAGMA_OACC_ENTER_DATA
},
1433 { "exit", PRAGMA_OACC_EXIT_DATA
},
1434 { "kernels", PRAGMA_OACC_KERNELS
},
1435 { "loop", PRAGMA_OACC_LOOP
},
1436 { "parallel", PRAGMA_OACC_PARALLEL
},
1437 { "update", PRAGMA_OACC_UPDATE
},
1438 { "wait", PRAGMA_OACC_WAIT
}
1440 static const struct omp_pragma_def omp_pragmas
[] = {
1441 { "atomic", PRAGMA_OMP_ATOMIC
},
1442 { "barrier", PRAGMA_OMP_BARRIER
},
1443 { "cancel", PRAGMA_OMP_CANCEL
},
1444 { "cancellation", PRAGMA_OMP_CANCELLATION_POINT
},
1445 { "critical", PRAGMA_OMP_CRITICAL
},
1446 { "end", PRAGMA_OMP_END_DECLARE_TARGET
},
1447 { "flush", PRAGMA_OMP_FLUSH
},
1448 { "master", PRAGMA_OMP_MASTER
},
1449 { "ordered", PRAGMA_OMP_ORDERED
},
1450 { "section", PRAGMA_OMP_SECTION
},
1451 { "sections", PRAGMA_OMP_SECTIONS
},
1452 { "single", PRAGMA_OMP_SINGLE
},
1453 { "task", PRAGMA_OMP_TASK
},
1454 { "taskgroup", PRAGMA_OMP_TASKGROUP
},
1455 { "taskwait", PRAGMA_OMP_TASKWAIT
},
1456 { "taskyield", PRAGMA_OMP_TASKYIELD
},
1457 { "threadprivate", PRAGMA_OMP_THREADPRIVATE
}
1459 static const struct omp_pragma_def omp_pragmas_simd
[] = {
1460 { "declare", PRAGMA_OMP_DECLARE_REDUCTION
},
1461 { "distribute", PRAGMA_OMP_DISTRIBUTE
},
1462 { "for", PRAGMA_OMP_FOR
},
1463 { "parallel", PRAGMA_OMP_PARALLEL
},
1464 { "simd", PRAGMA_OMP_SIMD
},
1465 { "target", PRAGMA_OMP_TARGET
},
1466 { "teams", PRAGMA_OMP_TEAMS
},
1470 c_pp_lookup_pragma (unsigned int id
, const char **space
, const char **name
)
1472 const int n_oacc_pragmas
= sizeof (oacc_pragmas
) / sizeof (*oacc_pragmas
);
1473 const int n_omp_pragmas
= sizeof (omp_pragmas
) / sizeof (*omp_pragmas
);
1474 const int n_omp_pragmas_simd
= sizeof (omp_pragmas_simd
)
1475 / sizeof (*omp_pragmas
);
1478 for (i
= 0; i
< n_oacc_pragmas
; ++i
)
1479 if (oacc_pragmas
[i
].id
== id
)
1482 *name
= oacc_pragmas
[i
].name
;
1486 for (i
= 0; i
< n_omp_pragmas
; ++i
)
1487 if (omp_pragmas
[i
].id
== id
)
1490 *name
= omp_pragmas
[i
].name
;
1494 for (i
= 0; i
< n_omp_pragmas_simd
; ++i
)
1495 if (omp_pragmas_simd
[i
].id
== id
)
1498 *name
= omp_pragmas_simd
[i
].name
;
1502 if (id
== PRAGMA_CILK_SIMD
)
1509 if (id
>= PRAGMA_FIRST_EXTERNAL
1510 && (id
< PRAGMA_FIRST_EXTERNAL
+ registered_pp_pragmas
.length ()))
1512 *space
= registered_pp_pragmas
[id
- PRAGMA_FIRST_EXTERNAL
].space
;
1513 *name
= registered_pp_pragmas
[id
- PRAGMA_FIRST_EXTERNAL
].name
;
1520 /* Front-end wrappers for pragma registration to avoid dragging
1521 cpplib.h in almost everywhere. */
1524 c_register_pragma_1 (const char *space
, const char *name
,
1525 internal_pragma_handler ihandler
, bool allow_expansion
)
1529 if (flag_preprocess_only
)
1531 pragma_ns_name ns_name
;
1533 if (!allow_expansion
)
1536 ns_name
.space
= space
;
1537 ns_name
.name
= name
;
1538 registered_pp_pragmas
.safe_push (ns_name
);
1539 id
= registered_pp_pragmas
.length ();
1540 id
+= PRAGMA_FIRST_EXTERNAL
- 1;
1544 registered_pragmas
.safe_push (ihandler
);
1545 id
= registered_pragmas
.length ();
1546 id
+= PRAGMA_FIRST_EXTERNAL
- 1;
1548 /* The C++ front end allocates 6 bits in cp_token; the C front end
1549 allocates 7 bits in c_token. At present this is sufficient. */
1550 gcc_assert (id
< 64);
1553 cpp_register_deferred_pragma (parse_in
, space
, name
, id
,
1554 allow_expansion
, false);
1557 /* Register a C pragma handler, using a space and a name. It disallows pragma
1558 expansion (if you want it, use c_register_pragma_with_expansion instead). */
1560 c_register_pragma (const char *space
, const char *name
,
1561 pragma_handler_1arg handler
)
1563 internal_pragma_handler ihandler
;
1565 ihandler
.handler
.handler_1arg
= handler
;
1566 ihandler
.extra_data
= false;
1567 ihandler
.data
= NULL
;
1568 c_register_pragma_1 (space
, name
, ihandler
, false);
1571 /* Register a C pragma handler, using a space and a name, it also carries an
1572 extra data field which can be used by the handler. It disallows pragma
1573 expansion (if you want it, use c_register_pragma_with_expansion_and_data
1576 c_register_pragma_with_data (const char *space
, const char *name
,
1577 pragma_handler_2arg handler
, void * data
)
1579 internal_pragma_handler ihandler
;
1581 ihandler
.handler
.handler_2arg
= handler
;
1582 ihandler
.extra_data
= true;
1583 ihandler
.data
= data
;
1584 c_register_pragma_1 (space
, name
, ihandler
, false);
1587 /* Register a C pragma handler, using a space and a name. It allows pragma
1588 expansion as in the following example:
1591 #pragma count (NUMBER)
1593 Name expansion is still disallowed. */
1595 c_register_pragma_with_expansion (const char *space
, const char *name
,
1596 pragma_handler_1arg handler
)
1598 internal_pragma_handler ihandler
;
1600 ihandler
.handler
.handler_1arg
= handler
;
1601 ihandler
.extra_data
= false;
1602 ihandler
.data
= NULL
;
1603 c_register_pragma_1 (space
, name
, ihandler
, true);
1606 /* Register a C pragma handler, using a space and a name, it also carries an
1607 extra data field which can be used by the handler. It allows pragma
1608 expansion as in the following example:
1611 #pragma count (NUMBER)
1613 Name expansion is still disallowed. */
1615 c_register_pragma_with_expansion_and_data (const char *space
, const char *name
,
1616 pragma_handler_2arg handler
,
1619 internal_pragma_handler ihandler
;
1621 ihandler
.handler
.handler_2arg
= handler
;
1622 ihandler
.extra_data
= true;
1623 ihandler
.data
= data
;
1624 c_register_pragma_1 (space
, name
, ihandler
, true);
1628 c_invoke_pragma_handler (unsigned int id
)
1630 internal_pragma_handler
*ihandler
;
1631 pragma_handler_1arg handler_1arg
;
1632 pragma_handler_2arg handler_2arg
;
1634 id
-= PRAGMA_FIRST_EXTERNAL
;
1635 ihandler
= ®istered_pragmas
[id
];
1636 if (ihandler
->extra_data
)
1638 handler_2arg
= ihandler
->handler
.handler_2arg
;
1639 handler_2arg (parse_in
, ihandler
->data
);
1643 handler_1arg
= ihandler
->handler
.handler_1arg
;
1644 handler_1arg (parse_in
);
1648 /* Set up front-end pragmas. */
1654 const int n_oacc_pragmas
1655 = sizeof (oacc_pragmas
) / sizeof (*oacc_pragmas
);
1658 for (i
= 0; i
< n_oacc_pragmas
; ++i
)
1659 cpp_register_deferred_pragma (parse_in
, "acc", oacc_pragmas
[i
].name
,
1660 oacc_pragmas
[i
].id
, true, true);
1665 const int n_omp_pragmas
= sizeof (omp_pragmas
) / sizeof (*omp_pragmas
);
1668 for (i
= 0; i
< n_omp_pragmas
; ++i
)
1669 cpp_register_deferred_pragma (parse_in
, "omp", omp_pragmas
[i
].name
,
1670 omp_pragmas
[i
].id
, true, true);
1672 if (flag_openmp
|| flag_openmp_simd
)
1674 const int n_omp_pragmas_simd
= sizeof (omp_pragmas_simd
)
1675 / sizeof (*omp_pragmas
);
1678 for (i
= 0; i
< n_omp_pragmas_simd
; ++i
)
1679 cpp_register_deferred_pragma (parse_in
, "omp", omp_pragmas_simd
[i
].name
,
1680 omp_pragmas_simd
[i
].id
, true, true);
1684 cpp_register_deferred_pragma (parse_in
, NULL
, "simd", PRAGMA_CILK_SIMD
,
1687 if (!flag_preprocess_only
)
1688 cpp_register_deferred_pragma (parse_in
, "GCC", "pch_preprocess",
1689 PRAGMA_GCC_PCH_PREPROCESS
, false, false);
1691 if (!flag_preprocess_only
)
1692 cpp_register_deferred_pragma (parse_in
, "GCC", "ivdep", PRAGMA_IVDEP
, false,
1695 if (flag_cilkplus
&& !flag_preprocess_only
)
1696 cpp_register_deferred_pragma (parse_in
, "cilk", "grainsize",
1697 PRAGMA_CILK_GRAINSIZE
, true, false);
1699 #ifdef HANDLE_PRAGMA_PACK_WITH_EXPANSION
1700 c_register_pragma_with_expansion (0, "pack", handle_pragma_pack
);
1702 c_register_pragma (0, "pack", handle_pragma_pack
);
1704 c_register_pragma (0, "weak", handle_pragma_weak
);
1705 c_register_pragma ("GCC", "visibility", handle_pragma_visibility
);
1707 c_register_pragma ("GCC", "diagnostic", handle_pragma_diagnostic
);
1708 c_register_pragma ("GCC", "target", handle_pragma_target
);
1709 c_register_pragma ("GCC", "optimize", handle_pragma_optimize
);
1710 c_register_pragma ("GCC", "push_options", handle_pragma_push_options
);
1711 c_register_pragma ("GCC", "pop_options", handle_pragma_pop_options
);
1712 c_register_pragma ("GCC", "reset_options", handle_pragma_reset_options
);
1714 c_register_pragma ("STDC", "FLOAT_CONST_DECIMAL64",
1715 handle_pragma_float_const_decimal64
);
1717 c_register_pragma_with_expansion (0, "redefine_extname",
1718 handle_pragma_redefine_extname
);
1720 c_register_pragma_with_expansion (0, "message", handle_pragma_message
);
1724 c_register_pragma (0, "upc", handle_pragma_upc
);
1726 c_register_pragma (0, "pupc", handle_pragma_pupc
);
1727 init_pragma_pupc ();
1730 #ifdef REGISTER_TARGET_PRAGMAS
1731 REGISTER_TARGET_PRAGMAS ();
1734 /* Allow plugins to register their own pragmas. */
1735 invoke_plugin_callbacks (PLUGIN_PRAGMAS
, NULL
);
1738 #include "gt-c-family-c-pragma.h"