mirror of git://gcc.gnu.org/git/gcc.git
re PR c++/39681 (Compile error is not descriptive)
/cp 2012-05-17 Paolo Carlini <paolo.carlini@oracle.com> PR c++/39681 * parser.c (cp_parser_new_type_id): Early return error_mark_node if the cp_parser_type_specifier_seq call has type_specifier_seq.type error_mark_node; tidy. (cp_parser_new_expression): Always initialize nelts to NULL_TREE to avoid uninitialized warnings. (cp_parser_init_declarator, cp_parser_late_parse_one_default_arg): Call cp_parser_skip_to_end_of_statement if cp_parser_initializer returns error_mark_node. /testsuite 2012-05-17 Paolo Carlini <paolo.carlini@oracle.com> PR c++/39681 * g++.dg/parse/error48.C: New. * g++.dg/cpp0x/error8.C: Likewise. * g++.dg/ext/utf-cxx98.C: Adjust dg-error directive. * g++.dg/ext/utf-dflt2.C: Likewise. * g++.dg/ext/utf-gnuxx98.C: Likewise. * g++.dg/ext/utf-dflt.C: Likewise. * c-c++-common/raw-string-3.c: Likewise. * c-c++-common/raw-string-4.c: Likewise. From-SVN: r187634
This commit is contained in:
parent
8e6acdb8cd
commit
70ba90b226
|
@ -1,3 +1,15 @@
|
|||
2012-05-17 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/39681
|
||||
* parser.c (cp_parser_new_type_id): Early return error_mark_node
|
||||
if the cp_parser_type_specifier_seq call has type_specifier_seq.type
|
||||
error_mark_node; tidy.
|
||||
(cp_parser_new_expression): Always initialize nelts to NULL_TREE to
|
||||
avoid uninitialized warnings.
|
||||
(cp_parser_init_declarator, cp_parser_late_parse_one_default_arg):
|
||||
Call cp_parser_skip_to_end_of_statement if cp_parser_initializer
|
||||
returns error_mark_node.
|
||||
|
||||
2012-05-17 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/53371
|
||||
|
|
|
@ -6613,7 +6613,7 @@ cp_parser_new_expression (cp_parser* parser)
|
|||
VEC(tree,gc) *placement;
|
||||
tree type;
|
||||
VEC(tree,gc) *initializer;
|
||||
tree nelts;
|
||||
tree nelts = NULL_TREE;
|
||||
tree ret;
|
||||
|
||||
/* Look for the optional `::' operator. */
|
||||
|
@ -6666,7 +6666,6 @@ cp_parser_new_expression (cp_parser* parser)
|
|||
"try removing the parentheses around the type-id");
|
||||
cp_parser_direct_new_declarator (parser);
|
||||
}
|
||||
nelts = NULL_TREE;
|
||||
}
|
||||
/* Otherwise, there must be a new-type-id. */
|
||||
else
|
||||
|
@ -6736,7 +6735,6 @@ cp_parser_new_type_id (cp_parser* parser, tree *nelts)
|
|||
cp_declarator *declarator;
|
||||
cp_declarator *outer_declarator;
|
||||
const char *saved_message;
|
||||
tree type;
|
||||
|
||||
/* The type-specifier sequence must not contain type definitions.
|
||||
(It cannot contain declarations of new types either, but if they
|
||||
|
@ -6751,6 +6749,10 @@ cp_parser_new_type_id (cp_parser* parser, tree *nelts)
|
|||
&type_specifier_seq);
|
||||
/* Restore the old message. */
|
||||
parser->type_definition_forbidden_message = saved_message;
|
||||
|
||||
if (type_specifier_seq.type == error_mark_node)
|
||||
return error_mark_node;
|
||||
|
||||
/* Parse the new-declarator. */
|
||||
new_declarator = cp_parser_new_declarator_opt (parser);
|
||||
|
||||
|
@ -6787,8 +6789,7 @@ cp_parser_new_type_id (cp_parser* parser, tree *nelts)
|
|||
new_declarator = NULL;
|
||||
}
|
||||
|
||||
type = groktypename (&type_specifier_seq, new_declarator, false);
|
||||
return type;
|
||||
return groktypename (&type_specifier_seq, new_declarator, false);
|
||||
}
|
||||
|
||||
/* Parse an (optional) new-declarator.
|
||||
|
@ -15735,6 +15736,8 @@ cp_parser_init_declarator (cp_parser* parser,
|
|||
&is_non_constant_init);
|
||||
if (!member_p && processing_template_decl)
|
||||
finish_lambda_scope ();
|
||||
if (initializer == error_mark_node)
|
||||
cp_parser_skip_to_end_of_statement (parser);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21749,6 +21752,9 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl,
|
|||
|
||||
finish_lambda_scope ();
|
||||
|
||||
if (parsed_arg == error_mark_node)
|
||||
cp_parser_skip_to_end_of_statement (parser);
|
||||
|
||||
if (!processing_template_decl)
|
||||
{
|
||||
/* In a non-template class, check conversions now. In a template,
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
2012-05-17 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/39681
|
||||
* g++.dg/parse/error48.C: New.
|
||||
* g++.dg/cpp0x/error8.C: Likewise.
|
||||
* g++.dg/ext/utf-cxx98.C: Adjust dg-error directive.
|
||||
* g++.dg/ext/utf-dflt2.C: Likewise.
|
||||
* g++.dg/ext/utf-gnuxx98.C: Likewise.
|
||||
* g++.dg/ext/utf-dflt.C: Likewise.
|
||||
* c-c++-common/raw-string-3.c: Likewise.
|
||||
* c-c++-common/raw-string-4.c: Likewise.
|
||||
|
||||
2012-05-17 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/53371
|
||||
|
|
|
@ -5,26 +5,26 @@
|
|||
// { dg-options "-std=c++98" { target c++ } }
|
||||
|
||||
const void *s0 = R"(a)"; // { dg-error "was not declared|undeclared" }
|
||||
// { dg-error "expected ',' or ';'" "" { target *-*-* } 7 }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 7 }
|
||||
const void *s1 = uR"(a)"; // { dg-error "was not declared|undeclared" }
|
||||
// { dg-error "expected ',' or ';'" "" { target *-*-* } 9 }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 9 }
|
||||
const void *s2 = UR"(a)"; // { dg-error "was not declared|undeclared" }
|
||||
// { dg-error "expected ',' or ';'" "" { target *-*-* } 11 }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 11 }
|
||||
const void *s3 = u8R"(a)"; // { dg-error "was not declared|undeclared" }
|
||||
// { dg-error "expected ',' or ';'" "" { target *-*-* } 13 }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 13 }
|
||||
const void *s4 = LR"(a)"; // { dg-error "was not declared|undeclared" }
|
||||
// { dg-error "expected ',' or ';'" "" { target *-*-* } 15 }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 15 }
|
||||
|
||||
const int i0 = R'a'; // { dg-error "expected ',' or ';'" }
|
||||
// { dg-error "was not declared" "" { target c++ } 18 }
|
||||
const int i1 = uR'a'; // { dg-error "expected ',' or ';'" }
|
||||
// { dg-error "was not declared" "" { target c++ } 20 }
|
||||
const int i2 = UR'a'; // { dg-error "expected ',' or ';'" }
|
||||
// { dg-error "was not declared" "" { target c++ } 22 }
|
||||
const int i3 = u8R'a'; // { dg-error "expected ',' or ';'" }
|
||||
// { dg-error "was not declared" "" { target c++ } 24 }
|
||||
const int i4 = LR'a'; // { dg-error "expected ',' or ';'" }
|
||||
// { dg-error "was not declared" "" { target c++ } 26 }
|
||||
const int i0 = R'a'; // { dg-error "was not declared" "" { target c++ } }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 18 }
|
||||
const int i1 = uR'a'; // { dg-error "was not declared" "" { target c++ } }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 20 }
|
||||
const int i2 = UR'a'; // { dg-error "was not declared" "" { target c++ } }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 22 }
|
||||
const int i3 = u8R'a'; // { dg-error "was not declared" "" { target c++ } }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 24 }
|
||||
const int i4 = LR'a'; // { dg-error "was not declared" "" { target c++ } }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 26 }
|
||||
|
||||
#define R "a"
|
||||
#define uR "b"
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
// { dg-options "-std=c++0x" { target c++ } }
|
||||
|
||||
const int i0 = R'a'; // { dg-error "was not declared|undeclared" }
|
||||
// { dg-error "expected ',' or ';'" "" { target *-*-* } 6 }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 6 }
|
||||
const int i1 = uR'a'; // { dg-error "was not declared|undeclared" }
|
||||
// { dg-error "expected ',' or ';'" "" { target *-*-* } 8 }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 8 }
|
||||
const int i2 = UR'a'; // { dg-error "was not declared|undeclared" }
|
||||
// { dg-error "expected ',' or ';'" "" { target *-*-* } 10 }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 10 }
|
||||
const int i3 = u8R'a'; // { dg-error "was not declared|undeclared" }
|
||||
// { dg-error "expected ',' or ';'" "" { target *-*-* } 12 }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 12 }
|
||||
const int i4 = LR'a'; // { dg-error "was not declared|undeclared" }
|
||||
// { dg-error "expected ',' or ';'" "" { target *-*-* } 14 }
|
||||
// { dg-error "expected ',' or ';'" "" { target c } 14 }
|
||||
|
||||
#define R 1 +
|
||||
#define uR 2 +
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// PR c++/39681
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
struct A
|
||||
{
|
||||
int* p = new foo; // { dg-error "16:expected type-specifier" }
|
||||
};
|
|
@ -8,9 +8,7 @@ const static char16_t c0 = 'a'; /* { dg-error "not name a type" } */
|
|||
const static char32_t c1 = 'a'; /* { dg-error "not name a type" } */
|
||||
|
||||
const unsigned short c2 = u'a'; /* { dg-error "not declared" } */
|
||||
/* { dg-error "expected ',' or ';'" "" { target *-*-* } 10 } */
|
||||
const unsigned long c3 = U'a'; /* { dg-error "not declared" } */
|
||||
/* { dg-error "expected ',' or ';'" "" { target *-*-* } 12 } */
|
||||
|
||||
#define u 1 +
|
||||
#define U 2 +
|
||||
|
|
|
@ -8,9 +8,7 @@ const static char16_t c0 = 'a'; /* { dg-error "not name a type" } */
|
|||
const static char32_t c1 = 'a'; /* { dg-error "not name a type" } */
|
||||
|
||||
const unsigned short c2 = u'a'; /* { dg-error "not declared" } */
|
||||
/* { dg-error "expected ',' or ';'" "" { target *-*-* } 10 } */
|
||||
const unsigned long c3 = U'a'; /* { dg-error "not declared" } */
|
||||
/* { dg-error "expected ',' or ';'" "" { target *-*-* } 12 } */
|
||||
|
||||
#define u 1 +
|
||||
#define U 2 +
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// { dg-options "-std=c++98" }
|
||||
|
||||
const void *s0 = u8"a"; // { dg-error "was not declared" }
|
||||
// { dg-error "expected ',' or ';'" "" { target *-*-* } 5 }
|
||||
|
||||
#define u8 "a"
|
||||
|
||||
|
|
|
@ -8,9 +8,7 @@ const static char16_t c0 = 'a'; /* { dg-error "not name a type" } */
|
|||
const static char32_t c1 = 'a'; /* { dg-error "not name a type" } */
|
||||
|
||||
const unsigned short c2 = u'a'; /* { dg-error "not declared" } */
|
||||
/* { dg-error "expected ',' or ';'" "" { target *-*-* } 10 } */
|
||||
const unsigned long c3 = U'a'; /* { dg-error "not declared" } */
|
||||
/* { dg-error "expected ',' or ';'" "" { target *-*-* } 12 } */
|
||||
|
||||
#define u 1 +
|
||||
#define U 2 +
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// PR c++/39681
|
||||
|
||||
int main()
|
||||
{
|
||||
int* p = new foo; // { dg-error "16:expected type-specifier" }
|
||||
}
|
Loading…
Reference in New Issue