Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/arduino.cc/builder/ctags/ctags_to_prototypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,32 @@ func (p *CTagsParser) findLineWhereToInsertPrototypes() int {
}

func (p *CTagsParser) firstFunctionPointerUsedAsArgument() int {
functionNames := p.collectFunctionNames()
functionTags := p.collectFunctions()
for _, tag := range p.tags {
if functionNameUsedAsFunctionPointerIn(tag, functionNames) {
if functionNameUsedAsFunctionPointerIn(tag, functionTags) {
return tag.Line
}
}
return -1
}

func functionNameUsedAsFunctionPointerIn(tag *types.CTag, functionNames []string) bool {
for _, functionName := range functionNames {
if strings.Index(tag.Code, "&"+functionName) != -1 {
func functionNameUsedAsFunctionPointerIn(tag *types.CTag, functionTags []*types.CTag) bool {
for _, functionTag := range functionTags {
if tag.Line != functionTag.Line && strings.Index(tag.Code, "&"+functionTag.FunctionName) != -1 {
return true
}
}
return false
}

func (p *CTagsParser) collectFunctionNames() []string {
names := []string{}
func (p *CTagsParser) collectFunctions() []*types.CTag {
functionTags := []*types.CTag{}
for _, tag := range p.tags {
if tag.Kind == KIND_FUNCTION {
names = append(names, tag.FunctionName)
functionTags = append(functionTags, tag)
}
}
return names
return functionTags
}

func (p *CTagsParser) firstFunctionAtLine() int {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
template< uint16_t nBuffSize >
class Foo{
public:

template< uint16_t N >
Foo &operator +=( const Foo<N> &ref ){
//...
return *this;
}
};

Foo<64> a;
Foo<32> b;

void setup(){
a += b;
}

void loop(){}
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ func TestTryBuild039(t *testing.T) {
tryBuildWithContext(t, ctx, "sketch12", "sketch12.ino")
}

func TestTryBuild040(t *testing.T) {
tryBuild(t, "sketch_with_fake_function_pointer", "sketch_with_fake_function_pointer.ino")
}

func makeDefaultContext(t *testing.T) *types.Context {
DownloadCoresAndToolsAndLibraries(t)

Expand Down