Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spatch struggles with literal concatenation #341

Open
mrc0mmand opened this issue Dec 28, 2023 · 0 comments
Open

spatch struggles with literal concatenation #341

mrc0mmand opened this issue Dec 28, 2023 · 0 comments

Comments

@mrc0mmand
Copy link

spatch throws a parse error when concatenating two or more string literals defined elswhere and assigning the result to a variable:

// main.c
#include <stdio.h>
#include "macro.h"

int main(void) {
    const char *digits = DIGITS DIGITS;

    puts(digits);

    return 0;
}
// macro.h
#pragma once

#define DIGITS "0123456789"
$ spatch.opt --recursive-includes --include-headers-for-types --verbose-includes --verbose-parsing --parse-c main.c
init_defs_builtins: /home/mrc0mmand/repos/coccinelle/standard.h

PARSING: main.c
failed on stdio.h
including ./macro.h
TYPEDEF: disable typedef cos special case: DIGITS
(ONCE) CPP-TYPEDEF: promoting:(1) DIGITS on line 5
ERROR-RECOV: found sync '}' at line 10
parsing pass2: try again
TYPEDEF:_handle_typedef=false. Not normal if don't come from exn
ERROR-RECOV: found sync '}' at line 10
parsing pass3: try again
ERROR-RECOV: found sync '}' at line 10
parse error 
 = File "main.c", line 5, column 25, charpos = 81
  around = 'DIGITS',
  whole content =     const char *digits = DIGITS DIGITS;
badcount: 8
bad: #include "macro.h"
bad: 
bad: int main(void) {
BAD:!!!!!     const char *digits = DIGITS DIGITS;
bad: 
bad:     puts(digits);
bad: 
bad:     return 0;
bad: }
-----------------------------------------------------------------------
maybe 10 most problematic tokens
-----------------------------------------------------------------------
DIGITS: present in 2 parsing errors
example: 
       
       int main(void) {
           const char *digits = DIGITS DIGITS;
       
digits: present in 1 parsing errors
example: 
       
       int main(void) {
           const char *digits = DIGITS DIGITS;
       
main: present in 1 parsing errors
example: 
       
       int main(void) {
           const char *digits = DIGITS DIGITS;
       
-----------------------------------------------------------------------
NB total files = 1; perfect = 0; pbs = 1; timeout = 0; =========> 0%
nb good = 1,  nb passed = 0 =========> 0.00% passed
nb good = 1,  nb bad = 8 =========> 11.11% good or passed
@JuliaLawall JuliaLawall changed the title spatch struggles with literal concantenation spatch struggles with literal concatenation Dec 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant