diff mbox

PR 45186: Add build[1-6]_loc and build[1-6]_stat_loc to gcc/tree.h

Message ID 4C88E4F8.5070606@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Sept. 9, 2010, 1:45 p.m. UTC
For PR 45186, I need to annotate build1 etc. with a location; to make 
life easier this patch follows fold_build[0-9], which have 
fold_build[0-9]_loc cousins.

Build and regtested on x86-64-linux.
OK for the trunk?

Tobias

Comments

Richard Biener Sept. 9, 2010, 1:57 p.m. UTC | #1
On Thu, Sep 9, 2010 at 3:45 PM, Tobias Burnus <burnus@net-b.de> wrote:
>  For PR 45186, I need to annotate build1 etc. with a location; to make life
> easier this patch follows fold_build[0-9], which have fold_build[0-9]_loc
> cousins.
>
> Build and regtested on x86-64-linux.
> OK for the trunk?

SET_EXPR_LOCATION is only valid for IS_EXPR_CODE_CLASS, so
most of your wrappers will ICE for some invocations which makes me
doubt that a generic wrapper like this is non-confusing.

build6 should be unused and can be removed.

Richard.

> Tobias
>
Jakub Jelinek Sept. 17, 2010, 9:13 a.m. UTC | #2
On Thu, Sep 09, 2010 at 03:57:53PM +0200, Richard Guenther wrote:
> On Thu, Sep 9, 2010 at 3:45 PM, Tobias Burnus <burnus@net-b.de> wrote:
> >  For PR 45186, I need to annotate build1 etc. with a location; to make life
> > easier this patch follows fold_build[0-9], which have fold_build[0-9]_loc
> > cousins.
> >
> > Build and regtested on x86-64-linux.
> > OK for the trunk?
> 
> SET_EXPR_LOCATION is only valid for IS_EXPR_CODE_CLASS, so
> most of your wrappers will ICE for some invocations which makes me
> doubt that a generic wrapper like this is non-confusing.

fold_build*_loc also do SET_EXPR_LOCATION unconditionally.  Sure, it could
be guarded by CAN_HAVE_LOCATION_P if you really want.

	Jakub
diff mbox

Patch

2010-09-09  Tobias Burnus  <burnus@net-b.de>

	PR fortran/45186
	* tree.h (build1_stat_loc, build2_stat_loc, build3_stat_loc,
	build4_stat_loc, build5_stat_loc, build6_stat_loc): New
	inline functions.
	(build1_loc, build2_loc, build3_loc, build4_loc, build5_loc,
	build6_loc): New macros.

