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