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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [plugin/] [attribute_plugin.c] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 301 jeremybenn
/* Demonstrates how to add custom attributes */
2
 
3
#include "gcc-plugin.h"
4
#include <stdlib.h>
5
#include "config.h"
6
#include "system.h"
7
#include "coretypes.h"
8
#include "tree.h"
9
#include "tree-pass.h"
10
#include "intl.h"
11
 
12
int plugin_is_GPL_compatible;
13
 
14
/* Attribute handler callback */
15
 
16
static tree
17
handle_user_attribute (tree *node, tree name, tree args,
18
                        int flags, bool *no_add_attrs)
19
{
20
  return NULL_TREE;
21
}
22
 
23
/* Attribute definition */
24
 
25
static struct attribute_spec user_attr =
26
  { "user", 1, 1, false,  false, false, handle_user_attribute };
27
 
28
/* Plugin callback called during attribute registration */
29
 
30
static void
31
register_attributes (void *event_data, void *data)
32
{
33
  warning (0, G_("Callback to register attributes"));
34
  register_attribute (&user_attr);
35
}
36
 
37
/* Callback function to invoke before the function body is genericized.  */
38
 
39
void
40
handle_pre_generic (void *event_data, void *data)
41
{
42
  tree fndecl = (tree) event_data;
43
  tree arg;
44
  for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN (arg)) {
45
      tree attr;
46
      for (attr = DECL_ATTRIBUTES (arg); attr; attr = TREE_CHAIN (attr)) {
47
          tree attrname = TREE_PURPOSE (attr);
48
          tree attrargs = TREE_VALUE (attr);
49
          warning (0, G_("attribute '%s' on param '%s' of function %s"),
50
                   IDENTIFIER_POINTER (attrname),
51
                   IDENTIFIER_POINTER (DECL_NAME (arg)),
52
                   IDENTIFIER_POINTER (DECL_NAME (fndecl))
53
                   );
54
      }
55
  }
56
}
57
 
58
int
59
plugin_init (struct plugin_name_args *plugin_info,
60
             struct plugin_gcc_version *version)
61
{
62
  const char *plugin_name = plugin_info->base_name;
63
  register_callback (plugin_name, PLUGIN_PRE_GENERICIZE,
64
                     handle_pre_generic, NULL);
65
 
66
  register_callback (plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
67
  return 0;
68
}

powered by: WebSVN 2.1.0

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