Index: gcc/tree.h
===================================================================
--- gcc/tree.h	(revision 164052)
+++ gcc/tree.h	(working copy)
@@ -3992,23 +3992,102 @@  extern tree build_nt_call_vec (tree, VEC
 
 extern tree build0_stat (enum tree_code, tree MEM_STAT_DECL);
 #define build0(c,t) build0_stat (c,t MEM_STAT_INFO)
+
+
 extern tree build1_stat (enum tree_code, tree, tree MEM_STAT_DECL);
 #define build1(c,t1,t2) build1_stat (c,t1,t2 MEM_STAT_INFO)
+
+static inline tree
+build1_stat_loc (location_t loc, enum tree_code code, tree type,
+		 tree op MEM_STAT_DECL)
+{
+  tree t = build1_stat (code, type, op PASS_MEM_STAT);
+  SET_EXPR_LOCATION (t, loc);
+  return t;
+}
+#define build1_loc(l,c,t1,t2) build1_stat_loc (l,c,t1,t2 MEM_STAT_INFO)
+
+
 extern tree build2_stat (enum tree_code, tree, tree, tree MEM_STAT_DECL);
 #define build2(c,t1,t2,t3) build2_stat (c,t1,t2,t3 MEM_STAT_INFO)
+
+static inline tree
+build2_stat_loc (location_t loc, enum tree_code code, tree type, tree arg0,
+		 tree op MEM_STAT_DECL)
+{
+  tree t = build2_stat (code, type, arg0, op PASS_MEM_STAT);
+  SET_EXPR_LOCATION (t, loc);
+  return t;
+}
+#define build2_loc(l,c,t1,t2,t3) build2_stat_loc (l,c,t1,t2,t3 MEM_STAT_INFO)
+
+
 extern tree build3_stat (enum tree_code, tree, tree, tree, tree MEM_STAT_DECL);
 #define build3(c,t1,t2,t3,t4) build3_stat (c,t1,t2,t3,t4 MEM_STAT_INFO)
+
+static inline tree
+build3_stat_loc (location_t loc, enum tree_code code, tree type, tree arg0,
+		 tree arg1, tree op MEM_STAT_DECL)
+{
+  tree t = build3_stat (code, type, arg0, arg1, op PASS_MEM_STAT);
+  SET_EXPR_LOCATION (t, loc);
+  return t;
+}
+#define build3_loc(l,c,t1,t2,t3,t4) \
+  build3_stat_loc (l,c,t1,t2,t3,t4 MEM_STAT_INFO)
+
+
 extern tree build4_stat (enum tree_code, tree, tree, tree, tree,
 			 tree MEM_STAT_DECL);
 #define build4(c,t1,t2,t3,t4,t5) build4_stat (c,t1,t2,t3,t4,t5 MEM_STAT_INFO)
+
+static inline tree
+build4_stat_loc (location_t loc, enum tree_code code, tree type, tree arg0,
+		 tree arg1, tree arg2, tree op MEM_STAT_DECL)
+{
+  tree t = build4_stat (code, type, arg0, arg1, arg2, op PASS_MEM_STAT);
+  SET_EXPR_LOCATION (t, loc);
+  return t;
+}
+#define build4_loc(l,c,t1,t2,t3,t4,t5) \
+  build4_stat_loc (l,c,t1,t2,t3,t4,t5 MEM_STAT_INFO)
+
+
 extern tree build5_stat (enum tree_code, tree, tree, tree, tree, tree,
 			 tree MEM_STAT_DECL);
 #define build5(c,t1,t2,t3,t4,t5,t6) build5_stat (c,t1,t2,t3,t4,t5,t6 MEM_STAT_INFO)
+
+static inline tree
+build5_stat_loc (location_t loc, enum tree_code code, tree type, tree arg0,
+		 tree arg1, tree arg2, tree arg3, tree op MEM_STAT_DECL)
+{
+  tree t = build5_stat (code, type, arg0, arg1, arg2, arg3, op PASS_MEM_STAT);
+  SET_EXPR_LOCATION (t, loc);
+  return t;
+}
+#define build5_loc(l,c,t1,t2,t3,t4,t5,t6) \
+  build5_stat_loc (l,c,t1,t2,t3,t4,t5,t6 MEM_STAT_INFO)
+
+
 extern tree build6_stat (enum tree_code, tree, tree, tree, tree, tree,
 			 tree, tree MEM_STAT_DECL);
 #define build6(c,t1,t2,t3,t4,t5,t6,t7) \
   build6_stat (c,t1,t2,t3,t4,t5,t6,t7 MEM_STAT_INFO)
 
+static inline tree
+build6_stat_loc (location_t loc, enum tree_code code, tree type, tree arg0,
+		 tree arg1, tree arg2, tree arg3, tree arg4,
+		 tree op MEM_STAT_DECL)
+{
+  tree t = build6_stat (code, type, arg0, arg1, arg2, arg3, arg4,
+			op PASS_MEM_STAT);
+  SET_EXPR_LOCATION (t, loc);
+  return t;
+}
+#define build6_loc(l,c,t1,t2,t3,t4,t5,t6,t7) \
+  build6_stat_loc (l,c,t1,t2,t3,t4,t5,t6,t7 MEM_STAT_INFO)
+
+
 extern tree build_var_debug_value_stat (tree, tree MEM_STAT_DECL);
 #define build_var_debug_value(t1,t2) \
   build_var_debug_value_stat (t1,t2 MEM_STAT_INFO)