Skip to content

clang12: Using as compiler generates 30K warnings of -Wcompound-token-split-by-macro #18780

Closed
@jkeenan

Description

Today I had occasion to try to build perl on FreeBSD-12 with, for the first time clang-12. Using this version of clang introduced over 30,000 new build-time warnings, all of type -Wcompound-token-split-by-macro.

$ uname -mrs
FreeBSD 12.2-STABLE amd64

$ ./perl -Ilib -V:config_args
config_args='-des -Dusedevel -Dusethreads -Dcc=clang12';

$ clang12 --version
clang version 12.0.0
Target: x86_64-portbld-freebsd12.2
Thread model: posix
InstalledDir: /usr/local/llvm12/bin

$ ~/bin/perl/report-build-warnings 1e43c13e1f.freebsd.clang12.maketp.output.txt.gz
File:  1e43c13e1f.freebsd.clang12.maketp.output.txt.gz

  Wcompound-token-split-by-macro           30106
  Wstring-compare                            2

$ zgrep "source =>" 1e43c13e1f.freebsd.clang12.parse.output.txt.gz | sort | uniq -c
  16     source => "../../../hv_func.h",
 144     source => "../../../inline.h",
 208     source => "../../../perl_siphash.h",
  96     source => "../../../sbox32_hash.h",
 272     source => "../../../zaphod32_hash.h",
 122     source => "../../hv_func.h",
1124     source => "../../inline.h",
1586     source => "../../perl_siphash.h",
 732     source => "../../sbox32_hash.h",
2074     source => "../../zaphod32_hash.h",
  36     source => "./const-c.inc",
  12     source => "./const-xs.inc",
  26     source => "./constants.xs",
  86     source => "./hv_func.h",
 774     source => "./inline.h",
  10     source => "./invlist_inline.h",
   6     source => "./numeric.xs",
1118     source => "./perl_siphash.h",
 516     source => "./sbox32_hash.h",
  16     source => "./vutil.c",
  32     source => "./vxs.inc",
1462     source => "./zaphod32_hash.h",
1180     source => "APItest.c",
 506     source => "APItest.xs",
 198     source => "B.c",
 140     source => "B.xs",
  20     source => "Base64.c",
   8     source => "Base64.xs",
  10     source => "Byte.c",
  90     source => "Bzip2.c",
  52     source => "Bzip2.xs",
  10     source => "CN.c",
  10     source => "Call.c",
  16     source => "Call.xs",
  14     source => "Collate.c",
  26     source => "Collate.xs",
  16     source => "Cwd.c",
  30     source => "Cwd.xs",
 170     source => "DB_File.c",
  60     source => "DB_File.xs",
   2     source => "DosGlob.c",
   2     source => "Dumper.c",
  62     source => "Dumper.xs",
  22     source => "DynaLoader.c",
  10     source => "EBCDIC.c",
  42     source => "Encode.c",
 120     source => "Encode.xs",
  20     source => "FastCalc.c",
  26     source => "FastCalc.xs",
  12     source => "Fcntl.xs",
  18     source => "FieldHash.c",
  14     source => "FieldHash.xs",
 132     source => "GDBM_File.c",
  32     source => "GDBM_File.xs",
  10     source => "Glob.c",
  24     source => "Glob.xs",
  84     source => "HiRes.c",
  18     source => "HiRes.xs",
   6     source => "Hostname.xs",
  46     source => "IO.c",
  20     source => "IO.xs",
  10     source => "JP.c",
  10     source => "KR.c",
   2     source => "Langinfo.c",
  66     source => "ListUtil.c",
 320     source => "ListUtil.xs",
   8     source => "MD5.c",
  24     source => "MD5.xs",
  64     source => "NDBM_File.c",
   2     source => "NDBM_File.xs",
  38     source => "Normalize.c",
  20     source => "Normalize.xs",
  24     source => "Opcode.c",
  22     source => "Opcode.xs",
 342     source => "POSIX.c",
  98     source => "POSIX.xs",
  28     source => "Peek.c",
   4     source => "Piece.c",
   4     source => "Piece.xs",
1036     source => "RealPPPort.c",
 696     source => "RealPPPort.xs",
  70     source => "SDBM_File.c",
   2     source => "SDBM_File.xs",
  38     source => "SHA.c",
  60     source => "SHA.xs",
  24     source => "Socket.c",
  46     source => "Socket.xs",
  26     source => "Storable.c",
