C++ only


This option controls whether parsing and semantic checking are applied to template definitions (class template definitions, function bodies, member function bodies, and static data member initializers) or only to template instantiations. The compiler can check function bodies and variable initializers in template definitions and produce error or warning messages.


Read syntax diagramSkip visual syntax diagram                      .-no----.
>>- -q--tmplparse--=--+-warn--+--------------------------------><

where suboptions are:

no Do not parse the template definitions. This reduces the number of errors issued in code written for previous versions of VisualAge C++ and predecessor products. This is the default.
warn Parses template definitions and issues warning messages for semantic errors.
error Treats problems in template definitions as errors, even if the template is not instantiated.


This option applies to template definitions, not their instantiations. Regardless of the setting of this option, error messages are produced for problems that appear outside definitions. For example, errors found during the parsing or semantic checking of constructs such as the following, always cause error messages:


Example 1:

In the following example the template class is not instantiated, therefore it is never parsed by the compile and if you do not use -qtmplparse=error option, the compiler do not find any syntax error. However; if you use -qtmplparse=error the template class is parsed and the compiler flags the error message.

template <class A> struct container
   A a1;
   A foo1()      //syntax error
   int _data;

xlC -c -qtmplparse=error myprogram.cpp 

Example 2:

In the following example a containing class is not instantiated, therefore its out-of-line member definition is not parsed. If you do not use -qtmplparse=error the compiler does not issue an error message for the mismatch between the out-of-line definition and the original definition.

template <class A> struct container
   void member(A a);

// error - this member is not declared in the struct container
template <class B> void container<B>::member()   {
xlC -c -qtmplparse=error myprogram.cpp 
Whether you use -qtmplparse=error or not , if you try to instantiate the class compiler will issue an error message.

Related information