[flang] Improve error message for "type already declared"
authorTim Keith <tkeith@nvidia.com>
Tue, 11 Sep 2018 14:26:54 +0000 (07:26 -0700)
committerTim Keith <tkeith@nvidia.com>
Tue, 11 Sep 2018 14:26:54 +0000 (07:26 -0700)
Add reference to the statement where the type was first set.

Original-commit: flang-compiler/f18@911c90e99ee43e4e221d0b5ffd8a76c82390c153
Reviewed-on: https://github.com/flang-compiler/f18/pull/179

flang/lib/semantics/resolve-names.cc

index 86f53ef..25f8976 100644 (file)
@@ -2286,10 +2286,12 @@ void DeclarationVisitor::SetType(
   if (!prevType) {
     symbol.SetType(type);
   } else if (!symbol.test(Symbol::Flag::Implicit)) {
-    Say(name, "The type of '%s' has already been declared"_err_en_US);
+    Say2(name, "The type of '%s' has already been declared"_err_en_US,
+        symbol.name(), "Declaration of '%s'"_en_US);
   } else if (type != *prevType) {
-    Say(name,
-        "The type of '%s' has already been implicitly declared"_err_en_US);
+    Say2(name,
+        "The type of '%s' has already been implicitly declared"_err_en_US,
+        symbol.name(), "Declaration of '%s'"_en_US);
   } else {
     symbol.set(Symbol::Flag::Implicit, false);
   }