From: Jason Merrill Date: Fri, 15 Jun 2018 20:22:55 +0000 (-0400) Subject: * decl.c (start_enum): Do compare dependent underlying type. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b4cf2e42b5d30bd38b05c16365ab8e5c98f7e12a;p=gcc.git * decl.c (start_enum): Do compare dependent underlying type. From-SVN: r261655 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f6c69087ce2..d8ce66eb22c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,7 @@ 2018-06-15 Jason Merrill + * decl.c (start_enum): Do compare dependent underlying type. + PR c++/82882 - ICE with lambda in template default argument. * lambda.c (record_null_lambda_scope): New. * pt.c (tsubst_lambda_expr): Use it. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 98dea9b766f..d7df01289db 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -14131,8 +14131,6 @@ start_enum (tree name, tree enumtype, tree underlying_type, enumtype = error_mark_node; } else if (underlying_type && ENUM_UNDERLYING_TYPE (enumtype) - && !dependent_type_p (underlying_type) - && !dependent_type_p (ENUM_UNDERLYING_TYPE (enumtype)) && !same_type_p (underlying_type, ENUM_UNDERLYING_TYPE (enumtype))) { @@ -14157,7 +14155,7 @@ start_enum (tree name, tree enumtype, tree underlying_type, /* enumtype may be an ENUMERAL_TYPE if this is a redefinition of an opaque enum, or an opaque enum of an already defined - enumeration (C++0x only). + enumeration (C++11). In any other case, it'll be NULL_TREE. */ if (!enumtype) { @@ -14166,14 +14164,9 @@ start_enum (tree name, tree enumtype, tree underlying_type, } prevtype = enumtype; - /* Do not push the decl more than once, unless we need to - compare underlying types at instantiation time */ + /* Do not push the decl more than once. */ if (!enumtype - || TREE_CODE (enumtype) != ENUMERAL_TYPE - || (underlying_type - && dependent_type_p (underlying_type)) - || (ENUM_UNDERLYING_TYPE (enumtype) - && dependent_type_p (ENUM_UNDERLYING_TYPE (enumtype)))) + || TREE_CODE (enumtype) != ENUMERAL_TYPE) { enumtype = cxx_make_type (ENUMERAL_TYPE); enumtype = pushtag (name, enumtype, /*tag_scope=*/ts_current); diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index ae225db3ba5..2bda0f11d1d 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -112,7 +112,7 @@ enum scope_kind { of an if or switch statement. */ sk_function_parms, /* The scope containing function parameters. */ sk_class, /* The scope containing the members of a class. */ - sk_scoped_enum, /* The scope containing the enumertors of a C++0x + sk_scoped_enum, /* The scope containing the enumerators of a C++11 scoped enumeration. */ sk_namespace, /* The scope containing the members of a namespace, including the global scope. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum10.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum10.C index 3c4c3de6d66..e5d8e49537c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/forw_enum10.C +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum10.C @@ -6,7 +6,7 @@ template struct S1 enum E : T; // { dg-message "previous definition" } enum E : int; // { dg-error "different underlying type" } }; -template struct S1; // { dg-message "required from here" } +template struct S1; template struct S2 { @@ -17,8 +17,8 @@ template struct S2; template struct S3 { - enum E : T1; - enum E : T2; + enum E : T1; // { dg-message "previous definition" } + enum E : T2; // { dg-error "different underlying type" } }; template struct S3; @@ -27,4 +27,4 @@ template struct S4 enum E : T1; // { dg-message "previous definition" } enum E : T2; // { dg-error "different underlying type" } }; -template struct S4; // { dg-message "required from here" } +template struct S4; diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum7.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum7.C index 3c67f547057..d43bbc1caf2 100644 --- a/gcc/testsuite/g++.dg/cpp0x/forw_enum7.C +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum7.C @@ -4,8 +4,6 @@ template struct S1 { enum E1 : int; - enum E1 : T; - enum class E2 : int; enum class E2 : T; }; diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum8.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum8.C index b84a759c6de..3f06cd4bd67 100644 --- a/gcc/testsuite/g++.dg/cpp0x/forw_enum8.C +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum8.C @@ -1,22 +1,19 @@ // { dg-do compile { target c++11 } } -//This instatiation is ok template struct S1 { - enum E : int; - enum E : T; + enum E : int; // { dg-message "previous definition" } + enum E : T; // { dg-error "different underlying type" } }; template struct S1; //ok -//This error is diagnosed at instantiation time template struct S2 { enum E : int; // { dg-message "previous definition" } enum E : T; // { dg-error "different underlying type" } }; -template struct S2; // { dg-message "required from here" } +template struct S2; -//This error is diagnosed at compilation time template struct S3 { enum E : int; // { dg-message "previous definition" }