Skip to content

Commit 7302d53

Browse files
committed
issue #10989 Incorrect linking in C++ code
The call context stack has been extended with the bracket count and the appropriate place the barcket count is also saved and set to 0.
1 parent 14fc65f commit 7302d53

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/code.l

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
574574
}
575575
<Body,FuncCall>"{" {
576576
yyextra->theVarContext.pushScope();
577+
yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
578+
yyextra->bracketCount = 0;
577579
578580
DBG_CTX((stderr,"** scope stack push INNERBLOCK\n"));
579581
yyextra->scopeStack.push(INNERBLOCK);
@@ -594,6 +596,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
594596
}
595597
<Body,FuncCall,MemberCall,MemberCall2>"}" {
596598
yyextra->theVarContext.popScope();
599+
yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
597600
yyextra->type.clear();
598601
yyextra->name.clear();
599602
@@ -1064,7 +1067,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
10641067
}
10651068
<Body>"*"{B}*")" { // end of cast?
10661069
yyextra->code->codify(yytext);
1067-
yyextra->theCallContext.popScope(yyextra->name, yyextra->type);
1070+
yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
10681071
yyextra->bracketCount--;
10691072
yyextra->parmType = yyextra->name;
10701073
BEGIN(FuncCall);
@@ -1077,7 +1080,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
10771080
yyextra->name.clear();yyextra->type.clear();
10781081
if (*yytext==')')
10791082
{
1080-
yyextra->theCallContext.popScope(yyextra->name, yyextra->type);
1083+
yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
10811084
yyextra->bracketCount--;
10821085
if (yyextra->bracketCount<=0)
10831086
{
@@ -1469,7 +1472,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
14691472
}
14701473
else if (*yytext=='[')
14711474
{
1472-
yyextra->theCallContext.pushScope(yyextra->name, yyextra->type);
1475+
yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
14731476
}
14741477
yyextra->args.clear();
14751478
yyextra->parmType.clear();
@@ -1568,7 +1571,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
15681571
<ObjCCall,ObjCMName,ObjCSkipStr>\n { yyextra->currentCtx->format+=*yytext; }
15691572

15701573
<Body>"]" {
1571-
yyextra->theCallContext.popScope(yyextra->name, yyextra->type);
1574+
yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
15721575
yyextra->code->codify(yytext);
15731576
// TODO: nested arrays like: a[b[0]->func()]->func()
15741577
yyextra->name = yyextra->saveName;
@@ -1676,7 +1679,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
16761679
yyextra->parmType.clear();yyextra->parmName.clear();
16771680
yyextra->code->codify(yytext);
16781681
yyextra->bracketCount++;
1679-
yyextra->theCallContext.pushScope(yyextra->name, yyextra->type);
1682+
yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
16801683
if (YY_START==FuncCall && !yyextra->insideBody)
16811684
{
16821685
yyextra->theVarContext.pushScope();
@@ -1710,7 +1713,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
17101713
yyextra->parmName.clear();
17111714
addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
17121715
}
1713-
yyextra->theCallContext.popScope(yyextra->name, yyextra->type);
1716+
yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
17141717
yyextra->inForEachExpression = FALSE;
17151718
//yyextra->theCallContext.setClass(0); // commented out, otherwise a()->b() does not work for b().
17161719
yyextra->code->codify(yytext);
@@ -2255,12 +2258,12 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
22552258
<*>"("|"[" {
22562259
if (yytext[0]=='(') yyextra->bracketCount++;
22572260
yyextra->code->codify(yytext);
2258-
yyextra->theCallContext.pushScope(yyextra->name, yyextra->type);
2261+
yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
22592262
}
22602263
<*>")"|"]" {
22612264
if (yytext[0]==')') yyextra->bracketCount--;
22622265
yyextra->code->codify(yytext);
2263-
yyextra->theCallContext.popScope(yyextra->name, yyextra->type);
2266+
yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
22642267
}
22652268
<*>\n {
22662269
codifyLines(yyscanner,yytext);

src/scopedtypevariant.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ class CallContext
141141
public:
142142
struct Ctx
143143
{
144-
Ctx(const QCString &name_,const QCString &type_) : name(name_), type(type_) {}
144+
Ctx(const QCString &name_,const QCString &type_, int bracketCount_) : name(name_), type(type_), bracketCount(bracketCount_) {}
145145
QCString name;
146146
QCString type;
147+
int bracketCount;
147148
ScopedTypeVariant stv;
148149
};
149150

@@ -156,24 +157,25 @@ class CallContext
156157
Ctx &ctx = m_stvList.back();
157158
ctx.stv=stv;
158159
}
159-
void pushScope(const QCString &name_,const QCString &type_)
160+
void pushScope(const QCString &name_,const QCString &type_, int bracketCount_)
160161
{
161-
m_stvList.emplace_back(name_,type_);
162+
m_stvList.emplace_back(name_,type_,bracketCount_);
162163
}
163-
void popScope(QCString &name_,QCString &type_)
164+
void popScope(QCString &name_,QCString &type_, int &bracketCount_)
164165
{
165166
if (m_stvList.size()>1)
166167
{
167168
const Ctx &ctx = m_stvList.back();
168169
name_ = ctx.name;
169170
type_ = ctx.type;
171+
bracketCount_ = ctx.bracketCount;
170172
m_stvList.pop_back();
171173
}
172174
}
173175
void clear()
174176
{
175177
m_stvList.clear();
176-
m_stvList.emplace_back(QCString(),QCString());
178+
m_stvList.emplace_back(QCString(),QCString(),0);
177179
}
178180
const ScopedTypeVariant getScope() const
179181
{

0 commit comments

Comments
 (0)