https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91360

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Wed Aug 28 20:31:31 2019
New Revision: 275008

URL: https://gcc.gnu.org/viewcvs?rev=275008&root=gcc&view=rev
Log:
        PR c++/91360 - Implement C++20 P1143R2: constinit.
        * c-common.c (c_common_reswords): Add constinit and __constinit.
        (keyword_is_decl_specifier): Handle RID_CONSTINIT.
        * c-common.h (enum rid): Add RID_CONSTINIT, RID_FIRST_CXX20, and
        RID_LAST_CXX20.
        (D_CXX20): Define.
        * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_constinit.
        * c-format.c (cxx_keywords): Add "constinit".
        * c.opt (Wc++2a-compat, Wc++20-compat): New options.

        * cp-tree.h (TINFO_VAR_DECLARED_CONSTINIT): Define.
        (LOOKUP_CONSTINIT): Define.
        (enum cp_decl_spec): Add ds_constinit.
        * decl.c (check_tag_decl): Give an error for constinit in type
        declarations.
        (check_initializer): Also check LOOKUP_CONSTINIT.
        (cp_finish_decl): Add checking for a constinit declaration.  Set
        TINFO_VAR_DECLARED_CONSTINIT.
        (grokdeclarator): Add checking for a declaration with the constinit
        specifier.
        * lex.c (init_reswords): Handle D_CXX20.
        * parser.c (cp_lexer_get_preprocessor_token): Pass a better location
        to warning_at.  Warn about C++20 keywords.
        (cp_keyword_starts_decl_specifier_p): Handle RID_CONSTINIT.
        (cp_parser_diagnose_invalid_type_name): Add an inform about constinit.
        (cp_parser_decomposition_declaration): Maybe pass LOOKUP_CONSTINIT to
        cp_finish_decl.
        (cp_parser_decl_specifier_seq): Handle RID_CONSTINIT.
        (cp_parser_init_declarator): Maybe pass LOOKUP_CONSTINIT to
        cp_finish_decl.
        (set_and_check_decl_spec_loc): Add "constinit".
        * pt.c (tsubst_decl): Set TINFO_VAR_DECLARED_CONSTINIT.
        (instantiate_decl): Maybe pass LOOKUP_CONSTINIT to cp_finish_decl.
        * typeck2.c (store_init_value): If a constinit variable wasn't
        initialized using a constant initializer, give an error.

        * doc/invoke.texi: Document -Wc++20-compat.

        * g++.dg/cpp2a/constinit1.C: New test.
        * g++.dg/cpp2a/constinit2.C: New test.
        * g++.dg/cpp2a/constinit3.C: New test.
        * g++.dg/cpp2a/constinit4.C: New test.
        * g++.dg/cpp2a/constinit5.C: New test.
        * g++.dg/cpp2a/constinit6.C: New test.
        * g++.dg/cpp2a/constinit7.C: New test.
        * g++.dg/cpp2a/constinit8.C: New test.
        * g++.dg/cpp2a/constinit9.C: New test.
        * g++.dg/cpp2a/constinit10.C: New test.
        * g++.dg/cpp2a/constinit11.C: New test.
        * g++.dg/cpp2a/constinit12.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit1.C
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit10.C
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit11.C
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit12.C
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit2.C
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit3.C
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit4.C
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit5.C
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit6.C
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit7.C
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit8.C
    trunk/gcc/testsuite/g++.dg/cpp2a/constinit9.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/c-family/c-common.h
    trunk/gcc/c-family/c-cppbuiltin.c
    trunk/gcc/c-family/c-format.c
    trunk/gcc/c-family/c.opt
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/lex.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog

Reply via email to