aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/c-typeprint.c1
-rw-r--r--gdb/testsuite/gdb.cp/templates.cc14
-rw-r--r--gdb/testsuite/gdb.cp/templates.exp36
3 files changed, 51 insertions, 0 deletions
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 5f20233..a622824 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -119,6 +119,7 @@ c_print_type_1 (struct type *type,
code = type->code ();
if (local_name != NULL)
{
+ c_type_print_modifier (type, stream, 0, 1, language);
fputs_filtered (local_name, stream);
if (varstring != NULL && *varstring != '\0')
fputs_filtered (" ", stream);
diff --git a/gdb/testsuite/gdb.cp/templates.cc b/gdb/testsuite/gdb.cp/templates.cc
index d6120e2..d5b24af 100644
--- a/gdb/testsuite/gdb.cp/templates.cc
+++ b/gdb/testsuite/gdb.cp/templates.cc
@@ -690,6 +690,18 @@ int gf2 (int a) {
char string[3];
+// Template class with typedefs and const attributes.
+template<typename DataT>
+class Cfoo
+{
+ typedef float myfloat;
+public:
+ DataT me0;
+ const DataT me1=1;
+ const myfloat me2=2.0;
+ const int me3=0;
+};
+
// Template for nested instantiations
@@ -778,6 +790,8 @@ int main()
sic.spec ('c');
siip.spec (&x);
+ Cfoo<double> cfoo;
+
Garply<int> f;
Garply<char> fc;
f.x = 13;
diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp
index 8370beb..5f0538d 100644
--- a/gdb/testsuite/gdb.cp/templates.exp
+++ b/gdb/testsuite/gdb.cp/templates.exp
@@ -547,6 +547,42 @@ gdb_test_multiple "ptype/r siip" "ptype siip" {
}
}
+# Check cv qualifiers and substitute parameters.
+
+if {[test_compiler_info {clang-*}]} {
+ setup_kfail "llvm/52262 " "*-*-*"
+}
+gdb_test "ptype cfoo" [multi_line \
+"type = (class |)Cfoo<double> \\\[with DataT = double\\\] \\{" \
+ "\[ \t\]*public:" \
+ "\[ \t\]*DataT me0;" \
+ "\[ \t\]*const DataT me1;" \
+ "\[ \t\]*const myfloat me2;" \
+ "\[ \t\]*const int me3;" \
+ "" \
+ "\[ \t\]*private:" \
+ "\[ \t\]*typedef float myfloat;" \
+"\\}" \
+] "print type of cfoo"
+
+# Check cv qualifiers and do not substitute.
+
+if {[test_compiler_info {clang-*}]} {
+ setup_kfail "llvm/52262 " "*-*-*"
+}
+gdb_test "ptype/r cfoo" [multi_line \
+"type = (class |)Cfoo<double> \\{" \
+ "\[ \t\]*public:" \
+ "\[ \t\]*double me0;" \
+ "\[ \t\]*const double me1;" \
+ "\[ \t\]*const Cfoo<double>::myfloat me2;" \
+ "\[ \t\]*const int me3;" \
+ "" \
+ "\[ \t\]*private:" \
+ "\[ \t\]*typedef float myfloat;" \
+"\\}" \
+] "print raw type of cfoo"
+
# pt Garply<int>
gdb_test_multiple "ptype/r Garply<int>" "ptype Garply<int>" {