summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2002-08-13 06:45:32 +0000
committerMichi Henning <michi@zeroc.com>2002-08-13 06:45:32 +0000
commit188bed46ca85b141af937ebab48ac2b25aa23ebb (patch)
treee0e2a25fc3f120c5e5fb7e5f94a1cb35148ce688 /cpp/src
parentChanged nonmutating from metadata do keyword. (diff)
downloadice-188bed46ca85b141af937ebab48ac2b25aa23ebb.tar.bz2
ice-188bed46ca85b141af937ebab48ac2b25aa23ebb.tar.xz
ice-188bed46ca85b141af937ebab48ac2b25aa23ebb.zip
Fixed assertion bug for operation redefinitions.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Slice/Grammar.y106
-rw-r--r--cpp/src/Slice/Scanner.l3
2 files changed, 68 insertions, 41 deletions
diff --git a/cpp/src/Slice/Grammar.y b/cpp/src/Slice/Grammar.y
index 002bb45d8c6..2ed33e281d9 100644
--- a/cpp/src/Slice/Grammar.y
+++ b/cpp/src/Slice/Grammar.y
@@ -1123,9 +1123,11 @@ parameters
TypePtr type = tsp->v.first;
string ident = tsp->v.second;
OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer());
- assert(op);
- ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v);
- unit->currentContainer()->checkIntroduced(ident, pd);
+ if(op)
+ {
+ ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v);
+ unit->currentContainer()->checkIntroduced(ident, pd);
+ }
}
| parameters ',' out_qualifier type_id
{
@@ -1134,9 +1136,11 @@ parameters
TypePtr type = tsp->v.first;
string ident = tsp->v.second;
OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer());
- assert(op);
- ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v);
- unit->currentContainer()->checkIntroduced(ident, pd);
+ if(op)
+ {
+ ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v);
+ unit->currentContainer()->checkIntroduced(ident, pd);
+ }
}
| out_qualifier type keyword
{
@@ -1144,9 +1148,11 @@ parameters
TypePtr type = TypePtr::dynamicCast($2);
StringTokPtr ident = StringTokPtr::dynamicCast($3);
OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer());
- assert(op);
- op->createParamDecl(ident->v, type, isOutParam->v);
- unit->error("keyword `" + ident->v + "' cannot be used as parameter name");
+ if(op)
+ {
+ op->createParamDecl(ident->v, type, isOutParam->v);
+ unit->error("keyword `" + ident->v + "' cannot be used as parameter name");
+ }
}
| parameters ',' out_qualifier type keyword
{
@@ -1154,27 +1160,33 @@ parameters
TypePtr type = TypePtr::dynamicCast($4);
StringTokPtr ident = StringTokPtr::dynamicCast($5);
OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer());
- assert(op);
- op->createParamDecl(ident->v, type, isOutParam->v);
- unit->error("keyword `" + ident->v + "' cannot be used as parameter name");
+ if(op)
+ {
+ op->createParamDecl(ident->v, type, isOutParam->v);
+ unit->error("keyword `" + ident->v + "' cannot be used as parameter name");
+ }
}
| out_qualifier type
{
BoolTokPtr isOutParam = BoolTokPtr::dynamicCast($1);
TypePtr type = TypePtr::dynamicCast($2);
OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer());
- assert(op);
- op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v);
- unit->error("missing parameter name");
+ if(op)
+ {
+ op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v);
+ unit->error("missing parameter name");
+ }
}
| parameters ',' out_qualifier type
{
BoolTokPtr isOutParam = BoolTokPtr::dynamicCast($3);
TypePtr type = TypePtr::dynamicCast($4);
OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer());
- assert(op);
- op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v);
- unit->error("missing parameter name");
+ if(op)
+ {
+ op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v);
+ unit->error("missing parameter name");
+ }
}
;
@@ -1264,42 +1276,56 @@ type
{
StringTokPtr scoped = StringTokPtr::dynamicCast($1);
ContainerPtr cont = unit->currentContainer();
- TypeList types = cont->lookupType(scoped->v);
- if(types.empty())
+ if(cont)
{
- YYERROR; // Can't continue, jump to next yyerrok
+ TypeList types = cont->lookupType(scoped->v);
+ if(types.empty())
+ {
+ YYERROR; // Can't continue, jump to next yyerrok
+ }
+ cont->checkIntroduced(scoped->v);
+ $$ = types.front();
+ }
+ else
+ {
+ $$ = 0;
}
- cont->checkIntroduced(scoped->v);
- $$ = types.front();
}
| scoped_name '*'
{
StringTokPtr scoped = StringTokPtr::dynamicCast($1);
ContainerPtr cont = unit->currentContainer();
- TypeList types = cont->lookupType(scoped->v);
- if(types.empty())
- {
- YYERROR; // Can't continue, jump to next yyerrok
- }
- for(TypeList::iterator p = types.begin(); p != types.end(); ++p)
+ if(cont)
{
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(*p);
- if(!cl)
+ TypeList types = cont->lookupType(scoped->v);
+ if(types.empty())
{
- string msg = "`";
- msg += scoped->v;
- msg += "' must be class or interface";
- unit->error(msg);
YYERROR; // Can't continue, jump to next yyerrok
}
- cont->checkIntroduced(scoped->v);
- if(cl->isLocal())
+ for(TypeList::iterator p = types.begin(); p != types.end(); ++p)
{
- unit->error("cannot create proxy for " + cl->kindOf() + " `" + cl->name() + "'");
+ ClassDeclPtr cl = ClassDeclPtr::dynamicCast(*p);
+ if(!cl)
+ {
+ string msg = "`";
+ msg += scoped->v;
+ msg += "' must be class or interface";
+ unit->error(msg);
+ YYERROR; // Can't continue, jump to next yyerrok
+ }
+ cont->checkIntroduced(scoped->v);
+ if(cl->isLocal())
+ {
+ unit->error("cannot create proxy for " + cl->kindOf() + " `" + cl->name() + "'");
+ }
+ *p = new Proxy(cl);
}
- *p = new Proxy(cl);
+ $$ = types.front();
+ }
+ else
+ {
+ $$ = 0;
}
- $$ = types.front();
}
;
diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l
index e49569aecf9..aefa6fd16d8 100644
--- a/cpp/src/Slice/Scanner.l
+++ b/cpp/src/Slice/Scanner.l
@@ -40,6 +40,7 @@ void initScanner();
%option noyywrap
%option never-interactive
+identifier \\?[[:alpha:]_][[:alnum:]_]*
integer_constant (\+|-)?((0[0-7]+)|(0x[[:xdigit:]]+)|([[:digit:]]+))
fractional_constant ([[:digit:]]*\.[[:digit:]]+)|([[:digit:]]+\.)
exponent_part (e|E)(\+|-)?[[:digit:]]+
@@ -121,7 +122,7 @@ floating_literal (({fractional_constant}{exponent_part}?)|([[:digit:]]+{exponent
return ICE_SCOPE_DELIMITER;
}
-\\?[[:alpha:]_][[:alnum:]_]* {
+{identifier} {
StringTokPtr ident = new StringTok;
ident->v = *yytext == '\\' ? yytext + 1 : yytext;
*yylvalp = ident;