This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi! When processing_template_decl, cp_build_modify_expr just silently casts the RHS to LHS's type using NOP_EXPR, expecting the result will be eventually thrown away anyway and the original values get through to tsubst*. As c_finish_omp_for doesn't verify init's type, it is ok to just use build2 MODIFY_EXPR when processing_template_decl, cp_build_modify_expr will be called during tsubst* that way with the original initializer rather than initializer wrapped into a NOP_EXPR. Regtested on i686-linux, committed to trunk. 2008-09-23 Jakub Jelinek <jakub@redhat.com> PR c++/37533 * semantics.c (finish_omp_for): If processing_template_decl, just build MODIFY_EXPR for init instead of calling cp_build_modify_expr. * g++.dg/gomp/pr37533.C: New test. --- gcc/cp/semantics.c.jj 2008-09-21 22:23:28.000000000 +0200 +++ gcc/cp/semantics.c 2008-09-22 19:59:51.000000000 +0200 @@ -4290,8 +4290,12 @@ finish_omp_for (location_t locus, tree d } if (!processing_template_decl) - init = fold_build_cleanup_point_expr (TREE_TYPE (init), init); - init = cp_build_modify_expr (decl, NOP_EXPR, init, tf_warning_or_error); + { + init = fold_build_cleanup_point_expr (TREE_TYPE (init), init); + init = cp_build_modify_expr (decl, NOP_EXPR, init, tf_warning_or_error); + } + else + init = build2 (MODIFY_EXPR, void_type_node, decl, init); if (cond && TREE_SIDE_EFFECTS (cond) && COMPARISON_CLASS_P (cond)) { int n = TREE_SIDE_EFFECTS (TREE_OPERAND (cond, 1)) != 0; --- gcc/testsuite/g++.dg/gomp/pr37533.C.jj 2008-09-22 20:08:55.000000000 +0200 +++ gcc/testsuite/g++.dg/gomp/pr37533.C 2008-09-22 20:08:28.000000000 +0200 @@ -0,0 +1,50 @@ +// PR c++/37533 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template<int> +void +f1 () +{ +#pragma omp parallel for + for (int i = ""; i < 4; ++i) // { dg-error "invalid conversion from" } + ; +} + +template<int> +void +f2 () +{ + int i; +#pragma omp parallel for + for (i = ""; i < 4; ++i) // { dg-error "invalid conversion from" } + ; +} + +template<typename T> +void +f3 () +{ +#pragma omp parallel for + for (T i = ""; i < 4; ++i) // { dg-error "invalid conversion from" } + ; +} + +template<typename T> +void +f4 () +{ + T i; +#pragma omp parallel for + for (i = ""; i < 4; ++i) // { dg-error "invalid conversion from" } + ; +} + +void +bar () +{ + f1<0> (); // { dg-message "instantiated from here" } + f2<1> (); // { dg-message "instantiated from here" } + f3<int> (); // { dg-message "instantiated from here" } + f4<int> (); // { dg-message "instantiated from here" } +} Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |