[llvm-dev] Naming clash: -DCLS=n and CLS in code

U.Mutlu via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 19 10:22:24 PDT 2018


While building llvm & clang & libs by giving some optimization options
to the building compiler, the following error happened:

I think it is related to the passed -DCLS=64, because in file
clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6411 an enum member
has the same name (CLS), so it does a macro-substitution with the passed value 
of CLS, ie. with 64, but which of course then breakes the syntax...

I think such "reserved" names like CLS that can be passed to the compiler(s), 
should be avoided as identifiers for naming variables, constants, enum 
members, macros etc.


[2845/3381] Building CXX object 
tools/clang/lib/Tooling/CMakeFiles/clangTooling.dir/Execution.cpp.o
FAILED: /usr/local/gcc-latest/bin/g++-latest  -DEXPENSIVE_CHECKS -D_DEBUG 
-D_GLIBCXX_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools/clang/lib/Frontend/Rewrite 
-I/sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite 
-I/sw/src/clang_llvm_dev/clang/include -Itools/clang/include -Iinclude 
-I/sw/src/clang_llvm_dev/llvm_trunk/include -fopt-info -pipe -Wall -Wextra 
-Ofast                -DCLS=64 -fPIC -floop-nest-optimize --param 
simultaneous-prefetches=16 -fprefetch-loop-arrays -msse4.2       -mrecip=all 
          -funroll-loops -fdelete-null-pointer-checks --param 
prefetch-latency=32 -ffast-math -ftree-vectorize -funsafe-math-optimizations 
-Wno-error=unused-parameter -Wno-error=type-limits -fPIC 
-fvisibility-inlines-hidden -Werror=date-time -std=c++1y -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -Wno-maybe-uninitialized 
-Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections 
-fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing 
-pedantic -Wno-long-long -O3    -UNDEBUG -MD -MT 
tools/clang/lib/Frontend/Rewrite/CMakeFiles/clangRewriteFrontend.dir/RewriteModernObjC.cpp.o 
-MF 
tools/clang/lib/Frontend/Rewrite/CMakeFiles/clangRewriteFrontend.dir/RewriteModernObjC.cpp.o.d 
-o 
tools/clang/lib/Frontend/Rewrite/CMakeFiles/clangRewriteFrontend.dir/RewriteModernObjC.cpp.o 
-c /sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
<command-line>: error: expected identifier before numeric constant
/sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6411:3: note: 
in expansion of macro 'CLS'
    CLS = 0x0,
    ^~~
<command-line>: error: expected '}' before numeric constant
/sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6411:3: note: 
in expansion of macro 'CLS'
    CLS = 0x0,
    ^~~
/sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6410:20: 
note: to match this '{'
  enum MetaDataDlags {
                     ^
<command-line>: error: expected unqualified-id before numeric constant
/sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6411:3: note: 
in expansion of macro 'CLS'
    CLS = 0x0,
    ^~~
/sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6421:1: error: 
expected declaration before '}' token
  };
  ^
In file included from 
/sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/STLExtras.h:21,
                  from 
/sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/StringRef.h:13,
                  from 
/sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/StringMap.h:17,
                  from 
/sw/src/clang_llvm_dev/llvm_trunk/include/llvm/Support/Host.h:17,
                  from 
/sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/Hashing.h:49,
                  from 
/sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/ArrayRef.h:13,
                  from 
/sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/APFloat.h:21,
                  from 
/sw/src/clang_llvm_dev/clang/include/clang/AST/APValue.h:18,
                  from /sw/src/clang_llvm_dev/clang/include/clang/AST/Decl.h:17,
                  from 
/sw/src/clang_llvm_dev/clang/include/clang/AST/ASTTypeTraits.h:20,
                  from 
/sw/src/clang_llvm_dev/clang/include/clang/AST/ASTContext.h:18,
                  from /sw/src/clang_llvm_dev/clang/include/clang/AST/AST.h:18,
                  from 
/sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:15:
...


More information about the llvm-dev mailing list