[patch] Fix PR c++/27315: ICE with ill-placed OpenMP #pragma

Lee Millward lee.millward@gmail.com
Wed Apr 26 20:30:00 GMT 2006


The C++ front-end currently ICE's on the following invalid test-case
when using OpenMP:

struct A
#pragma omp parallel
{
   template<int> void foo();
};

template void A::foo<0>();

pr27315.C:7: error: '#pragma' is not allowed here
pr27315.C:12: error: invalid use of incomplete type 'struct A'
pr27315.C:6: error: forward declaration of 'struct A'
pr27315.C:12: internal compiler error: tree check: expected tree that
contains 'decl common' structure, have 'error_mark'  in
do_decl_instantiation, at cp/pt.c:11209

This is because when do_decl_instantiation is called, the decl
argument pased is error_mark_node which isn't taken into account, so
when execution hits the following line the ICE occurs:

else if (! DECL_LANG_SPECIFIC (decl))

The proposed patch below fixes the ICE by adding an addition sanity
check that decl does not equal error_mark_node before continuing.

Bootstrapped and regression tested on i686-pc-linux-gnu with no new
failures. Ok for mainline?

cp/

2006-04-26  Lee Millward  <lee.millward@gmail.com>

       PR c++/27315
       * pt.c (do_decl_instantiation): Check that decl
       does not equal error_mark_node before continuing.

testsuite/

2006-04-26  Lee Millward  <lee.millward@gmail.com>

       PR c++/27315
       * g++.dg/gomp/pr27315.C: New test.



More information about the Gcc-patches mailing list