aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2012-06-13 16:10:10 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2012-06-13 16:10:10 +0000
commit50af5481d5feece564c8b03bfb4a647dc7573f3c (patch)
tree6d434da197be7f970b21ecc8f8f4afc417571b76 /gdb/c-exp.y
parentd55637df6923689396e58c3d789e82314f4826ec (diff)
downloadgdb-50af5481d5feece564c8b03bfb4a647dc7573f3c.zip
gdb-50af5481d5feece564c8b03bfb4a647dc7573f3c.tar.gz
gdb-50af5481d5feece564c8b03bfb4a647dc7573f3c.tar.bz2
gdb/
PR c++/14177 - Fix parsing TYPENAME:: in parentheses. * c-exp.y (classify_inner_name): Remove caller assumptions in the function comment. Return ERROR for unresolved cases. Implement returning proper NAME. (yylex): Accept also NAME from classify_inner_name. * cp-namespace.c (cp_lookup_nested_type): Rename to ... (cp_lookup_nested_symbol): ... here. Return any found symbol, not just LOC_TYPEDEF type. * cp-support.h (cp_lookup_nested_type): Update its declaration. gdb/testsuite/ PR c++/14177 - Fix parsing TYPENAME:: in parentheses. * gdb.cp/cpexprs.cc (class CV, CV::i, ATTRIBUTE_USED, CV_f): New. (test_function): Call CV_f. * gdb.cp/cpexprs.exp (p 'CV::m(int)', p CV::m(int)) (p 'CV::m(int) const', p CV::m(int) const, p 'CV::m(int) volatile') (p CV::m(int) volatile, p 'CV::m(int) const volatile') (p CV::m(int) const volatile, p CV_f(int), p CV_f(CV::t)) (p CV_f(CV::i)): New tests.
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y33
1 files changed, 21 insertions, 12 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index e912657..1e14337 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -2505,9 +2505,8 @@ classify_name (struct block *block)
/* Like classify_name, but used by the inner loop of the lexer, when a
name might have already been seen. FIRST_NAME is true if the token
- in `yylval' is the first component of a name, false otherwise. If
- this function returns NAME, it might not have updated `yylval'.
- This is ok because the caller only cares about TYPENAME. */
+ in `yylval' is the first component of a name, false otherwise. */
+
static int
classify_inner_name (struct block *block, int first_name)
{
@@ -2521,18 +2520,28 @@ classify_inner_name (struct block *block, int first_name)
if (TYPE_CODE (type) != TYPE_CODE_STRUCT
&& TYPE_CODE (type) != TYPE_CODE_UNION
&& TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
- /* We know the caller won't expect us to update yylval. */
- return NAME;
+ return ERROR;
copy = copy_name (yylval.tsym.stoken);
- new_type = cp_lookup_nested_type (yylval.tsym.type, copy, block);
+ yylval.ssym.sym = cp_lookup_nested_symbol (yylval.tsym.type, copy, block);
+ if (yylval.ssym.sym == NULL)
+ return ERROR;
+
+ switch (SYMBOL_CLASS (yylval.ssym.sym))
+ {
+ case LOC_BLOCK:
+ case LOC_LABEL:
+ return ERROR;
- if (new_type == NULL)
- /* We know the caller won't expect us to update yylval. */
- return NAME;
+ case LOC_TYPEDEF:
+ yylval.tsym.type = SYMBOL_TYPE (yylval.ssym.sym);;
+ return TYPENAME;
- yylval.tsym.type = new_type;
- return TYPENAME;
+ default:
+ yylval.ssym.is_a_field_of_this = 0;
+ return NAME;
+ }
+ internal_error (__FILE__, __LINE__, _("not reached"));
}
/* The outer level of a two-level lexer. This calls the inner lexer
@@ -2592,7 +2601,7 @@ yylex (void)
first_iter);
/* We keep going until we either run out of names, or until
we have a qualified name which is not a type. */
- if (classification != TYPENAME)
+ if (classification != TYPENAME && classification != NAME)
{
/* Push the final component and leave the loop. */
VEC_safe_push (token_and_value, token_fifo, &next);