llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.04k stars 11.58k forks source link

MSVC compatibility hack thwarted by typo correction #20623

Open rnk opened 10 years ago

rnk commented 10 years ago
Bugzilla Link 20249
Version unspecified
OS Windows NT
CC @DougGregor,@zygoloid

Extended Description

Introducing typo correction candidates causes a warning with -fms-compatibility to become an error.

consider:

$ cat t.cpp
#ifdef BUG
namespace type_in_base_of_dependent_base {
struct A { typedef int NameFromBase; };
}
#endif

namespace function_template_deduction {
// Overloaded function templates.
template <int N> int f() { return N; }
template <typename T> int f() { return sizeof(T); }

// Dependent base class with enum.
template <typename T> struct A { enum { NameFromBase = 4 }; };
template <typename T> struct D : A<T> {
  // expected-warning@+1 {{use of undeclared identifier 'NameFromBase'; unqualified lookup into dependent bases}}
  int x = f<NameFromBase>();
};
}
$ clang -c t.cpp
t.cpp:16:13: warning: use of undeclared identifier 'NameFromBase'; unqualified lookup into dependent bases of class template 'D' is a Microsoft extension [-Wmicrosoft]
  int x = f<NameFromBase>();
            ^
            this->
1 warning generated.

$ clang -c t.cpp -DBUG
t.cpp:16:13: error: unknown type name 'NameFromBase'; did you mean 'type_in_base_of_dependent_base::A::NameFromBase'?
  int x = f<NameFromBase>();
            ^~~~~~~~~~~~
            type_in_base_of_dependent_base::A::NameFromBase
t.cpp:3:24: note: 'type_in_base_of_dependent_base::A::NameFromBase' declared here
struct A { typedef int NameFromBase; };
                       ^
1 error generated.
rnk commented 2 years ago

Still repros, godbolt link: https://gcc.godbolt.org/z/hezh9Trh3