Skip to content
Snippets Groups Projects
  • Jakub Jelinek's avatar
    e4c0595e
    libcpp: Use constexpr for _cpp_trigraph_map initialization for C++14 · e4c0595e
    Jakub Jelinek authored
    The _cpp_trigraph_map initialization used to be done for C99+ using
    designated initializers, but can't be done that way for C++ because
    the designated initializer support in C++ as array designators are just
    an extension there and don't allow skipping anything nor going backwards.
    
    But, we can get the same effect using C++14 constexpr constructor.
    With the following patch we get rid of the runtime initialization
    and the array can be in .rodata.
    
    2024-10-07  Jakub Jelinek  <jakub@redhat.com>
    
    	* internal.h (_cpp_trigraph_map_s): New type for C++14 or later.
    	(_cpp_trigraph_map_d): New variable for C++14 or later.
    	(_cpp_trigraph_map): Define to _cpp_trigraph_map_d.map for C++14 or
    	later.
    	* init.cc (init_trigraph_map): Define to nothing for C++14 or later.
    	(TRIGRAPH_MAP, END, s): Define differently for C++14 or later.
    e4c0595e
    History
    libcpp: Use constexpr for _cpp_trigraph_map initialization for C++14
    Jakub Jelinek authored
    The _cpp_trigraph_map initialization used to be done for C99+ using
    designated initializers, but can't be done that way for C++ because
    the designated initializer support in C++ as array designators are just
    an extension there and don't allow skipping anything nor going backwards.
    
    But, we can get the same effect using C++14 constexpr constructor.
    With the following patch we get rid of the runtime initialization
    and the array can be in .rodata.
    
    2024-10-07  Jakub Jelinek  <jakub@redhat.com>
    
    	* internal.h (_cpp_trigraph_map_s): New type for C++14 or later.
    	(_cpp_trigraph_map_d): New variable for C++14 or later.
    	(_cpp_trigraph_map): Define to _cpp_trigraph_map_d.map for C++14 or
    	later.
    	* init.cc (init_trigraph_map): Define to nothing for C++14 or later.
    	(TRIGRAPH_MAP, END, s): Define differently for C++14 or later.