Skip to content
  1. Feb 01, 2019
    • Brian Gesiak's avatar
      [SemaCXX] Param diagnostic matches overload logic · 3aba9fd6
      Brian Gesiak authored
      Summary:
      Given the following test program:
      
      ```
      class C {
      public:
        int A(int a, int& b);
      };
      
      int C::A(const int a, int b) {
        return a * b;
      }
      ```
      
      Clang would produce an error message that correctly diagnosed the
      redeclaration of `C::A` to not match the original declaration (the
      parameters to the two declarations do not match -- the original takes an
      `int &` as its 2nd parameter, but the redeclaration takes an `int`). However,
      it also produced a note diagnostic that inaccurately pointed to the
      first parameter, claiming that `const int` in the redeclaration did not
      match the unqualified `int` in the original. The diagnostic is
      misleading because it has nothing to do with why the program does not
      compile.
      
      The logic for checking for a function overload, in
      `Sema::FunctionParamTypesAreEqual`, discards cv-qualifiers before
      checking whether the types are equal. Do the same when producing the
      overload diagnostic.
      
      Reviewers: rsmith
      
      Reviewed By: rsmith
      
      Subscribers: cpplearner, cfe-commits
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D57032
      
      llvm-svn: 352831
      3aba9fd6
  2. Jun 16, 2016
  3. Sep 20, 2013
    • Richard Smith's avatar
      Switch the semantic DeclContext for a block-scope declaration of a function or · 541b38be
      Richard Smith authored
      variable from being the function to being the enclosing namespace scope (in
      C++) or the TU (in C). This allows us to fix a selection of related issues
      where we would build incorrect redeclaration chains for such declarations, and
      fail to notice type mismatches.
      
      Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern,
      which is only found when searching scopes, and not found when searching
      DeclContexts. Such a declaration is only made visible in its DeclContext if
      there are no non-LocalExtern declarations.
      
      llvm-svn: 191064
      541b38be
  4. Aug 13, 2013
    • Richard Smith's avatar
      Fix implementation of C11 6.2.7/4 and C++11 [dcl.array]p3: · 1c34fb78
      Richard Smith authored
      When a local extern declaration redeclares some other entity, the type of that
      entity is merged with the prior type if the prior declaration is visible (in C)
      or is declared in the same scope (in C++).
      
       - Make LookupRedeclarationWithLinkage actually work in C++, use it in the right
         set of cases, and make it track whether it found a shadowed declaration.
       - Track whether we found a declaration in the same scope (for C++) including
         across serialization and template instantiation.
      
      llvm-svn: 188307
      1c34fb78
  5. Mar 12, 2013
    • Rafael Espindola's avatar
      Move the extern "C" sema tests to a new file. · f67ef798
      Rafael Espindola authored
      llvm-svn: 176888
      f67ef798
    • Rafael Espindola's avatar
      We already reported an error for · cfd2528a
      Rafael Espindola authored
      extern "C" {
        void test5_f() {
          extern int test5_b;
        }
      }
      static float test5_b;
      
      This patch makes us report one for
      
      extern "C" {
        void test6_f() {
          extern int test6_b;
        }
      }
      extern "C" {
        static float test6_b;
      }
      
      Not because we think the declaration would be extern C, but because of the rule:
      
      An entity with C language linkage shall not be declared with the same name as an entity in global scope...
      
      We were just not looking past the extern "C" to see if the decl was in global
      scope.
      
      llvm-svn: 176875
      cfd2528a
    • Rafael Espindola's avatar
      Error if an extern C declaration matches a previous hidden extern C declaration. · 15770b2f
      Rafael Espindola authored
      Without this patch we produce an error for
      
      extern "C" {
        void f() {
          extern int b;
        }
      }
      extern "C" {
        extern float b;
      }
      
      but not for
      
      extern "C" {
        void f() {
          extern int b;
        }
      }
      extern "C" {
        float b;
      }
      
      llvm-svn: 176867
      15770b2f
  6. Jan 11, 2013
  7. Jun 08, 2012
  8. Apr 03, 2012
  9. Oct 11, 2011
  10. Oct 10, 2011
  11. Sep 14, 2011
  12. Aug 23, 2011
    • Matt Beaumont-Gay's avatar
      Fix an incorrect note. · 56381b85
      Matt Beaumont-Gay authored
      For the test case added to function-redecl.cpp, we were previously complaining
      about a mismatch in the parameter types, since the definition used the
      typedef'd type.
      
      llvm-svn: 138318
      56381b85
  13. Aug 18, 2011
  14. Dec 15, 2009
  15. Mar 24, 2009
  16. Feb 24, 2009
    • Douglas Gregor's avatar
      Improve merging of function declarations. Specifically: · e62c0a45
      Douglas Gregor authored
        - When we are declaring a function in local scope, we can merge with
          a visible declaration from an outer scope if that declaration
          refers to an entity with linkage. This behavior now works in C++
          and properly ignores entities without linkage.
        - Diagnose the use of "static" on a function declaration in local
          scope.
        - Diagnose the declaration of a static function after a non-static
          declaration of the same function.
        - Propagate the storage specifier to a function declaration from a
          prior declaration (PR3425)
        - Don't name-mangle "main"
      
      llvm-svn: 65360
      e62c0a45
Loading