]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/c-family/c-pragma.c
* c-pragma.c (c_pp_lookup_pragma): Handle PRAGMA_CILK_SIMD.
[thirdparty/gcc.git] / gcc / c-family / c-pragma.c
1 /* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack.
2 Copyright (C) 1992-2014 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
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
9 version.
10
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
14 for more details.
15
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/>. */
19
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "tm.h"
24 #include "tree.h"
25 #include "stringpool.h"
26 #include "attribs.h"
27 #include "varasm.h"
28 #include "gcc-symtab.h"
29 #include "function.h" /* For cfun. FIXME: Does the parser know
30 when it is inside a function, so that
31 we don't have to look at cfun? */
32 #include "cpplib.h"
33 #include "c-pragma.h"
34 #include "flags.h"
35 #include "c-common.h"
36 #include "tm_p.h" /* For REGISTER_TARGET_PRAGMAS (why is
37 this not a target hook?). */
38 #include "vec.h"
39 #include "target.h"
40 #include "diagnostic.h"
41 #include "opts.h"
42 #include "plugin.h"
43 #include "cgraph.h"
44
45 #define GCC_BAD(gmsgid) \
46 do { warning (OPT_Wpragmas, gmsgid); return; } while (0)
47 #define GCC_BAD2(gmsgid, arg) \
48 do { warning (OPT_Wpragmas, gmsgid, arg); return; } while (0)
49
50 typedef struct GTY(()) align_stack {
51 int alignment;
52 tree id;
53 struct align_stack * prev;
54 } align_stack;
55
56 static GTY(()) struct align_stack * alignment_stack;
57
58 static void handle_pragma_pack (cpp_reader *);
59
60 /* If we have a "global" #pragma pack(<n>) in effect when the first
61 #pragma pack(push,<n>) is encountered, this stores the value of
62 maximum_field_alignment in effect. When the final pop_alignment()
63 happens, we restore the value to this, not to a value of 0 for
64 maximum_field_alignment. Value is in bits. */
65 static int default_alignment;
66 #define SET_GLOBAL_ALIGNMENT(ALIGN) (maximum_field_alignment = *(alignment_stack == NULL \
67 ? &default_alignment \
68 : &alignment_stack->alignment) = (ALIGN))
69
70 static void push_alignment (int, tree);
71 static void pop_alignment (tree);
72
73 /* Push an alignment value onto the stack. */
74 static void
75 push_alignment (int alignment, tree id)
76 {
77 align_stack * entry;
78
79 entry = ggc_alloc_align_stack ();
80
81 entry->alignment = alignment;
82 entry->id = id;
83 entry->prev = alignment_stack;
84
85 /* The current value of maximum_field_alignment is not necessarily
86 0 since there may be a #pragma pack(<n>) in effect; remember it
87 so that we can restore it after the final #pragma pop(). */
88 if (alignment_stack == NULL)
89 default_alignment = maximum_field_alignment;
90
91 alignment_stack = entry;
92
93 maximum_field_alignment = alignment;
94 }
95
96 /* Undo a push of an alignment onto the stack. */
97 static void
98 pop_alignment (tree id)
99 {
100 align_stack * entry;
101
102 if (alignment_stack == NULL)
103 GCC_BAD ("#pragma pack (pop) encountered without matching #pragma pack (push)");
104
105 /* If we got an identifier, strip away everything above the target
106 entry so that the next step will restore the state just below it. */
107 if (id)
108 {
109 for (entry = alignment_stack; entry; entry = entry->prev)
110 if (entry->id == id)
111 {
112 alignment_stack = entry;
113 break;
114 }
115 if (entry == NULL)
116 warning (OPT_Wpragmas, "\
117 #pragma pack(pop, %E) encountered without matching #pragma pack(push, %E)"
118 , id, id);
119 }
120
121 entry = alignment_stack->prev;
122
123 maximum_field_alignment = entry ? entry->alignment : default_alignment;
124
125 alignment_stack = entry;
126 }
127
128 /* #pragma pack ()
129 #pragma pack (N)
130
131 #pragma pack (push)
132 #pragma pack (push, N)
133 #pragma pack (push, ID)
134 #pragma pack (push, ID, N)
135 #pragma pack (pop)
136 #pragma pack (pop, ID) */
137 static void
138 handle_pragma_pack (cpp_reader * ARG_UNUSED (dummy))
139 {
140 tree x, id = 0;
141 int align = -1;
142 enum cpp_ttype token;
143 enum { set, push, pop } action;
144
145 if (pragma_lex (&x) != CPP_OPEN_PAREN)
146 GCC_BAD ("missing %<(%> after %<#pragma pack%> - ignored");
147
148 token = pragma_lex (&x);
149 if (token == CPP_CLOSE_PAREN)
150 {
151 action = set;
152 align = initial_max_fld_align;
153 }
154 else if (token == CPP_NUMBER)
155 {
156 if (TREE_CODE (x) != INTEGER_CST)
157 GCC_BAD ("invalid constant in %<#pragma pack%> - ignored");
158 align = TREE_INT_CST_LOW (x);
159 action = set;
160 if (pragma_lex (&x) != CPP_CLOSE_PAREN)
161 GCC_BAD ("malformed %<#pragma pack%> - ignored");
162 }
163 else if (token == CPP_NAME)
164 {
165 #define GCC_BAD_ACTION do { if (action != pop) \
166 GCC_BAD ("malformed %<#pragma pack(push[, id][, <n>])%> - ignored"); \
167 else \
168 GCC_BAD ("malformed %<#pragma pack(pop[, id])%> - ignored"); \
169 } while (0)
170
171 const char *op = IDENTIFIER_POINTER (x);
172 if (!strcmp (op, "push"))
173 action = push;
174 else if (!strcmp (op, "pop"))
175 action = pop;
176 else
177 GCC_BAD2 ("unknown action %qE for %<#pragma pack%> - ignored", x);
178
179 while ((token = pragma_lex (&x)) == CPP_COMMA)
180 {
181 token = pragma_lex (&x);
182 if (token == CPP_NAME && id == 0)
183 {
184 id = x;
185 }
186 else if (token == CPP_NUMBER && action == push && align == -1)
187 {
188 if (TREE_CODE (x) != INTEGER_CST)
189 GCC_BAD ("invalid constant in %<#pragma pack%> - ignored");
190 align = TREE_INT_CST_LOW (x);
191 if (align == -1)
192 action = set;
193 }
194 else
195 GCC_BAD_ACTION;
196 }
197
198 if (token != CPP_CLOSE_PAREN)
199 GCC_BAD_ACTION;
200 #undef GCC_BAD_ACTION
201 }
202 else
203 GCC_BAD ("malformed %<#pragma pack%> - ignored");
204
205 if (pragma_lex (&x) != CPP_EOF)
206 warning (OPT_Wpragmas, "junk at end of %<#pragma pack%>");
207
208 if (flag_pack_struct)
209 GCC_BAD ("#pragma pack has no effect with -fpack-struct - ignored");
210
211 if (action != pop)
212 switch (align)
213 {
214 case 0:
215 case 1:
216 case 2:
217 case 4:
218 case 8:
219 case 16:
220 align *= BITS_PER_UNIT;
221 break;
222 case -1:
223 if (action == push)
224 {
225 align = maximum_field_alignment;
226 break;
227 }
228 default:
229 GCC_BAD2 ("alignment must be a small power of two, not %d", align);
230 }
231
232 switch (action)
233 {
234 case set: SET_GLOBAL_ALIGNMENT (align); break;
235 case push: push_alignment (align, id); break;
236 case pop: pop_alignment (id); break;
237 }
238 }
239
240 typedef struct GTY(()) pending_weak_d
241 {
242 tree name;
243 tree value;
244 } pending_weak;
245
246
247 static GTY(()) vec<pending_weak, va_gc> *pending_weaks;
248
249 static void apply_pragma_weak (tree, tree);
250 static void handle_pragma_weak (cpp_reader *);
251
252 static void
253 apply_pragma_weak (tree decl, tree value)
254 {
255 if (value)
256 {
257 value = build_string (IDENTIFIER_LENGTH (value),
258 IDENTIFIER_POINTER (value));
259 decl_attributes (&decl, build_tree_list (get_identifier ("alias"),
260 build_tree_list (NULL, value)),
261 0);
262 }
263
264 if (SUPPORTS_WEAK && DECL_EXTERNAL (decl) && TREE_USED (decl)
265 && !DECL_WEAK (decl) /* Don't complain about a redundant #pragma. */
266 && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
267 warning (OPT_Wpragmas, "applying #pragma weak %q+D after first use "
268 "results in unspecified behavior", decl);
269
270 declare_weak (decl);
271 }
272
273 void
274 maybe_apply_pragma_weak (tree decl)
275 {
276 tree id;
277 int i;
278 pending_weak *pe;
279
280 /* Avoid asking for DECL_ASSEMBLER_NAME when it's not needed. */
281
282 /* No weak symbols pending, take the short-cut. */
283 if (!pending_weaks)
284 return;
285 /* If it's not visible outside this file, it doesn't matter whether
286 it's weak. */
287 if (!DECL_EXTERNAL (decl) && !TREE_PUBLIC (decl))
288 return;
289 /* If it's not a function or a variable, it can't be weak.
290 FIXME: what kinds of things are visible outside this file but
291 aren't functions or variables? Should this be an assert instead? */
292 if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL)
293 return;
294
295 id = DECL_ASSEMBLER_NAME (decl);
296
297 FOR_EACH_VEC_ELT (*pending_weaks, i, pe)
298 if (id == pe->name)
299 {
300 apply_pragma_weak (decl, pe->value);
301 pending_weaks->unordered_remove (i);
302 break;
303 }
304 }
305
306 /* Process all "#pragma weak A = B" directives where we have not seen
307 a decl for A. */
308 void
309 maybe_apply_pending_pragma_weaks (void)
310 {
311 tree alias_id, id, decl;
312 int i;
313 pending_weak *pe;
314 symtab_node *target;
315
316 if (!pending_weaks)
317 return;
318
319 FOR_EACH_VEC_ELT (*pending_weaks, i, pe)
320 {
321 alias_id = pe->name;
322 id = pe->value;
323
324 if (id == NULL)
325 continue;
326
327 target = symtab_node_for_asm (id);
328 decl = build_decl (UNKNOWN_LOCATION,
329 target ? TREE_CODE (target->decl) : FUNCTION_DECL,
330 alias_id, default_function_type);
331
332 DECL_ARTIFICIAL (decl) = 1;
333 TREE_PUBLIC (decl) = 1;
334 DECL_WEAK (decl) = 1;
335 if (TREE_CODE (decl) == VAR_DECL)
336 TREE_STATIC (decl) = 1;
337 if (!target)
338 {
339 error ("%q+D aliased to undefined symbol %qE",
340 decl, id);
341 continue;
342 }
343
344 assemble_alias (decl, id);
345 }
346 }
347
348 /* #pragma weak name [= value] */
349 static void
350 handle_pragma_weak (cpp_reader * ARG_UNUSED (dummy))
351 {
352 tree name, value, x, decl;
353 enum cpp_ttype t;
354
355 value = 0;
356
357 if (pragma_lex (&name) != CPP_NAME)
358 GCC_BAD ("malformed #pragma weak, ignored");
359 t = pragma_lex (&x);
360 if (t == CPP_EQ)
361 {
362 if (pragma_lex (&value) != CPP_NAME)
363 GCC_BAD ("malformed #pragma weak, ignored");
364 t = pragma_lex (&x);
365 }
366 if (t != CPP_EOF)
367 warning (OPT_Wpragmas, "junk at end of %<#pragma weak%>");
368
369 decl = identifier_global_value (name);
370 if (decl && DECL_P (decl))
371 {
372 apply_pragma_weak (decl, value);
373 if (value)
374 {
375 DECL_EXTERNAL (decl) = 0;
376 if (TREE_CODE (decl) == VAR_DECL)
377 TREE_STATIC (decl) = 1;
378 assemble_alias (decl, value);
379 }
380 }
381 else
382 {
383 pending_weak pe = {name, value};
384 vec_safe_push (pending_weaks, pe);
385 }
386 }
387
388 /* GCC supports two #pragma directives for renaming the external
389 symbol associated with a declaration (DECL_ASSEMBLER_NAME), for
390 compatibility with the Solaris and VMS system headers. GCC also
391 has its own notation for this, __asm__("name") annotations.
392
393 Corner cases of these features and their interaction:
394
395 1) Both pragmas silently apply only to declarations with external
396 linkage (that is, TREE_PUBLIC || DECL_EXTERNAL). Asm labels
397 do not have this restriction.
398
399 2) In C++, both #pragmas silently apply only to extern "C" declarations.
400 Asm labels do not have this restriction.
401
402 3) If any of the three ways of changing DECL_ASSEMBLER_NAME is
403 applied to a decl whose DECL_ASSEMBLER_NAME is already set, and the
404 new name is different, a warning issues and the name does not change.
405
406 4) The "source name" for #pragma redefine_extname is the DECL_NAME,
407 *not* the DECL_ASSEMBLER_NAME.
408
409 5) If #pragma extern_prefix is in effect and a declaration occurs
410 with an __asm__ name, the #pragma extern_prefix is silently
411 ignored for that declaration.
412
413 6) If #pragma extern_prefix and #pragma redefine_extname apply to
414 the same declaration, whichever triggered first wins, and a warning
415 is issued. (We would like to have #pragma redefine_extname always
416 win, but it can appear either before or after the declaration, and
417 if it appears afterward, we have no way of knowing whether a modified
418 DECL_ASSEMBLER_NAME is due to #pragma extern_prefix.) */
419
420 typedef struct GTY(()) pending_redefinition_d {
421 tree oldname;
422 tree newname;
423 } pending_redefinition;
424
425
426 static GTY(()) vec<pending_redefinition, va_gc> *pending_redefine_extname;
427
428 static void handle_pragma_redefine_extname (cpp_reader *);
429
430 /* #pragma redefine_extname oldname newname */
431 static void
432 handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy))
433 {
434 tree oldname, newname, decls, x;
435 enum cpp_ttype t;
436 bool found;
437
438 if (pragma_lex (&oldname) != CPP_NAME)
439 GCC_BAD ("malformed #pragma redefine_extname, ignored");
440 if (pragma_lex (&newname) != CPP_NAME)
441 GCC_BAD ("malformed #pragma redefine_extname, ignored");
442 t = pragma_lex (&x);
443 if (t != CPP_EOF)
444 warning (OPT_Wpragmas, "junk at end of %<#pragma redefine_extname%>");
445
446 found = false;
447 for (decls = c_linkage_bindings (oldname);
448 decls; )
449 {
450 tree decl;
451 if (TREE_CODE (decls) == TREE_LIST)
452 {
453 decl = TREE_VALUE (decls);
454 decls = TREE_CHAIN (decls);
455 }
456 else
457 {
458 decl = decls;
459 decls = NULL_TREE;
460 }
461
462 if ((TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
463 && (TREE_CODE (decl) == FUNCTION_DECL
464 || TREE_CODE (decl) == VAR_DECL))
465 {
466 found = true;
467 if (DECL_ASSEMBLER_NAME_SET_P (decl))
468 {
469 const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
470 name = targetm.strip_name_encoding (name);
471
472 if (strcmp (name, IDENTIFIER_POINTER (newname)))
473 warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to "
474 "conflict with previous rename");
475 }
476 else
477 change_decl_assembler_name (decl, newname);
478 }
479 }
480
481 if (!found)
482 /* We have to add this to the rename list even if there's already
483 a global value that doesn't meet the above criteria, because in
484 C++ "struct foo {...};" puts "foo" in the current namespace but
485 does *not* conflict with a subsequent declaration of a function
486 or variable foo. See g++.dg/other/pragma-re-2.C. */
487 add_to_renaming_pragma_list (oldname, newname);
488 }
489
490 /* This is called from here and from ia64-c.c. */
491 void
492 add_to_renaming_pragma_list (tree oldname, tree newname)
493 {
494 unsigned ix;
495 pending_redefinition *p;
496
497 FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname, ix, p)
498 if (oldname == p->oldname)
499 {
500 if (p->newname != newname)
501 warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to "
502 "conflict with previous #pragma redefine_extname");
503 return;
504 }
505
506 pending_redefinition e = {oldname, newname};
507 vec_safe_push (pending_redefine_extname, e);
508 }
509
510 /* The current prefix set by #pragma extern_prefix. */
511 GTY(()) tree pragma_extern_prefix;
512
513 /* Hook from the front ends to apply the results of one of the preceding
514 pragmas that rename variables. */
515
516 tree
517 maybe_apply_renaming_pragma (tree decl, tree asmname)
518 {
519 unsigned ix;
520 pending_redefinition *p;
521
522 /* The renaming pragmas are only applied to declarations with
523 external linkage. */
524 if ((TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL)
525 || (!TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl))
526 || !has_c_linkage (decl))
527 return asmname;
528
529 /* If the DECL_ASSEMBLER_NAME is already set, it does not change,
530 but we may warn about a rename that conflicts. */
531 if (DECL_ASSEMBLER_NAME_SET_P (decl))
532 {
533 const char *oldname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
534 oldname = targetm.strip_name_encoding (oldname);
535
536 if (asmname && strcmp (TREE_STRING_POINTER (asmname), oldname))
537 warning (OPT_Wpragmas, "asm declaration ignored due to "
538 "conflict with previous rename");
539
540 /* Take any pending redefine_extname off the list. */
541 FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname, ix, p)
542 if (DECL_NAME (decl) == p->oldname)
543 {
544 /* Only warn if there is a conflict. */
545 if (strcmp (IDENTIFIER_POINTER (p->newname), oldname))
546 warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to "
547 "conflict with previous rename");
548
549 pending_redefine_extname->unordered_remove (ix);
550 break;
551 }
552 return 0;
553 }
554
555 /* Find out if we have a pending #pragma redefine_extname. */
556 FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname, ix, p)
557 if (DECL_NAME (decl) == p->oldname)
558 {
559 tree newname = p->newname;
560 pending_redefine_extname->unordered_remove (ix);
561
562 /* If we already have an asmname, #pragma redefine_extname is
563 ignored (with a warning if it conflicts). */
564 if (asmname)
565 {
566 if (strcmp (TREE_STRING_POINTER (asmname),
567 IDENTIFIER_POINTER (newname)) != 0)
568 warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to "
569 "conflict with __asm__ declaration");
570 return asmname;
571 }
572
573 /* Otherwise we use what we've got; #pragma extern_prefix is
574 silently ignored. */
575 return build_string (IDENTIFIER_LENGTH (newname),
576 IDENTIFIER_POINTER (newname));
577 }
578
579 /* If we've got an asmname, #pragma extern_prefix is silently ignored. */
580 if (asmname)
581 return asmname;
582
583 /* If #pragma extern_prefix is in effect, apply it. */
584 if (pragma_extern_prefix)
585 {
586 const char *prefix = TREE_STRING_POINTER (pragma_extern_prefix);
587 size_t plen = TREE_STRING_LENGTH (pragma_extern_prefix) - 1;
588
589 const char *id = IDENTIFIER_POINTER (DECL_NAME (decl));
590 size_t ilen = IDENTIFIER_LENGTH (DECL_NAME (decl));
591
592 char *newname = (char *) alloca (plen + ilen + 1);
593
594 memcpy (newname, prefix, plen);
595 memcpy (newname + plen, id, ilen + 1);
596
597 return build_string (plen + ilen, newname);
598 }
599
600 /* Nada. */
601 return 0;
602 }
603
604
605 static void handle_pragma_visibility (cpp_reader *);
606
607 static vec<int> visstack;
608
609 /* Push the visibility indicated by STR onto the top of the #pragma
610 visibility stack. KIND is 0 for #pragma GCC visibility, 1 for
611 C++ namespace with visibility attribute and 2 for C++ builtin
612 ABI namespace. push_visibility/pop_visibility calls must have
613 matching KIND, it is not allowed to push visibility using one
614 KIND and pop using a different one. */
615
616 void
617 push_visibility (const char *str, int kind)
618 {
619 visstack.safe_push (((int) default_visibility) | (kind << 8));
620 if (!strcmp (str, "default"))
621 default_visibility = VISIBILITY_DEFAULT;
622 else if (!strcmp (str, "internal"))
623 default_visibility = VISIBILITY_INTERNAL;
624 else if (!strcmp (str, "hidden"))
625 default_visibility = VISIBILITY_HIDDEN;
626 else if (!strcmp (str, "protected"))
627 default_visibility = VISIBILITY_PROTECTED;
628 else
629 GCC_BAD ("#pragma GCC visibility push() must specify default, internal, hidden or protected");
630 visibility_options.inpragma = 1;
631 }
632
633 /* Pop a level of the #pragma visibility stack. Return true if
634 successful. */
635
636 bool
637 pop_visibility (int kind)
638 {
639 if (!visstack.length ())
640 return false;
641 if ((visstack.last () >> 8) != kind)
642 return false;
643 default_visibility
644 = (enum symbol_visibility) (visstack.pop () & 0xff);
645 visibility_options.inpragma
646 = visstack.length () != 0;
647 return true;
648 }
649
650 /* Sets the default visibility for symbols to something other than that
651 specified on the command line. */
652
653 static void
654 handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED)
655 {
656 /* Form is #pragma GCC visibility push(hidden)|pop */
657 tree x;
658 enum cpp_ttype token;
659 enum { bad, push, pop } action = bad;
660
661 token = pragma_lex (&x);
662 if (token == CPP_NAME)
663 {
664 const char *op = IDENTIFIER_POINTER (x);
665 if (!strcmp (op, "push"))
666 action = push;
667 else if (!strcmp (op, "pop"))
668 action = pop;
669 }
670 if (bad == action)
671 GCC_BAD ("#pragma GCC visibility must be followed by push or pop");
672 else
673 {
674 if (pop == action)
675 {
676 if (! pop_visibility (0))
677 GCC_BAD ("no matching push for %<#pragma GCC visibility pop%>");
678 }
679 else
680 {
681 if (pragma_lex (&x) != CPP_OPEN_PAREN)
682 GCC_BAD ("missing %<(%> after %<#pragma GCC visibility push%> - ignored");
683 token = pragma_lex (&x);
684 if (token != CPP_NAME)
685 GCC_BAD ("malformed #pragma GCC visibility push");
686 else
687 push_visibility (IDENTIFIER_POINTER (x), 0);
688 if (pragma_lex (&x) != CPP_CLOSE_PAREN)
689 GCC_BAD ("missing %<(%> after %<#pragma GCC visibility push%> - ignored");
690 }
691 }
692 if (pragma_lex (&x) != CPP_EOF)
693 warning (OPT_Wpragmas, "junk at end of %<#pragma GCC visibility%>");
694 }
695
696 static void
697 handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
698 {
699 const char *kind_string, *option_string;
700 unsigned int option_index;
701 enum cpp_ttype token;
702 diagnostic_t kind;
703 tree x;
704 struct cl_option_handlers handlers;
705
706 token = pragma_lex (&x);
707 if (token != CPP_NAME)
708 GCC_BAD ("missing [error|warning|ignored] after %<#pragma GCC diagnostic%>");
709 kind_string = IDENTIFIER_POINTER (x);
710 if (strcmp (kind_string, "error") == 0)
711 kind = DK_ERROR;
712 else if (strcmp (kind_string, "warning") == 0)
713 kind = DK_WARNING;
714 else if (strcmp (kind_string, "ignored") == 0)
715 kind = DK_IGNORED;
716 else if (strcmp (kind_string, "push") == 0)
717 {
718 diagnostic_push_diagnostics (global_dc, input_location);
719 return;
720 }
721 else if (strcmp (kind_string, "pop") == 0)
722 {
723 diagnostic_pop_diagnostics (global_dc, input_location);
724 return;
725 }
726 else
727 GCC_BAD ("expected [error|warning|ignored|push|pop] after %<#pragma GCC diagnostic%>");
728
729 token = pragma_lex (&x);
730 if (token != CPP_STRING)
731 GCC_BAD ("missing option after %<#pragma GCC diagnostic%> kind");
732 option_string = TREE_STRING_POINTER (x);
733 set_default_handlers (&handlers);
734 for (option_index = 0; option_index < cl_options_count; option_index++)
735 if (strcmp (cl_options[option_index].opt_text, option_string) == 0)
736 {
737 control_warning_option (option_index, (int) kind, kind != DK_IGNORED,
738 input_location, c_family_lang_mask, &handlers,
739 &global_options, &global_options_set,
740 global_dc);
741 return;
742 }
743 GCC_BAD ("unknown option after %<#pragma GCC diagnostic%> kind");
744 }
745
746 /* Parse #pragma GCC target (xxx) to set target specific options. */
747 static void
748 handle_pragma_target(cpp_reader *ARG_UNUSED(dummy))
749 {
750 enum cpp_ttype token;
751 tree x;
752 bool close_paren_needed_p = false;
753
754 if (cfun)
755 {
756 error ("#pragma GCC option is not allowed inside functions");
757 return;
758 }
759
760 token = pragma_lex (&x);
761 if (token == CPP_OPEN_PAREN)
762 {
763 close_paren_needed_p = true;
764 token = pragma_lex (&x);
765 }
766
767 if (token != CPP_STRING)
768 {
769 GCC_BAD ("%<#pragma GCC option%> is not a string");
770 return;
771 }
772
773 /* Strings are user options. */
774 else
775 {
776 tree args = NULL_TREE;
777
778 do
779 {
780 /* Build up the strings now as a tree linked list. Skip empty
781 strings. */
782 if (TREE_STRING_LENGTH (x) > 0)
783 args = tree_cons (NULL_TREE, x, args);
784
785 token = pragma_lex (&x);
786 while (token == CPP_COMMA)
787 token = pragma_lex (&x);
788 }
789 while (token == CPP_STRING);
790
791 if (close_paren_needed_p)
792 {
793 if (token == CPP_CLOSE_PAREN)
794 token = pragma_lex (&x);
795 else
796 GCC_BAD ("%<#pragma GCC target (string [,string]...)%> does "
797 "not have a final %<)%>");
798 }
799
800 if (token != CPP_EOF)
801 {
802 error ("#pragma GCC target string... is badly formed");
803 return;
804 }
805
806 /* put arguments in the order the user typed them. */
807 args = nreverse (args);
808
809 if (targetm.target_option.pragma_parse (args, NULL_TREE))
810 current_target_pragma = args;
811 }
812 }
813
814 /* Handle #pragma GCC optimize to set optimization options. */
815 static void
816 handle_pragma_optimize (cpp_reader *ARG_UNUSED(dummy))
817 {
818 enum cpp_ttype token;
819 tree x;
820 bool close_paren_needed_p = false;
821 tree optimization_previous_node = optimization_current_node;
822
823 if (cfun)
824 {
825 error ("#pragma GCC optimize is not allowed inside functions");
826 return;
827 }
828
829 token = pragma_lex (&x);
830 if (token == CPP_OPEN_PAREN)
831 {
832 close_paren_needed_p = true;
833 token = pragma_lex (&x);
834 }
835
836 if (token != CPP_STRING && token != CPP_NUMBER)
837 {
838 GCC_BAD ("%<#pragma GCC optimize%> is not a string or number");
839 return;
840 }
841
842 /* Strings/numbers are user options. */
843 else
844 {
845 tree args = NULL_TREE;
846
847 do
848 {
849 /* Build up the numbers/strings now as a list. */
850 if (token != CPP_STRING || TREE_STRING_LENGTH (x) > 0)
851 args = tree_cons (NULL_TREE, x, args);
852
853 token = pragma_lex (&x);
854 while (token == CPP_COMMA)
855 token = pragma_lex (&x);
856 }
857 while (token == CPP_STRING || token == CPP_NUMBER);
858
859 if (close_paren_needed_p)
860 {
861 if (token == CPP_CLOSE_PAREN)
862 token = pragma_lex (&x);
863 else
864 GCC_BAD ("%<#pragma GCC optimize (string [,string]...)%> does "
865 "not have a final %<)%>");
866 }
867
868 if (token != CPP_EOF)
869 {
870 error ("#pragma GCC optimize string... is badly formed");
871 return;
872 }
873
874 /* put arguments in the order the user typed them. */
875 args = nreverse (args);
876
877 parse_optimize_options (args, false);
878 current_optimize_pragma = chainon (current_optimize_pragma, args);
879 optimization_current_node = build_optimization_node (&global_options);
880 c_cpp_builtins_optimize_pragma (parse_in,
881 optimization_previous_node,
882 optimization_current_node);
883 }
884 }
885
886 /* Stack of the #pragma GCC options created with #pragma GCC push_option. Save
887 both the binary representation of the options and the TREE_LIST of
888 strings that will be added to the function's attribute list. */
889 typedef struct GTY(()) opt_stack {
890 struct opt_stack *prev;
891 tree target_binary;
892 tree target_strings;
893 tree optimize_binary;
894 tree optimize_strings;
895 } opt_stack;
896
897 static GTY(()) struct opt_stack * options_stack;
898
899 /* Handle #pragma GCC push_options to save the current target and optimization
900 options. */
901
902 static void
903 handle_pragma_push_options (cpp_reader *ARG_UNUSED(dummy))
904 {
905 enum cpp_ttype token;
906 tree x = 0;
907 opt_stack *p;
908
909 token = pragma_lex (&x);
910 if (token != CPP_EOF)
911 {
912 warning (OPT_Wpragmas, "junk at end of %<#pragma push_options%>");
913 return;
914 }
915
916 p = ggc_alloc_opt_stack ();
917 p->prev = options_stack;
918 options_stack = p;
919
920 /* Save optimization and target flags in binary format. */
921 p->optimize_binary = build_optimization_node (&global_options);
922 p->target_binary = build_target_option_node (&global_options);
923
924 /* Save optimization and target flags in string list format. */
925 p->optimize_strings = copy_list (current_optimize_pragma);
926 p->target_strings = copy_list (current_target_pragma);
927 }
928
929 /* Handle #pragma GCC pop_options to restore the current target and
930 optimization options from a previous push_options. */
931
932 static void
933 handle_pragma_pop_options (cpp_reader *ARG_UNUSED(dummy))
934 {
935 enum cpp_ttype token;
936 tree x = 0;
937 opt_stack *p;
938
939 token = pragma_lex (&x);
940 if (token != CPP_EOF)
941 {
942 warning (OPT_Wpragmas, "junk at end of %<#pragma pop_options%>");
943 return;
944 }
945
946 if (! options_stack)
947 {
948 warning (OPT_Wpragmas,
949 "%<#pragma GCC pop_options%> without a corresponding "
950 "%<#pragma GCC push_options%>");
951 return;
952 }
953
954 p = options_stack;
955 options_stack = p->prev;
956
957 if (p->target_binary != target_option_current_node)
958 {
959 (void) targetm.target_option.pragma_parse (NULL_TREE, p->target_binary);
960 target_option_current_node = p->target_binary;
961 }
962
963 if (p->optimize_binary != optimization_current_node)
964 {
965 tree old_optimize = optimization_current_node;
966 cl_optimization_restore (&global_options,
967 TREE_OPTIMIZATION (p->optimize_binary));
968 c_cpp_builtins_optimize_pragma (parse_in, old_optimize,
969 p->optimize_binary);
970 optimization_current_node = p->optimize_binary;
971 }
972
973 current_target_pragma = p->target_strings;
974 current_optimize_pragma = p->optimize_strings;
975 }
976
977 /* Handle #pragma GCC reset_options to restore the current target and
978 optimization options to the original options used on the command line. */
979
980 static void
981 handle_pragma_reset_options (cpp_reader *ARG_UNUSED(dummy))
982 {
983 enum cpp_ttype token;
984 tree x = 0;
985 tree new_optimize = optimization_default_node;
986 tree new_target = target_option_default_node;
987
988 token = pragma_lex (&x);
989 if (token != CPP_EOF)
990 {
991 warning (OPT_Wpragmas, "junk at end of %<#pragma reset_options%>");
992 return;
993 }
994
995 if (new_target != target_option_current_node)
996 {
997 (void) targetm.target_option.pragma_parse (NULL_TREE, new_target);
998 target_option_current_node = new_target;
999 }
1000
1001 if (new_optimize != optimization_current_node)
1002 {
1003 tree old_optimize = optimization_current_node;
1004 cl_optimization_restore (&global_options,
1005 TREE_OPTIMIZATION (new_optimize));
1006 c_cpp_builtins_optimize_pragma (parse_in, old_optimize, new_optimize);
1007 optimization_current_node = new_optimize;
1008 }
1009
1010 current_target_pragma = NULL_TREE;
1011 current_optimize_pragma = NULL_TREE;
1012 }
1013
1014 /* Print a plain user-specified message. */
1015
1016 static void
1017 handle_pragma_message (cpp_reader *ARG_UNUSED(dummy))
1018 {
1019 enum cpp_ttype token;
1020 tree x, message = 0;
1021
1022 token = pragma_lex (&x);
1023 if (token == CPP_OPEN_PAREN)
1024 {
1025 token = pragma_lex (&x);
1026 if (token == CPP_STRING)
1027 message = x;
1028 else
1029 GCC_BAD ("expected a string after %<#pragma message%>");
1030 if (pragma_lex (&x) != CPP_CLOSE_PAREN)
1031 GCC_BAD ("malformed %<#pragma message%>, ignored");
1032 }
1033 else if (token == CPP_STRING)
1034 message = x;
1035 else
1036 GCC_BAD ("expected a string after %<#pragma message%>");
1037
1038 gcc_assert (message);
1039
1040 if (pragma_lex (&x) != CPP_EOF)
1041 warning (OPT_Wpragmas, "junk at end of %<#pragma message%>");
1042
1043 if (TREE_STRING_LENGTH (message) > 1)
1044 inform (input_location, "#pragma message: %s", TREE_STRING_POINTER (message));
1045 }
1046
1047 /* Mark whether the current location is valid for a STDC pragma. */
1048
1049 static bool valid_location_for_stdc_pragma;
1050
1051 void
1052 mark_valid_location_for_stdc_pragma (bool flag)
1053 {
1054 valid_location_for_stdc_pragma = flag;
1055 }
1056
1057 /* Return true if the current location is valid for a STDC pragma. */
1058
1059 bool
1060 valid_location_for_stdc_pragma_p (void)
1061 {
1062 return valid_location_for_stdc_pragma;
1063 }
1064
1065 enum pragma_switch_t { PRAGMA_ON, PRAGMA_OFF, PRAGMA_DEFAULT, PRAGMA_BAD };
1066
1067 /* A STDC pragma must appear outside of external declarations or
1068 preceding all explicit declarations and statements inside a compound
1069 statement; its behavior is undefined if used in any other context.
1070 It takes a switch of ON, OFF, or DEFAULT. */
1071
1072 static enum pragma_switch_t
1073 handle_stdc_pragma (const char *pname)
1074 {
1075 const char *arg;
1076 tree t;
1077 enum pragma_switch_t ret;
1078
1079 if (!valid_location_for_stdc_pragma_p ())
1080 {
1081 warning (OPT_Wpragmas, "invalid location for %<pragma %s%>, ignored",
1082 pname);
1083 return PRAGMA_BAD;
1084 }
1085
1086 if (pragma_lex (&t) != CPP_NAME)
1087 {
1088 warning (OPT_Wpragmas, "malformed %<#pragma %s%>, ignored", pname);
1089 return PRAGMA_BAD;
1090 }
1091
1092 arg = IDENTIFIER_POINTER (t);
1093
1094 if (!strcmp (arg, "ON"))
1095 ret = PRAGMA_ON;
1096 else if (!strcmp (arg, "OFF"))
1097 ret = PRAGMA_OFF;
1098 else if (!strcmp (arg, "DEFAULT"))
1099 ret = PRAGMA_DEFAULT;
1100 else
1101 {
1102 warning (OPT_Wpragmas, "malformed %<#pragma %s%>, ignored", pname);
1103 return PRAGMA_BAD;
1104 }
1105
1106 if (pragma_lex (&t) != CPP_EOF)
1107 {
1108 warning (OPT_Wpragmas, "junk at end of %<#pragma %s%>", pname);
1109 return PRAGMA_BAD;
1110 }
1111
1112 return ret;
1113 }
1114
1115 /* #pragma STDC FLOAT_CONST_DECIMAL64 ON
1116 #pragma STDC FLOAT_CONST_DECIMAL64 OFF
1117 #pragma STDC FLOAT_CONST_DECIMAL64 DEFAULT */
1118
1119 static void
1120 handle_pragma_float_const_decimal64 (cpp_reader *ARG_UNUSED (dummy))
1121 {
1122 if (c_dialect_cxx ())
1123 {
1124 if (warn_unknown_pragmas > in_system_header_at (input_location))
1125 warning (OPT_Wunknown_pragmas,
1126 "%<#pragma STDC FLOAT_CONST_DECIMAL64%> is not supported"
1127 " for C++");
1128 return;
1129 }
1130
1131 if (!targetm.decimal_float_supported_p ())
1132 {
1133 if (warn_unknown_pragmas > in_system_header_at (input_location))
1134 warning (OPT_Wunknown_pragmas,
1135 "%<#pragma STDC FLOAT_CONST_DECIMAL64%> is not supported"
1136 " on this target");
1137 return;
1138 }
1139
1140 pedwarn (input_location, OPT_Wpedantic,
1141 "ISO C does not support %<#pragma STDC FLOAT_CONST_DECIMAL64%>");
1142
1143 switch (handle_stdc_pragma ("STDC FLOAT_CONST_DECIMAL64"))
1144 {
1145 case PRAGMA_ON:
1146 set_float_const_decimal64 ();
1147 break;
1148 case PRAGMA_OFF:
1149 case PRAGMA_DEFAULT:
1150 clear_float_const_decimal64 ();
1151 break;
1152 case PRAGMA_BAD:
1153 break;
1154 }
1155 }
1156
1157 /* A vector of registered pragma callbacks, which is never freed. */
1158
1159 static vec<internal_pragma_handler> registered_pragmas;
1160
1161 typedef struct
1162 {
1163 const char *space;
1164 const char *name;
1165 } pragma_ns_name;
1166
1167
1168 static vec<pragma_ns_name> registered_pp_pragmas;
1169
1170 struct omp_pragma_def { const char *name; unsigned int id; };
1171 static const struct omp_pragma_def omp_pragmas[] = {
1172 { "atomic", PRAGMA_OMP_ATOMIC },
1173 { "barrier", PRAGMA_OMP_BARRIER },
1174 { "cancel", PRAGMA_OMP_CANCEL },
1175 { "cancellation", PRAGMA_OMP_CANCELLATION_POINT },
1176 { "critical", PRAGMA_OMP_CRITICAL },
1177 { "end", PRAGMA_OMP_END_DECLARE_TARGET },
1178 { "flush", PRAGMA_OMP_FLUSH },
1179 { "master", PRAGMA_OMP_MASTER },
1180 { "ordered", PRAGMA_OMP_ORDERED },
1181 { "section", PRAGMA_OMP_SECTION },
1182 { "sections", PRAGMA_OMP_SECTIONS },
1183 { "single", PRAGMA_OMP_SINGLE },
1184 { "taskgroup", PRAGMA_OMP_TASKGROUP },
1185 { "taskwait", PRAGMA_OMP_TASKWAIT },
1186 { "taskyield", PRAGMA_OMP_TASKYIELD },
1187 { "threadprivate", PRAGMA_OMP_THREADPRIVATE }
1188 };
1189 static const struct omp_pragma_def omp_pragmas_simd[] = {
1190 { "declare", PRAGMA_OMP_DECLARE_REDUCTION },
1191 { "distribute", PRAGMA_OMP_DISTRIBUTE },
1192 { "for", PRAGMA_OMP_FOR },
1193 { "parallel", PRAGMA_OMP_PARALLEL },
1194 { "simd", PRAGMA_OMP_SIMD },
1195 { "target", PRAGMA_OMP_TARGET },
1196 { "task", PRAGMA_OMP_TASK },
1197 { "teams", PRAGMA_OMP_TEAMS },
1198 };
1199
1200 void
1201 c_pp_lookup_pragma (unsigned int id, const char **space, const char **name)
1202 {
1203 const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas);
1204 const int n_omp_pragmas_simd = sizeof (omp_pragmas_simd)
1205 / sizeof (*omp_pragmas);
1206 int i;
1207
1208 for (i = 0; i < n_omp_pragmas; ++i)
1209 if (omp_pragmas[i].id == id)
1210 {
1211 *space = "omp";
1212 *name = omp_pragmas[i].name;
1213 return;
1214 }
1215
1216 for (i = 0; i < n_omp_pragmas_simd; ++i)
1217 if (omp_pragmas_simd[i].id == id)
1218 {
1219 *space = "omp";
1220 *name = omp_pragmas_simd[i].name;
1221 return;
1222 }
1223
1224 if (id == PRAGMA_CILK_SIMD)
1225 {
1226 *space = NULL;
1227 *name = "simd";
1228 return;
1229 }
1230
1231 if (id >= PRAGMA_FIRST_EXTERNAL
1232 && (id < PRAGMA_FIRST_EXTERNAL + registered_pp_pragmas.length ()))
1233 {
1234 *space = registered_pp_pragmas[id - PRAGMA_FIRST_EXTERNAL].space;
1235 *name = registered_pp_pragmas[id - PRAGMA_FIRST_EXTERNAL].name;
1236 return;
1237 }
1238
1239 gcc_unreachable ();
1240 }
1241
1242 /* Front-end wrappers for pragma registration to avoid dragging
1243 cpplib.h in almost everywhere. */
1244
1245 static void
1246 c_register_pragma_1 (const char *space, const char *name,
1247 internal_pragma_handler ihandler, bool allow_expansion)
1248 {
1249 unsigned id;
1250
1251 if (flag_preprocess_only)
1252 {
1253 pragma_ns_name ns_name;
1254
1255 if (!allow_expansion)
1256 return;
1257
1258 ns_name.space = space;
1259 ns_name.name = name;
1260 registered_pp_pragmas.safe_push (ns_name);
1261 id = registered_pp_pragmas.length ();
1262 id += PRAGMA_FIRST_EXTERNAL - 1;
1263 }
1264 else
1265 {
1266 registered_pragmas.safe_push (ihandler);
1267 id = registered_pragmas.length ();
1268 id += PRAGMA_FIRST_EXTERNAL - 1;
1269
1270 /* The C++ front end allocates 6 bits in cp_token; the C front end
1271 allocates 7 bits in c_token. At present this is sufficient. */
1272 gcc_assert (id < 64);
1273 }
1274
1275 cpp_register_deferred_pragma (parse_in, space, name, id,
1276 allow_expansion, false);
1277 }
1278
1279 /* Register a C pragma handler, using a space and a name. It disallows pragma
1280 expansion (if you want it, use c_register_pragma_with_expansion instead). */
1281 void
1282 c_register_pragma (const char *space, const char *name,
1283 pragma_handler_1arg handler)
1284 {
1285 internal_pragma_handler ihandler;
1286
1287 ihandler.handler.handler_1arg = handler;
1288 ihandler.extra_data = false;
1289 ihandler.data = NULL;
1290 c_register_pragma_1 (space, name, ihandler, false);
1291 }
1292
1293 /* Register a C pragma handler, using a space and a name, it also carries an
1294 extra data field which can be used by the handler. It disallows pragma
1295 expansion (if you want it, use c_register_pragma_with_expansion_and_data
1296 instead). */
1297 void
1298 c_register_pragma_with_data (const char *space, const char *name,
1299 pragma_handler_2arg handler, void * data)
1300 {
1301 internal_pragma_handler ihandler;
1302
1303 ihandler.handler.handler_2arg = handler;
1304 ihandler.extra_data = true;
1305 ihandler.data = data;
1306 c_register_pragma_1 (space, name, ihandler, false);
1307 }
1308
1309 /* Register a C pragma handler, using a space and a name. It allows pragma
1310 expansion as in the following example:
1311
1312 #define NUMBER 10
1313 #pragma count (NUMBER)
1314
1315 Name expansion is still disallowed. */
1316 void
1317 c_register_pragma_with_expansion (const char *space, const char *name,
1318 pragma_handler_1arg handler)
1319 {
1320 internal_pragma_handler ihandler;
1321
1322 ihandler.handler.handler_1arg = handler;
1323 ihandler.extra_data = false;
1324 ihandler.data = NULL;
1325 c_register_pragma_1 (space, name, ihandler, true);
1326 }
1327
1328 /* Register a C pragma handler, using a space and a name, it also carries an
1329 extra data field which can be used by the handler. It allows pragma
1330 expansion as in the following example:
1331
1332 #define NUMBER 10
1333 #pragma count (NUMBER)
1334
1335 Name expansion is still disallowed. */
1336 void
1337 c_register_pragma_with_expansion_and_data (const char *space, const char *name,
1338 pragma_handler_2arg handler,
1339 void *data)
1340 {
1341 internal_pragma_handler ihandler;
1342
1343 ihandler.handler.handler_2arg = handler;
1344 ihandler.extra_data = true;
1345 ihandler.data = data;
1346 c_register_pragma_1 (space, name, ihandler, true);
1347 }
1348
1349 void
1350 c_invoke_pragma_handler (unsigned int id)
1351 {
1352 internal_pragma_handler *ihandler;
1353 pragma_handler_1arg handler_1arg;
1354 pragma_handler_2arg handler_2arg;
1355
1356 id -= PRAGMA_FIRST_EXTERNAL;
1357 ihandler = &registered_pragmas[id];
1358 if (ihandler->extra_data)
1359 {
1360 handler_2arg = ihandler->handler.handler_2arg;
1361 handler_2arg (parse_in, ihandler->data);
1362 }
1363 else
1364 {
1365 handler_1arg = ihandler->handler.handler_1arg;
1366 handler_1arg (parse_in);
1367 }
1368 }
1369
1370 /* Set up front-end pragmas. */
1371 void
1372 init_pragma (void)
1373 {
1374 if (flag_openmp)
1375 {
1376 const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas);
1377 int i;
1378
1379 for (i = 0; i < n_omp_pragmas; ++i)
1380 cpp_register_deferred_pragma (parse_in, "omp", omp_pragmas[i].name,
1381 omp_pragmas[i].id, true, true);
1382 }
1383 if (flag_openmp || flag_openmp_simd)
1384 {
1385 const int n_omp_pragmas_simd = sizeof (omp_pragmas_simd)
1386 / sizeof (*omp_pragmas);
1387 int i;
1388
1389 for (i = 0; i < n_omp_pragmas_simd; ++i)
1390 cpp_register_deferred_pragma (parse_in, "omp", omp_pragmas_simd[i].name,
1391 omp_pragmas_simd[i].id, true, true);
1392 }
1393
1394 if (flag_cilkplus)
1395 cpp_register_deferred_pragma (parse_in, NULL, "simd", PRAGMA_CILK_SIMD,
1396 true, false);
1397
1398 if (!flag_preprocess_only)
1399 cpp_register_deferred_pragma (parse_in, "GCC", "pch_preprocess",
1400 PRAGMA_GCC_PCH_PREPROCESS, false, false);
1401
1402 if (!flag_preprocess_only)
1403 cpp_register_deferred_pragma (parse_in, "GCC", "ivdep", PRAGMA_IVDEP, false,
1404 false);
1405 #ifdef HANDLE_PRAGMA_PACK_WITH_EXPANSION
1406 c_register_pragma_with_expansion (0, "pack", handle_pragma_pack);
1407 #else
1408 c_register_pragma (0, "pack", handle_pragma_pack);
1409 #endif
1410 c_register_pragma (0, "weak", handle_pragma_weak);
1411 c_register_pragma ("GCC", "visibility", handle_pragma_visibility);
1412
1413 c_register_pragma ("GCC", "diagnostic", handle_pragma_diagnostic);
1414 c_register_pragma ("GCC", "target", handle_pragma_target);
1415 c_register_pragma ("GCC", "optimize", handle_pragma_optimize);
1416 c_register_pragma ("GCC", "push_options", handle_pragma_push_options);
1417 c_register_pragma ("GCC", "pop_options", handle_pragma_pop_options);
1418 c_register_pragma ("GCC", "reset_options", handle_pragma_reset_options);
1419
1420 c_register_pragma ("STDC", "FLOAT_CONST_DECIMAL64",
1421 handle_pragma_float_const_decimal64);
1422
1423 c_register_pragma_with_expansion (0, "redefine_extname",
1424 handle_pragma_redefine_extname);
1425
1426 c_register_pragma_with_expansion (0, "message", handle_pragma_message);
1427
1428 #ifdef REGISTER_TARGET_PRAGMAS
1429 REGISTER_TARGET_PRAGMAS ();
1430 #endif
1431
1432 /* Allow plugins to register their own pragmas. */
1433 invoke_plugin_callbacks (PLUGIN_PRAGMAS, NULL);
1434 }
1435
1436 #include "gt-c-family-c-pragma.h"