OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [plugin/] [pragma_plugin.c] - Blame information for rev 315

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 301 jeremybenn
/* Demonstrates how to add custom pragmas */
2
 
3
#include "gcc-plugin.h"
4
#include <stdlib.h>
5
#include "config.h"
6
#include "system.h"
7
#include "coretypes.h"
8
#include "tm.h"
9
#include "rtl.h"
10
#include "tree.h"
11
#include "function.h"
12
#include "c-pragma.h"
13
#include "cpplib.h"
14
#include "tree-pass.h"
15
#include "intl.h"
16
 
17
int plugin_is_GPL_compatible;
18
 
19
 
20
/* handler of #pragma GCCPLUGIN sayhello "message" is quite similar to
21
   handler of #pragma GCC message...*/
22
 
23
static void
24
handle_pragma_sayhello (cpp_reader *dummy)
25
{
26
  tree message = 0;
27
  if (pragma_lex (&message) != CPP_STRING)
28
    {
29
      warning (OPT_Wpragmas, "%<#pragma GCCPLUGIN sayhello%>  is not a string");
30
      return;
31
    }
32
  if (TREE_STRING_LENGTH (message) > 1)
33
    if (cfun)
34
      warning (OPT_Wpragmas,
35
              "%<pragma GCCPLUGIN sayhello%> from function %qE: %s",
36
              cfun->decl, TREE_STRING_POINTER (message));
37
      else
38
        warning (OPT_Wpragmas,
39
            "%<pragma GCCPLUGIN sayhello%> outside of function: %s",
40
            TREE_STRING_POINTER (message));
41
}
42
 
43
/* Plugin callback called during pragma registration */
44
 
45
static void
46
register_my_pragma (void *event_data, void *data)
47
{
48
  warning (0, G_("Callback to register pragmas"));
49
  c_register_pragma ("GCCPLUGIN", "sayhello", handle_pragma_sayhello);
50
}
51
 
52
int
53
plugin_init (struct plugin_name_args *plugin_info,
54
             struct plugin_gcc_version *version)
55
{
56
  const char *plugin_name = plugin_info->base_name;
57
 
58
  register_callback (plugin_name, PLUGIN_PRAGMAS, register_my_pragma, NULL);
59
  return 0;
60
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.