2012     source => "Storable.xs",
  10     source => "Symbol.c",
  14     source => "SysV.c",
  96     source => "SysV.xs",
  48     source => "Syslog.c",
  10     source => "TW.c",
 264     source => "Typemap.c",
  42     source => "Typemap.xs",
   4     source => "Unicode.c",
  48     source => "Unicode.xs",
  20     source => "Util.c",
  86     source => "Util.xs",
   8     source => "XSUB-redefined-macros.xs",
   4     source => "XSUB-undef-XS_VERSION.xs",
 284     source => "Zlib.c",
  58     source => "Zlib.xs",
  20     source => "attributes.xs",
   8     source => "av.c",
   6     source => "caretx.c",
  62     source => "doio.c",
  42     source => "doop.c",
  42     source => "dump.c",
 134     source => "encoding.xs",
   6     source => "exception.c",
  64     source => "gv.c",
  34     source => "hv.c",
   8     source => "locale.c",
   2     source => "mathoms.c",
  98     source => "mg.c",
   6     source => "module3.c",
  52     source => "mro.xs",
   4     source => "mro_core.c",
  20     source => "numeric.c",
 592     source => "op.c",
  24     source => "pad.c",
 388     source => "perl.c",
  28     source => "perlio.c",
   6     source => "perly.c",
  12     source => "perly.y",
 834     source => "pp.c",
 252     source => "pp_ctl.c",
 366     source => "pp_hot.c",
 264     source => "pp_pack.c",
  30     source => "pp_sort.c",
 494     source => "pp_sys.c",
   2     source => "re.c",
  20     source => "re.xs",
2000     source => "re_comp.c",
 712     source => "re_exec.c",
  12     source => "reentr.c",
1476     source => "regcomp.c",
 266     source => "regexec.c",
   8     source => "scalar.xs",
   6     source => "scope.c",
  52     source => "shared.c",
 354     source => "shared.xs",
 760     source => "sv.c",
  42     source => "threads.c",
 190     source => "threads.xs",
  30     source => "time64.c",
 164     source => "toke.c",
 178     source => "universal.c",
  20     source => "utf8.c",
  58     source => "util.c",
  22     source => "via.xs",

The new warnings occur in pairs like this:

[
  {
    char   => 5,
    group  => "Wcompound-token-split-by-macro",
    line   => 150,
    source => "./zaphod32_hash.h",
    text   => "'(' and '{' tokens introducing statement expression appear in different macro expansion contexts",
  },
  {
    char   => 5,
    group  => "Wcompound-token-split-by-macro",
    line   => 150,
    source => "./zaphod32_hash.h",
    text   => "'}' and ')' tokens terminating statement expression appear in different macro expansion contexts",
  },

Or in the make output:

echo @`sh  cflags "optimize='-O2'" opmini.o`  -DPERL_IS_MINIPERL -DPERL_EXTERNAL_GLOB opmini.c
@clang12 -c -DPERL_CORE -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -std=c89 -O2 -Wall -Werror=pointer-arith -Wextra -Wc++-compat -Wwrite-strings -Werror=declaration-after-statement -DPERL_IS_MINIPERL -DPERL_EXTERNAL_GLOB opmini.c
In file included from op.c:163:
In file included from ./perl.h:4085:
In file included from ./hv.h:659:
In file included from ./hv_func.h:34:
In file included from ./sbox32_hash.h:4:
./zaphod32_hash.h:150:5: warning: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
    ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./zaphod32_hash.h:80:38: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
#define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START {  \
                                     ^~~~~~~~~~
./perl.h:737:29: note: expanded from macro 'STMT_START'
#   define STMT_START   (void)( /* gcc supports "({ STATEMENTS; })" */
                              ^
./zaphod32_hash.h:150:5: note: '{' token is here
    ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./zaphod32_hash.h:80:49: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
#define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START {  \
                                                ^
./zaphod32_hash.h:150:5: warning: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
    ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./zaphod32_hash.h:87:41: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
    v ^= (v>>23);                       \
                                        ^
./zaphod32_hash.h:150:5: note: ')' token is here
    ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./zaphod32_hash.h:88:3: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
} STMT_END
  ^~~~~~~~
./perl.h:738:21: note: expanded from macro 'STMT_END'
#   define STMT_END     )
                        ^

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    build-time-warningsReplaces [META] Build-time warnings RT #133556

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions