c++/24367: Infinite recursion of typedef substitution
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / local-static.exp
index 581efa396aa98d47cba1f62e0f0893cc97565883..fe0e2dc0f3a2b5e37d80a8cc7963b7a079a70b19 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2017 Free Software Foundation, Inc.
+# Copyright 2017-2019 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 
 standard_testfile .c
 
+# A few expected errors.
+set syntax_re "A syntax error in expression, near.*"
+set cannot_resolve_re "Cannot resolve method S::method to any overloaded instance"
+
+# Build an "Cannot resolve method ..." expected error string for
+# method METH.
+#
+proc cannot_resolve {meth} {
+    return "Cannot resolve method $meth to any overloaded instance"
+}
+
 # A list of scopes that have the static variables that we want to
 # print.  Each entry has, in order, the scope/function name, and the
-# prefix used by the static variables.  (The prefix exists to make it
-# easier to debug the test if something goes wrong.)
-
-     #SCOPE                            #PREFIX
+# prefix used by the static variables.  The prefix exists both to make
+# it easier to debug the test if something goes wrong, and, to make
+# sure that printing the static local of one method overload doesn't
+# find the variables of the wrong overload.
+#
+# While at it, we also try printing each scope without the static
+# local, to check that the parse copes with cv overloads without
+# quoting.  That's what the third and forth columns are for.  Note
+# that printing "func()" is different from "func(void)".  The former
+# is an inferior function call, while the latter is a reference to the
+# function.
+
+     #SCOPE                            #PREFIX         #PRINT-SCOPE-QUOTED
+                                                       #PRINT-SCOPE-UNQUOTED (opt)
 set cxx_scopes_list {
-    {"S::method()"                     "S_M"}
-    {"S::static_method()"              "S_SM"}
-    {"S::inline_method()"              "S_IM"}
-    {"S::static_inline_method()"       "S_SIM"}
-    {"S2<int>::method()"               "S2_M"}
-    {"S2<int>::static_method()"                "S2_SM"}
-    {"S2<int>::inline_method()"                "S2_IM"}
-    {"S2<int>::static_inline_method()" "S2_SIM"}
-    {"free_func()"                     "FF"}
-    {"free_inline_func()"              "FIF"}
+    {"S::method()"                     "S_M"           {= \\{void \\(S \\* const\\)\\} $hex <S::method\\(\\)>}
+                                                       {[cannot_resolve "S::method"]}}
+
+    {"S::method() const"               "S_M_C"         {= \\{void \\(const S \\* const\\)\\} $hex <S::method\\(\\) const>}
+                                                       $syntax_re}
+
+    {"S::method() volatile"            "S_M_V"         {= \\{void \\(volatile S \\* const\\)\\} $hex <S::method\\(\\) volatile>}
+                                                       $syntax_re}
+
+    {"S::method() const volatile"      "S_M_CV"        {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}
+                                                       $syntax_re}
+
+    {"S::method() volatile const"      "S_M_CV"        {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}
+                                                       $syntax_re}
+
+    {"S::method(void)"                 "S_M"           {= \\{void \\(S \\* const\\)\\} $hex <S::method\\(\\)>}}
+    {"S::method(void) const"           "S_M_C"         {= \\{void \\(const S \\* const\\)\\} $hex <S::method\\(\\) const>}}
+    {"S::method(void) volatile"                "S_M_V"         {= \\{void \\(volatile S \\* const\\)\\} $hex <S::method\\(\\) volatile>}}
+    {"S::method(void) const volatile"  "S_M_CV"        {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}}
+    {"S::method(void) volatile const"  "S_M_CV"        {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}}
+
+    {"S::static_method()"              "S_SM"          {= \\{void \\(void\\)\\} $hex <S::static_method\\(\\)>}
+                                                       "void"}
+
+    {"S::static_method(void)"          "S_SM"          {= \\{void \\(void\\)\\} $hex <S::static_method\\(\\)>}}
+
+    {"S::inline_method()"              "S_IM"          {= \\{void \\(S \\* const\\)\\} $hex <S::inline_method\\(\\)>}
+                                                       {[cannot_resolve "S::inline_method"]}}
+
+    {"S::inline_method(void)"          "S_IM"          {= \\{void \\(S \\* const\\)\\} $hex <S::inline_method\\(\\)>}}
+
+    {"S::static_inline_method()"       "S_SIM"         {= \\{void \\(void\\)\\} $hex <S::static_inline_method\\(\\)>}
+                                                       "void"}
+
+    {"S::static_inline_method(void)"   "S_SIM"         {= \\{void \\(void\\)\\} $hex <S::static_inline_method\\(\\)>}}
+
+    {"S2<int>::method()"               "S2_M"          {= \\{void \\(S2<int> \\* const\\)\\} $hex <S2<int>::method\\(\\)>}
+                                                       {[cannot_resolve "S2<int>::method"]}}
+
+    {"S2<int>::static_method()"                "S2_SM"         {= \\{void \\(void\\)\\} $hex <S2<int>::static_method\\(\\)>}
+                                                       "void"}
+
+    {"S2<int>::inline_method()"                "S2_IM"         {= \\{void \\(S2<int> \\* const\\)\\} $hex <S2<int>::inline_method\\(\\)>}
+                                                       {[cannot_resolve "S2<int>::inline_method"]}}
+
+    {"S2<int>::static_inline_method()" "S2_SIM"        {= \\{void \\(void\\)\\} $hex <S2<int>::static_inline_method\\(\\)>}
+                                                       "void"}
+
+    {"free_func"                       "FF"            {= \\{void \\(void\\)\\} $hex <free_func\\(\\)>}}
+
+    {"free_func()"                     "FF"            {= \\{void \\(void\\)\\} $hex <free_func\\(\\)>}
+                                                       "void"}
+
+    {"free_func(void)"                 "FF"            {= \\{void \\(void\\)\\} $hex <free_func\\(\\)>}}
+
+    {"free_inline_func()"              "FIF"           {= \\{void \\(void\\)\\} $hex <free_inline_func\\(\\)>}
+                                                       "void"}
+
+    {"free_inline_func(void)"          "FIF"           {= \\{void \\(void\\)\\} $hex <free_inline_func\\(\\)>}}
 }
 
 set c_scopes_list {
-    {"free_func"                       "FF"}
-    {"free_inline_func"                        "FIF"}
+    {"free_func"                       "FF"            {= \\{void \\(void\\)\\} $hex <free_func>}}
+    {"free_inline_func"                        "FIF"           {= \\{void \\(void\\)\\} $hex <free_inline_func>}}
 }
 
 # A list of all the static varibles defined in each scope.  The first
@@ -91,6 +161,29 @@ proc do_test {lang} {
        set scopes_list $cxx_scopes_list
     }
 
+    # Print each scope/function using these syntaxes:
+    #
+    #  "(gdb) p 'S::method() const'"    # quoted
+    #  "(gdb) p S::method() const"      # unquoted
+    #
+    foreach scope_line $scopes_list  {
+       set scope [lindex $scope_line 0]
+
+       set print_quoted_re [lindex $scope_line 2]
+       set print_quoted_re [uplevel 1 "subst -nobackslashes -nocommands \"$print_quoted_re\""]
+
+       set print_unquoted_re [lindex $scope_line 3]
+       set print_unquoted_re [uplevel 1 "subst -nobackslashes -nocommands \"$print_unquoted_re\""]
+
+       gdb_test "print '${scope}'" $print_quoted_re
+
+       if {$print_unquoted_re != ""} {
+           gdb_test "print ${scope}" $print_unquoted_re
+       } else {
+           gdb_test "print ${scope}" $print_quoted_re
+       }
+    }
+
     # Print each variable using these syntaxes:
     #
     #  'func()'::var
This page took 0.04397 seconds and 4 git commands to generate.