Skip to content

diagnose_if fails on constructor templates when the expression is argument-independent #160776

@higher-performance

Description

@higher-performance

This test case for clang/test/SemaCXX/diagnose_if.cpp fails:

struct ConstructorTemplate {
  template <class T>
  explicit ConstructorTemplate(T x)
      _diagnose_if(sizeof(T) == sizeof(char), "oh no", "error") {}
};

void run() {
  ConstructorTemplate('1'); // expected-error{{oh no}}
}

Replacing sizeof(T) with sizeof(x) makes it succeed. It seems the code path for diagnoseArgIndependentDiagnoseIfAttrs isn't called in some cases that it's supposed to, but I got lost trying to track it down.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions