aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2017-06-29 14:16:58 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2017-06-29 14:16:58 +0000
commit9a82bd058df19d15cfbd0c16a09a6ba0c5c5cfa7 (patch)
treeb6351836edf02325031150335d10b7d01f3906a8
parente98889226cc487b39334ae069422c0ac4615f9ec (diff)
downloadgcc-9a82bd058df19d15cfbd0c16a09a6ba0c5c5cfa7.zip
gcc-9a82bd058df19d15cfbd0c16a09a6ba0c5c5cfa7.tar.gz
gcc-9a82bd058df19d15cfbd0c16a09a6ba0c5c5cfa7.tar.bz2
parser.c (cp_parser_direct_declarator): Reorder if to avoid indentation.
* parser.c (cp_parser_direct_declarator): Reorder if to avoid indentation. Remove unnecessary assignment of constructor name. From-SVN: r249787
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/parser.c45
2 files changed, 22 insertions, 26 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c29dd16..ece47f9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2017-06-29 Nathan Sidwell <nathan@acm.org>
+ * parser.c (cp_parser_direct_declarator): Reorder if to avoid
+ indentation. Remove unnecessary assignment of constructor name.
+
Whitespace cleanups.
* call.c (name_as_c_string): Move CONST_CAST to return.
(build_new_method_call_1): Remove unneeded bracing.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index bd99c05..31840d6 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -20106,26 +20106,8 @@ cp_parser_direct_declarator (cp_parser* parser,
if (TREE_CODE (unqualified_name) == TYPE_DECL)
{
tree name_type = TREE_TYPE (unqualified_name);
- if (class_type && same_type_p (name_type, class_type))
- {
- if (qualifying_scope
- && CLASSTYPE_USE_TEMPLATE (name_type))
- {
- error_at (declarator_id_start_token->location,
- "invalid use of constructor as a template");
- inform (declarator_id_start_token->location,
- "use %<%T::%D%> instead of %<%T::%D%> to "
- "name the constructor in a qualified name",
- class_type,
- DECL_NAME (TYPE_TI_TEMPLATE (class_type)),
- class_type, name_type);
- declarator = cp_error_declarator;
- break;
- }
- else
- unqualified_name = constructor_name (class_type);
- }
- else
+
+ if (!class_type || !same_type_p (name_type, class_type))
{
/* We do not attempt to print the declarator
here because we do not have enough
@@ -20135,6 +20117,21 @@ cp_parser_direct_declarator (cp_parser* parser,
declarator = cp_error_declarator;
break;
}
+ else if (qualifying_scope
+ && CLASSTYPE_USE_TEMPLATE (name_type))
+ {
+ error_at (declarator_id_start_token->location,
+ "invalid use of constructor as a template");
+ inform (declarator_id_start_token->location,
+ "use %<%T::%D%> instead of %<%T::%D%> to "
+ "name the constructor in a qualified name",
+ class_type,
+ DECL_NAME (TYPE_TI_TEMPLATE (class_type)),
+ class_type, name_type);
+ declarator = cp_error_declarator;
+ break;
+ }
+ unqualified_name = constructor_name (class_type);
}
if (class_type)
@@ -20164,14 +20161,10 @@ cp_parser_direct_declarator (cp_parser* parser,
struct S {
friend void N::S();
}; */
- && !(friend_p
- && class_type != qualifying_scope)
+ && (!friend_p || class_type == qualifying_scope)
&& constructor_name_p (unqualified_name,
class_type))
- {
- unqualified_name = constructor_name (class_type);
- sfk = sfk_constructor;
- }
+ sfk = sfk_constructor;
else if (is_overloaded_fn (unqualified_name)
&& DECL_CONSTRUCTOR_P (get_first_fn
(unqualified_name)))