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