LCOV - code coverage report
Current view: top level - idlc/source - errorhandler.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 312 0.0 %
Date: 2014-04-14 Functions: 0 25 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <idlc/errorhandler.hxx>
      21             : #include <idlc/astinterface.hxx>
      22             : 
      23             : using namespace ::rtl;
      24             : 
      25           0 : static const sal_Char* errorCodeToMessage(ErrorCode eCode)
      26             : {
      27           0 :     switch (eCode)
      28             :     {
      29             :     case EIDL_NONE:
      30           0 :         return "all is fine ";
      31             :     case EIDL_SYNTAX_ERROR:
      32           0 :         return "";
      33             :     case EIDL_REDEF:
      34           0 :         return "illegal redefinition ";
      35             :     case EIDL_REDEF_SCOPE:
      36           0 :         return "illegal redefinition in scope ";
      37             :     case EIDL_DEF_USE:
      38           0 :         return "redefinition after use, ";
      39             :     case EIDL_COERCION_FAILURE:
      40           0 :         return "coercion failure ";
      41             :     case EIDL_SCOPE_CONFLICT:
      42           0 :         return "definition scope is different than fwd declare scope, ";
      43             :     case EIDL_ILLEGAL_ADD:
      44           0 :         return "illegal add operation, ";
      45             :     case EIDL_ILLEGAL_USE:
      46           0 :         return "illegal type used in expression, ";
      47             :     case EIDL_ILLEGAL_RAISES:
      48           0 :         return "non-exception type in raises(..) clause, ";
      49             :     case EIDL_CANT_INHERIT:
      50           0 :         return "cannot inherit ";
      51             :     case EIDL_LOOKUP_ERROR:
      52           0 :         return "error in lookup of symbol: ";
      53             :     case EIDL_INHERIT_FWD_ERROR:
      54           0 :         return "";
      55             :     case EIDL_CONSTANT_EXPECTED:
      56           0 :         return "constant expected: ";
      57             :     case EIDL_NAME_CASE_ERROR:
      58           0 :         return "identifier used with two differing spellings: ";
      59             :     case EIDL_EVAL_ERROR:
      60           0 :         return "expression evaluation error: ";
      61             :     case EIDL_AMBIGUOUS:
      62           0 :         return "ambiguous definition: ";
      63             :     case EIDL_DECL_NOT_DEFINED:
      64           0 :         return "forward declared but never defined: ";
      65             :     case EIDL_FWD_DECL_LOOKUP:
      66           0 :         return "";
      67             :     case EIDL_RECURSIVE_TYPE:
      68           0 :         return "illegal recursive use of type: ";
      69             :     case EIDL_NOT_A_TYPE:
      70           0 :         return "specified symbol is not a type: ";
      71             :     case EIDL_TYPE_NOT_VALID:
      72           0 :         return "specified type is not valid in this context: ";
      73             :     case EIDL_INTERFACEMEMBER_LOOKUP:
      74           0 :         return "error in lookup of symbol, expected interface is not defined and no forward exists: ";
      75             :     case EIDL_SERVICEMEMBER_LOOKUP:
      76           0 :         return "error in lookup of symbol, expected service is not defined: ";
      77             :     case EIDL_TYPE_IDENT_CONFLICT:
      78           0 :         return "type and parameter/member name are equal: ";
      79             :     case EIDL_WRONGATTRIBUTEFLAG:
      80           0 :         return "the used flag is not valid in this context: ";
      81             :     case EIDL_DEFINED_ATTRIBUTEFLAG:
      82           0 :         return "flag is already set: ";
      83             :     case EIDL_WRONGATTRIBUTEKEYWORD:
      84           0 :         return "keyword not allowed: ";
      85             :     case EIDL_MISSINGATTRIBUTEKEYWORD:
      86           0 :         return "missing keyword: ";
      87             :     case EIDL_BAD_ATTRIBUTE_FLAGS:
      88             :         return
      89             :             "the 'attribute' flag is mandatory, and only the 'bound' and"
      90           0 :             " 'readonly' optional flags are accepted: ";
      91             :     case EIDL_OPTIONALEXPECTED:
      92           0 :         return "only the 'optional' flag is accepted: ";
      93             :     case EIDL_MIXED_INHERITANCE:
      94             :         return "interface inheritance declarations cannot appear in both an"
      95           0 :             " interface's header and its body";
      96             :     case EIDL_DOUBLE_INHERITANCE:
      97             :         return
      98           0 :             "interface is (directly or indirectly) inherited more than once: ";
      99             :     case EIDL_DOUBLE_MEMBER:
     100             :         return
     101           0 :             "member is (directly or indirectly) declared more than once: ";
     102             :     case EIDL_CONSTRUCTOR_PARAMETER_NOT_IN:
     103             :         return
     104             :             "a service constructor parameter may not be an out or inout"
     105           0 :             " parameter";
     106             :     case EIDL_CONSTRUCTOR_REST_PARAMETER_NOT_FIRST:
     107             :         return
     108             :             "no parameters may precede a rest parameter in a service"
     109           0 :             " constructor";
     110             :     case EIDL_REST_PARAMETER_NOT_LAST:
     111           0 :         return "no parameters may follow a rest parameter";
     112             :     case EIDL_REST_PARAMETER_NOT_ANY:
     113           0 :         return "a rest parameter must be of type any";
     114             :     case EIDL_METHOD_HAS_REST_PARAMETER:
     115           0 :         return "a rest parameter may not be used on an interface method";
     116             :     case EIDL_READONLY_ATTRIBUTE_SET_EXCEPTIONS:
     117           0 :         return "a readonly attribute may not have a setter raises clause";
     118             :     case EIDL_UNSIGNED_TYPE_ARGUMENT:
     119           0 :         return "an unsigned type cannot be used as a type argument";
     120             :     case EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS:
     121             :         return
     122             :             "the number of given type arguments does not match the expected"
     123           0 :             " number of type parameters";
     124             :     case EIDL_INSTANTIATED_STRUCT_TYPE_TYPEDEF:
     125             :         return
     126             :             "an instantiated polymorphic struct type cannot be used in a"
     127           0 :             " typedef";
     128             :     case EIDL_IDENTICAL_TYPE_PARAMETERS:
     129           0 :         return "two type parameters have the same name";
     130             :     case EIDL_STRUCT_TYPE_TEMPLATE_WITH_BASE:
     131           0 :         return "a polymorphic struct type template may not have a base type";
     132             :     case EIDL_PUBLISHED_FORWARD:
     133             :         return
     134             :             "a published forward declaration of an interface type cannot be"
     135           0 :             " followed by an unpublished declaration of that type";
     136             :     case EIDL_PUBLISHED_USES_UNPUBLISHED:
     137             :         return
     138             :             "an unpublished entity cannot be used in the declaration of a"
     139           0 :             " published entity: ";
     140             :     case EIDL_SIMILAR_CONSTRUCTORS:
     141           0 :         return "two constructors have identical lists of parameter types";
     142             :     }
     143           0 :     return "unknown error";
     144             : }
     145             : 
     146           0 : static const sal_Char* warningCodeToMessage(WarningCode wCode)
     147             : {
     148           0 :     switch (wCode)
     149             :     {
     150             :     case WIDL_EXPID_CONFLICT:
     151           0 :         return "exception id conflict: ";
     152             :     case WIDL_REQID_CONFLICT:
     153           0 :         return "request id conflict: ";
     154             :     case WIDL_INHERIT_IDCONFLICT:
     155           0 :         return "request id conflict in inheritance tree: ";
     156             :     case WIDL_TYPE_IDENT_CONFLICT:
     157           0 :         return "type and parameter|member name are equal: ";
     158             :     case WIDL_WRONG_NAMING_CONV:
     159           0 :         return "type or identifier doesn't fulfill the UNO naming convention: ";
     160             :     }
     161           0 :     return "unknown warning";
     162             : }
     163             : 
     164           0 : static const sal_Char* parseStateToMessage(ParseState state)
     165             : {
     166           0 :     switch (state)
     167             :     {
     168             :     case PS_NoState:
     169           0 :         return "Statement can not be parsed";
     170             :     case PS_TypeDeclSeen:
     171           0 :         return "Malformed type declaration";
     172             :     case PS_ConstantDeclSeen:
     173           0 :         return "Malformed const declaration";
     174             :     case PS_ExceptionDeclSeen:
     175           0 :         return "Malformed exception declaration";
     176             :     case PS_InterfaceDeclSeen:
     177           0 :         return "Malformed interface declaration";
     178             :     case PS_ServiceDeclSeen:
     179           0 :         return "Malformed service declaration";
     180             :     case PS_ModuleDeclSeen:
     181           0 :         return "Malformed module declaration";
     182             :     case PS_AttributeDeclSeen:
     183           0 :         return "Malformed attribute declaration";
     184             :     case PS_PropertyDeclSeen:
     185           0 :         return "Malformed property declaration";
     186             :     case PS_OperationDeclSeen:
     187           0 :         return "Malformed operation declaration";
     188             :     case PS_InterfaceInheritanceDeclSeen:
     189           0 :         return "Malformed interface inheritance declaration";
     190             :     case PS_ConstantsDeclSeen:
     191           0 :         return "Malformed constants declaration";
     192             :     case PS_ServiceSeen:
     193           0 :         return "Missing service identifier following SERVICE keyword";
     194             :     case PS_ServiceIDSeen:
     195           0 :         return "Missing '{' or illegal syntax following service identifier";
     196             :     case PS_ServiceSqSeen:
     197           0 :         return "Illegal syntax following service '{' opener";
     198             :     case PS_ServiceBodySeen:
     199           0 :         return "Illegal syntax following service '}' closer";
     200             :     case PS_ServiceMemberSeen:
     201           0 :         return "Illegal syntax following service member declaration";
     202             :     case PS_ServiceIFHeadSeen:
     203           0 :         return "Illegal syntax following header of an interface member";
     204             :     case PS_ServiceSHeadSeen:
     205           0 :         return "Illegal syntax following header of an service member";
     206             :     case PS_ModuleSeen:
     207           0 :         return "Missing module identifier following MODULE keyword";
     208             :     case PS_ModuleIDSeen:
     209           0 :         return "Missing '{' or illegal syntax following module identifier";
     210             :     case PS_ModuleSqSeen:
     211           0 :         return "Illegal syntax following module '{' opener";
     212             :     case PS_ModuleQsSeen:
     213           0 :         return "Illegal syntax following module '}' closer";
     214             :     case PS_ModuleBodySeen:
     215           0 :         return "Illegal syntax following module export(s)";
     216             :     case PS_ConstantsSeen:
     217           0 :         return "Missing constants identifier following CONSTANTS keyword";
     218             :     case PS_ConstantsIDSeen:
     219           0 :         return "Missing '{' or illegal syntax following constants identifier";
     220             :     case PS_ConstantsSqSeen:
     221           0 :         return "Illegal syntax following module '{' opener";
     222             :     case PS_ConstantsQsSeen:
     223           0 :         return "Illegal syntax following module '}' closer";
     224             :     case PS_ConstantsBodySeen:
     225           0 :         return "Illegal syntax following constants export(s)";
     226             :     case PS_InterfaceSeen:
     227           0 :         return "Missing interface identifier following INTERFACE keyword";
     228             :     case PS_InterfaceIDSeen:
     229           0 :         return "Illegal syntax following interface identifier";
     230             :     case PS_InterfaceHeadSeen:
     231           0 :         return "Illegal syntax following interface head";
     232             :     case PS_InheritSpecSeen:
     233           0 :         return "Missing '{' or illegal syntax following inheritance spec";
     234             :     case PS_ForwardDeclSeen:
     235           0 :         return "Missing ';' following forward interface declaration";
     236             :     case PS_InterfaceSqSeen:
     237           0 :         return "Illegal syntax following interface '{' opener";
     238             :     case PS_InterfaceQsSeen:
     239           0 :         return "Illegal syntax following interface '}' closer";
     240             :     case PS_InterfaceBodySeen:
     241           0 :         return "Illegal syntax following interface export(s)";
     242             :     case PS_InheritColonSeen:
     243           0 :         return "Illegal syntax following ':' starting inheritance list";
     244             :     case PS_SNListCommaSeen:
     245           0 :         return "Found illegal scoped name in scoped name list";
     246             :     case PS_ScopedNameSeen:
     247           0 :         return "Missing ',' following scoped name in scoped name list";
     248             :     case PS_SN_IDSeen:
     249           0 :         return "Illegal component in scoped name";
     250             :     case PS_ScopeDelimSeen:
     251           0 :         return "Illegal component in scoped name following '::'";
     252             :     case PS_ConstSeen:
     253           0 :         return "Missing type or illegal syntax following CONST keyword";
     254             :     case PS_ConstTypeSeen:
     255           0 :         return "Missing identifier or illegal syntax following const type";
     256             :     case PS_ConstIDSeen:
     257           0 :         return "Missing '=' or illegal syntax after const identifier";
     258             :     case PS_ConstAssignSeen:
     259           0 :         return "Missing value expr or illegal syntax following '='";
     260             :     case PS_ConstExprSeen:
     261           0 :         return "Missing ';' or illegal syntax following value expr in const";
     262             :     case PS_TypedefSeen:
     263           0 :         return "Missing type or illegal syntax following TYPEDEF keyword";
     264             :     case PS_TypeSpecSeen:
     265           0 :         return "Missing declarators or illegal syntax following type spec";
     266             :     case PS_DeclaratorsSeen:
     267           0 :         return "Illegal syntax following declarators in TYPEDEF declaration";
     268             :     case PS_StructSeen:
     269           0 :         return "Missing struct identifier following STRUCT keyword";
     270             :     case PS_StructHeaderSeen:
     271           0 :         return "Missing '{' or illegal syntax following struct inheritance spec";
     272             :     case PS_StructIDSeen:
     273           0 :         return "Missing '{' or illegal syntax following struct identifier";
     274             :     case PS_StructSqSeen:
     275           0 :         return "Illegal syntax following struct '{' opener";
     276             :     case PS_StructQsSeen:
     277           0 :         return "Illegal syntax following struct '}' closer";
     278             :     case PS_StructBodySeen:
     279           0 :         return "Illegal syntax following struct member(s)";
     280             :     case PS_MemberTypeSeen:
     281           0 :         return "Illegal syntax or missing identifier following member type";
     282             :     case PS_MemberDeclsSeen:
     283           0 :         return "Illegal syntax following member declarator(s)";
     284             :     case PS_MemberDeclsCompleted:
     285           0 :         return "Missing ',' between member decls of same type(?)";
     286             :     case PS_EnumSeen:
     287           0 :         return "Illegal syntax or missing identifier following ENUM keyword";
     288             :     case PS_EnumIDSeen:
     289           0 :         return "Illegal syntax or missing '{' following enum identifier";
     290             :     case PS_EnumSqSeen:
     291           0 :         return "Illegal syntax following enum '{' opener";
     292             :     case PS_EnumQsSeen:
     293           0 :         return "Illegal syntax following enum '}' closer";
     294             :     case PS_EnumBodySeen:
     295           0 :         return "Illegal syntax following enum enumerator(s)";
     296             :     case PS_EnumCommaSeen:
     297           0 :         return "Illegal syntax or missing identifier following ',' in enum";
     298             :     case PS_SequenceSeen:
     299           0 :         return "Illegal syntax or missing '<' following SEQUENCE keyword";
     300             :     case PS_SequenceSqSeen:
     301           0 :         return "Illegal syntax or missing type following '<' in sequence";
     302             :     case PS_SequenceQsSeen:
     303           0 :         return "Illegal syntax following '>' in sequence";
     304             :     case PS_SequenceTypeSeen:
     305           0 :         return "Illegal syntax following sequence type declaration";
     306             :     case PS_FlagHeaderSeen:
     307           0 :         return "Illegal syntax after flags";
     308             :     case PS_AttrSeen:
     309           0 :         return "Illegal syntax after ATTRIBUTE keyword";
     310             :     case PS_AttrTypeSeen:
     311           0 :         return "Illegal syntax after type in attribute declaration";
     312             :     case PS_AttrCompleted:
     313           0 :         return "Illegal syntax after attribute declaration";
     314             :     case PS_ReadOnlySeen:
     315           0 :         return "Illegal syntax after READONLY keyword";
     316             :     case PS_OptionalSeen:
     317           0 :         return "Illegal syntax after OPTIONAL keyword";
     318             :     case PS_MayBeVoidSeen:
     319           0 :         return "Illegal syntax after MAYBEVOID keyword";
     320             :     case PS_BoundSeen:
     321           0 :         return "Illegal syntax after BOUND keyword";
     322             :     case PS_ConstrainedSeen:
     323           0 :         return "Illegal syntax after CONSTRAINED keyword";
     324             :     case PS_TransientSeen:
     325           0 :         return "Illegal syntax after TRANSIENT keyword";
     326             :     case PS_MayBeAmbigiousSeen:
     327           0 :         return "Illegal syntax after MAYBEAMBIGIOUS keyword";
     328             :     case PS_MayBeDefaultSeen:
     329           0 :         return "Illegal syntax after MAYBEDEFAULT keyword";
     330             :     case PS_RemoveableSeen:
     331           0 :         return "Illegal syntax after REMOVABLE keyword";
     332             :     case PS_PropertySeen:
     333           0 :         return "Illegal syntax after PROPERTY keyword";
     334             :     case PS_PropertyTypeSeen:
     335           0 :         return "Illegal syntax after type in property declaration";
     336             :     case PS_PropertyCompleted:
     337           0 :         return "Illegal syntax after property declaration";
     338             :     case PS_ExceptSeen:
     339           0 :         return "Illegal syntax or missing identifier after EXCEPTION keyword";
     340             :     case PS_ExceptHeaderSeen:
     341           0 :         return "Missing '{' or illegal syntax following exception inheritance spec";
     342             :     case PS_ExceptIDSeen:
     343           0 :         return "Illegal syntax or missing '{' after exception identifier";
     344             :     case PS_ExceptSqSeen:
     345           0 :         return "Illegal syntax after exception '{' opener";
     346             :     case PS_ExceptQsSeen:
     347           0 :         return "Illegal syntax after exception '}' closer";
     348             :     case PS_ExceptBodySeen:
     349           0 :         return "Illegal syntax after exception member(s)";
     350             :     case PS_OpTypeSeen:
     351           0 :         return "Illegal syntax or missing identifier after operation type";
     352             :     case PS_OpIDSeen:
     353           0 :         return "Illegal syntax or missing '(' after operation identifier";
     354             :     case PS_OpParsCompleted:
     355           0 :         return "Illegal syntax after operation parameter list";
     356             :     case PS_OpCompleted:
     357           0 :         return "Illegal syntax after operation declaration";
     358             :     case PS_OpSqSeen:
     359           0 :         return "Illegal syntax after operation parameter list '(' opener";
     360             :     case PS_OpQsSeen:
     361           0 :         return "Illegal syntax after operation parameter list ')' closer";
     362             :     case PS_OpParCommaSeen:
     363           0 :         return "Illegal syntax or missing direction in parameter declaration";
     364             :     case PS_OpParDirSeen:
     365           0 :         return "Illegal syntax or missing type in parameter declaration";
     366             :     case PS_OpParTypeSeen:
     367           0 :         return "Illegal syntax or missing declarator in parameter declaration";
     368             :     case PS_OpParDeclSeen:
     369           0 :         return "Illegal syntax following parameter declarator";
     370             :     case PS_RaiseSeen:
     371           0 :         return "Illegal syntax or missing '(' after RAISES keyword";
     372             :     case PS_RaiseSqSeen:
     373           0 :         return "Illegal syntax after RAISES '(' opener";
     374             :     case PS_RaiseQsSeen:
     375           0 :         return "Illegal syntax after RAISES ')' closer";
     376             :     case PS_DeclsCommaSeen:
     377           0 :         return "Illegal syntax after ',' in declarators list";
     378             :     case PS_DeclsDeclSeen:
     379           0 :         return "Illegal syntax after declarator in declarators list";
     380             :     default:
     381           0 :         return "no wider described syntax error";
     382             :     }
     383             : }
     384             : 
     385           0 : static OString flagToString(sal_uInt32 flag)
     386             : {
     387           0 :     OString flagStr;
     388           0 :     if ( (flag & AF_READONLY) == AF_READONLY )
     389           0 :         flagStr += "'readonly'";
     390           0 :     if ( (flag & AF_OPTIONAL) == AF_OPTIONAL )
     391           0 :         flagStr += "'optional'";
     392           0 :     if ( (flag & AF_MAYBEVOID) == AF_MAYBEVOID )
     393           0 :         flagStr += "'maybevoid'";
     394           0 :     if ( (flag & AF_BOUND) == AF_BOUND )
     395           0 :         flagStr += "'bound'";
     396           0 :     if ( (flag & AF_CONSTRAINED) == AF_CONSTRAINED )
     397           0 :         flagStr += "'constrained'";
     398           0 :     if ( (flag & AF_TRANSIENT) == AF_TRANSIENT )
     399           0 :             flagStr += "'transient'";
     400           0 :     if ( (flag & AF_MAYBEAMBIGUOUS) == AF_MAYBEAMBIGUOUS )
     401           0 :         flagStr += "'maybeambiguous'";
     402           0 :     if ( (flag & AF_MAYBEDEFAULT) == AF_MAYBEDEFAULT )
     403           0 :         flagStr += "'maybedefault'";
     404           0 :     if ( (flag & AF_REMOVABLE) == AF_REMOVABLE )
     405           0 :         flagStr += "'removable'";
     406           0 :     if ( (flag & AF_ATTRIBUTE) == AF_ATTRIBUTE )
     407           0 :         flagStr += "'attribute'";
     408           0 :     if ( (flag & AF_PROPERTY) == AF_PROPERTY )
     409           0 :         flagStr += "'property'";
     410           0 :     if ( flagStr.isEmpty() )
     411           0 :         flagStr += "'unknown'";
     412             : 
     413           0 :     return flagStr;
     414             : }
     415             : 
     416           0 : static void errorHeader(ErrorCode eCode, sal_Int32 lineNumber, sal_uInt32 start, sal_uInt32 end)
     417             : {
     418           0 :     OString file;
     419           0 :     if ( idlc()->getFileName() == idlc()->getRealFileName() )
     420           0 :         file = idlc()->getMainFileName();
     421             :     else
     422           0 :         file = idlc()->getFileName();
     423             : 
     424             :     fprintf(stderr, "%s:%lu [%lu:%lu] : %s", file.getStr(),
     425             :             sal::static_int_cast< unsigned long >(lineNumber),
     426             :             sal::static_int_cast< unsigned long >(start),
     427             :             sal::static_int_cast< unsigned long >(end),
     428           0 :             errorCodeToMessage(eCode));
     429           0 : }
     430             : 
     431           0 : static void errorHeader(ErrorCode eCode, sal_uInt32 lineNumber)
     432             : {
     433             :     errorHeader(eCode, lineNumber,
     434           0 :             idlc()->getOffsetStart(), idlc()->getOffsetEnd());
     435           0 : }
     436             : 
     437           0 : static void errorHeader(ErrorCode eCode)
     438             : {
     439           0 :     errorHeader(eCode, idlc()->getLineNumber(),
     440           0 :             idlc()->getOffsetStart(), idlc()->getOffsetEnd());
     441           0 : }
     442             : 
     443           0 : static void warningHeader(WarningCode wCode)
     444             : {
     445           0 :     OString file;
     446           0 :     if ( idlc()->getFileName() == idlc()->getRealFileName() )
     447           0 :         file = idlc()->getMainFileName();
     448             :     else
     449           0 :         file = idlc()->getFileName();
     450             : 
     451             :     fprintf(stderr, "%s(%lu) : WARNING, %s", file.getStr(),
     452             :             sal::static_int_cast< unsigned long >(idlc()->getLineNumber()),
     453           0 :             warningCodeToMessage(wCode));
     454           0 : }
     455             : 
     456           0 : void ErrorHandler::error0(ErrorCode e)
     457             : {
     458           0 :     errorHeader(e);
     459           0 :     fprintf(stderr, "\n");
     460           0 :     idlc()->incErrorCount();
     461           0 : }
     462             : 
     463           0 : void ErrorHandler::error1(ErrorCode e, AstDeclaration const * d)
     464             : {
     465           0 :     errorHeader(e);
     466           0 :     fprintf(stderr, "'%s'\n", d->getScopedName().getStr());
     467           0 :     idlc()->incErrorCount();
     468           0 : }
     469             : 
     470           0 : void ErrorHandler::error2(
     471             :     ErrorCode e, AstDeclaration const * d1, AstDeclaration const * d2)
     472             : {
     473           0 :     errorHeader(e);
     474           0 :     fprintf(stderr, "'%s', '%s'\n", d1->getScopedName().getStr(),
     475           0 :             d2->getScopedName().getStr());
     476           0 :     idlc()->incErrorCount();
     477           0 : }
     478             : 
     479           0 : void ErrorHandler::error3(ErrorCode e, AstDeclaration* d1, AstDeclaration* d2, AstDeclaration* d3)
     480             : {
     481           0 :     errorHeader(e);
     482           0 :     fprintf(stderr, "'%s', '%s', '%s'\n", d1->getScopedName().getStr(),
     483           0 :             d2->getScopedName().getStr(), d3->getScopedName().getStr());
     484           0 :     idlc()->incErrorCount();
     485           0 : }
     486             : 
     487           0 : void ErrorHandler::warning0(WarningCode w, const sal_Char* warningmsg)
     488             : {
     489           0 :     if ( idlc()->getOptions()->isValid("-w") || idlc()->getOptions()->isValid("-we") ) {
     490           0 :         warningHeader(w);
     491           0 :         fprintf(stderr, "%s\n", warningmsg);
     492             :     }
     493             : 
     494           0 :     if ( idlc()->getOptions()->isValid("-we") )
     495           0 :         idlc()->incErrorCount();
     496             :     else
     497           0 :         idlc()->incWarningCount();
     498           0 : }
     499             : 
     500           0 : void ErrorHandler::syntaxError(ParseState ps, sal_Int32 lineNumber, const sal_Char* errmsg)
     501             : {
     502           0 :     errorHeader(EIDL_SYNTAX_ERROR, lineNumber);
     503           0 :     fprintf(stderr, "%s: %s\n", parseStateToMessage(ps), errmsg);
     504           0 :     idlc()->incErrorCount();
     505           0 : }
     506             : 
     507           0 : void ErrorHandler::coercionError(AstExpression *pExpr, ExprType et)
     508             : {
     509           0 :     errorHeader(EIDL_COERCION_FAILURE);
     510             :     fprintf(stderr, "'%s' to '%s'\n", pExpr->toString().getStr(),
     511           0 :             exprTypeToString(et));
     512           0 :     idlc()->incErrorCount();
     513           0 : }
     514             : 
     515           0 : void ErrorHandler::lookupError(const OString& n)
     516             : {
     517           0 :     errorHeader(EIDL_LOOKUP_ERROR);
     518           0 :     fprintf(stderr, "'%s'\n", n.getStr());
     519           0 :     idlc()->incErrorCount();
     520           0 : }
     521             : 
     522           0 : void ErrorHandler::lookupError(ErrorCode e, const OString& n, AstDeclaration* pScope)
     523             : {
     524           0 :     errorHeader(e);
     525           0 :     fprintf(stderr, "'%s' in '%s'\n", n.getStr(), pScope->getFullName().getStr());
     526           0 :     idlc()->incErrorCount();
     527           0 : }
     528             : 
     529           0 : void ErrorHandler::flagError(ErrorCode e, sal_uInt32 flag)
     530             : {
     531           0 :     errorHeader(e);
     532           0 :     fprintf(stderr, "'%s'\n", flagToString(flag).getStr());
     533           0 :     idlc()->incErrorCount();
     534           0 : }
     535             : 
     536           0 : void ErrorHandler::noTypeError(AstDeclaration const * pDecl)
     537             : {
     538           0 :     errorHeader(EIDL_NOT_A_TYPE);
     539           0 :     fprintf(stderr, "'%s'\n", pDecl->getScopedName().getStr());
     540           0 :     idlc()->incErrorCount();
     541           0 : }
     542             : 
     543             : namespace {
     544             : 
     545           0 : char const * nodeTypeName(NodeType nodeType) {
     546           0 :     switch (nodeType) {
     547             :     case NT_interface:
     548           0 :         return "interface";
     549             : 
     550             :     case NT_exception:
     551           0 :         return "exception";
     552             : 
     553             :     case NT_struct:
     554           0 :         return "struct";
     555             : 
     556             :     default:
     557           0 :         return "";
     558             :     }
     559             : }
     560             : 
     561             : }
     562             : 
     563           0 : void ErrorHandler::inheritanceError(NodeType nodeType, const OString* name, AstDeclaration* pDecl)
     564             : {
     565           0 :     if ( nodeType == NT_interface &&
     566           0 :          (pDecl->getNodeType() == NT_interface) &&
     567           0 :          !((AstInterface*)pDecl)->isDefined() )
     568             :     {
     569           0 :         errorHeader(EIDL_INHERIT_FWD_ERROR);
     570             :         fprintf(stderr, "interface '%s' cannot inherit from forward declared interface '%s'\n",
     571           0 :                 name->getStr(), pDecl->getScopedName().getStr());
     572             :     } else
     573             :     {
     574           0 :         errorHeader(EIDL_CANT_INHERIT);
     575             :         fprintf(stderr, "%s '%s' from '%s'\n",
     576             :                 nodeTypeName(nodeType), name->getStr(),
     577           0 :                 pDecl->getScopedName().getStr());
     578             :     }
     579           0 :     idlc()->incErrorCount();
     580           0 : }
     581             : 
     582           0 : void ErrorHandler::forwardLookupError(AstDeclaration* pForward,
     583             :                                       const OString& name)
     584             : {
     585           0 :     errorHeader(EIDL_FWD_DECL_LOOKUP);
     586             :     fprintf(stderr, "trying to look up '%s' in undefined forward declared interface '%s'\n",
     587           0 :             pForward->getScopedName().getStr(), name.getStr());
     588           0 :     idlc()->incErrorCount();
     589           0 : }
     590             : 
     591           0 : void ErrorHandler::constantExpected(AstDeclaration* pDecl,
     592             :                                     const OString& name)
     593             : {
     594           0 :     errorHeader(EIDL_CONSTANT_EXPECTED);
     595           0 :     fprintf(stderr, "'%s' is bound to '%s'\n", name.getStr(), pDecl->getScopedName().getStr());
     596           0 :     idlc()->incErrorCount();
     597           0 : }
     598             : 
     599           0 : void ErrorHandler::evalError(AstExpression* pExpr)
     600             : {
     601           0 :     errorHeader(EIDL_EVAL_ERROR);
     602           0 :     fprintf(stderr, "'%s'\n", pExpr->toString().getStr());
     603           0 :     idlc()->incErrorCount();
     604           0 : }
     605             : 
     606           0 : bool ErrorHandler::checkPublished(AstDeclaration const * decl, bool bOptional) {
     607           0 :     if (idlc()->isPublished() && !decl->isPublished() && !bOptional) {
     608           0 :         error1(EIDL_PUBLISHED_USES_UNPUBLISHED, decl);
     609           0 :         return false;
     610             :     } else {
     611           0 :         return true;
     612             :     }
     613             : }
     614             : 
     615             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10