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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [plugin/] [pragma_plugin.c] - Blame information for rev 801

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

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

powered by: WebSVN 2.1.0

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