public inbox for cocci@systeme.lip6.fr
 help / color / mirror / Atom feed
* [cocci] c++ scope resolution operator
@ 2026-03-08 21:40 Sam Tygier
  2026-03-08 21:43 ` Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: Sam Tygier @ 2026-03-08 21:40 UTC (permalink / raw)
  To: cocci

Hi,

I am having trouble using Coccinelle with C++ around scope operators, 
e.g. std::cout.

For example this works as expected (replaces the string):

hello.cpp:

#include <iostream>
using namespace std;
int main(){
     cout << "hello";
     return 0;
}

hello.cocci:

@@
@@
- cout << "hello";
+ cout << "hello sam";

But the actual I want to work on uses explicit namespace scopes

hello.cpp

#include <iostream>
int main(){
     std::cout << "hello";
     return 1;
}

hello.cocci

@@
@@
- std::cout << "hello";
+ std::cout << "hello sam";

gives an error:

$ spatch --sp-file hello.cocci hello.cpp --c++=17 --debug
init_defs_builtins: /usr/lib64/coccinelle/standard.h
-----------------------------------------------------------------------
processing semantic patch file: hello3.cocci
with isos from: /usr/lib64/coccinelle/standard.iso
-----------------------------------------------------------------------
@@
@@
- std::cout << "hello";
+ std::cout << "hello sam";

minus: parse error:
   File "hello.cocci", line 3, column 6, charpos = 12
   around = ':',
   whole content = - std::cout << "hello";

I am using coccinelle from the Fedora package 1.3-3.fc42

$ spatch --version
spatch version 1.3 compiled with OCaml version 5.3.0


Thanks,
Sam




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [cocci] c++ scope resolution operator
  2026-03-08 21:40 [cocci] c++ scope resolution operator Sam Tygier
@ 2026-03-08 21:43 ` Julia Lawall
  2026-03-08 22:12   ` Sam Tygier
  0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2026-03-08 21:43 UTC (permalink / raw)
  To: Sam Tygier; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 1482 bytes --]



On Sun, 8 Mar 2026, Sam Tygier wrote:

> Hi,
>
> I am having trouble using Coccinelle with C++ around scope operators, e.g.
> std::cout.

Sorry, but the support for :: is still work in progress.

julia

>
> For example this works as expected (replaces the string):
>
> hello.cpp:
>
> #include <iostream>
> using namespace std;
> int main(){
>     cout << "hello";
>     return 0;
> }
>
> hello.cocci:
>
> @@
> @@
> - cout << "hello";
> + cout << "hello sam";
>
> But the actual I want to work on uses explicit namespace scopes
>
> hello.cpp
>
> #include <iostream>
> int main(){
>     std::cout << "hello";
>     return 1;
> }
>
> hello.cocci
>
> @@
> @@
> - std::cout << "hello";
> + std::cout << "hello sam";
>
> gives an error:
>
> $ spatch --sp-file hello.cocci hello.cpp --c++=17 --debug
> init_defs_builtins: /usr/lib64/coccinelle/standard.h
> -----------------------------------------------------------------------
> processing semantic patch file: hello3.cocci
> with isos from: /usr/lib64/coccinelle/standard.iso
> -----------------------------------------------------------------------
> @@
> @@
> - std::cout << "hello";
> + std::cout << "hello sam";
>
> minus: parse error:
>   File "hello.cocci", line 3, column 6, charpos = 12
>   around = ':',
>   whole content = - std::cout << "hello";
>
> I am using coccinelle from the Fedora package 1.3-3.fc42
>
> $ spatch --version
> spatch version 1.3 compiled with OCaml version 5.3.0
>
>
> Thanks,
> Sam
>
>
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [cocci] c++ scope resolution operator
  2026-03-08 21:43 ` Julia Lawall
@ 2026-03-08 22:12   ` Sam Tygier
  2026-03-09  6:05     ` [cocci] Support for C++ scope resolution operator? Markus Elfring
  2026-03-09  6:52     ` [cocci] c++ scope resolution operator Julia Lawall
  0 siblings, 2 replies; 5+ messages in thread
From: Sam Tygier @ 2026-03-08 22:12 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]


On 08/03/2026 21:43, Julia Lawall wrote:
> On Sun, 8 Mar 2026, Sam Tygier wrote:
>> Hi,
>>
>> I am having trouble using Coccinelle with C++ around scope operators, e.g.
>> std::cout.
> Sorry, but the support for :: is still work in progress.
>
> julia

Thanks, I'll keep an eye out for updates. Is there a github issue for 
this that I could subscribe to?

Sam

[-- Attachment #2: Type: text/html, Size: 925 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [cocci] Support for C++ scope resolution operator?
  2026-03-08 22:12   ` Sam Tygier
@ 2026-03-09  6:05     ` Markus Elfring
  2026-03-09  6:52     ` [cocci] c++ scope resolution operator Julia Lawall
  1 sibling, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2026-03-09  6:05 UTC (permalink / raw)
  To: Sam Tygier; +Cc: cocci

> Thanks, I'll keep an eye out for updates. Is there a github issue for this that I could subscribe to?

Not directly for the mentioned functionality so far.

See also:
* Support C++ codebases
  2010-12-05
  https://github.com/coccinelle/coccinelle/issues/1

* C++
  2021-04-15
  https://gitlab.inria.fr/coccinelle/coccinelle/-/issues/22


Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [cocci] c++ scope resolution operator
  2026-03-08 22:12   ` Sam Tygier
  2026-03-09  6:05     ` [cocci] Support for C++ scope resolution operator? Markus Elfring
@ 2026-03-09  6:52     ` Julia Lawall
  1 sibling, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2026-03-09  6:52 UTC (permalink / raw)
  To: Sam Tygier; +Cc: cocci



On Sun, 8 Mar 2026, Sam Tygier wrote:

>
>
> On 08/03/2026 21:43, Julia Lawall wrote:
>
> On Sun, 8 Mar 2026, Sam Tygier wrote:
>
> Hi,
>
> I am having trouble using Coccinelle with C++ around scope operators, e.g.
> std::cout.
>
> Sorry, but the support for :: is still work in progress.
>
> julia
>
> Thanks, I'll keep an eye out for updates. Is there a github issue for this that I could subscribe to?

No, it's part of an ongoing attempt to support c++.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-09  6:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-08 21:40 [cocci] c++ scope resolution operator Sam Tygier
2026-03-08 21:43 ` Julia Lawall
2026-03-08 22:12   ` Sam Tygier
2026-03-09  6:05     ` [cocci] Support for C++ scope resolution operator? Markus Elfring
2026-03-09  6:52     ` [cocci] c++ scope resolution operator Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox