LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 47316 - 'error: parameter declarator cannot be qualified' on seemingly valid code
Summary: 'error: parameter declarator cannot be qualified' on seemingly valid code
Status: RESOLVED INVALID
Alias: None
Product: clang
Classification: Unclassified
Component: C++14 (show other bugs)
Version: 10.0
Hardware: All All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-26 01:22 PDT by Sergei Trofimovich
Modified: 2020-08-29 01:04 PDT (History)
6 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2020-08-26 01:22:16 PDT
Original bug is observed on https://bugs.gentoo.org/739036 where source-highlight was buildable by g++-10 and failed b clang++-10.

Reduced example:

  namespace a {
  
  enum c { d };
  class e {
  public:
    e(c);
  };
  
  }; // namespace a
  a::e f(a::e(a::d));

gcc succeeds to build the example, clang fails:

$ g++-10.2.0 -std=c++14 -c -o test_exception_main.o bug.cpp && echo OK || echo FAIL
OK
$ clang++-10 -std=c++14 -c -o test_exception_main.o bug.cpp  && echo OK || echo FAIL
bug.cpp:10:16: error: parameter declarator cannot be qualified
a::e f(a::e(a::d));
            ~~~^
1 error generated.
FAIL

gcc bug, clang bug or known ambiguity? Looks like clang does not see a::d as an enum value.
Comment 1 Jonathan Wakely 2020-08-26 02:54:31 PDT
This looks like https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86564
Comment 2 Richard Smith 2020-08-26 18:13:16 PDT
Yes, weird though this might be, the standard rules say that this disambiguates as a function declaration whose parameter is named a::d (with redundant parentheses around the parameter name), just like:

a::e f(a::e a::d);

... which is invalid because the name of the parameter can't be qualified, but that's a semantic restriction that's not taken into account by disambiguation.

MSVC and EDG agree that this testcase is invalid for the same reason Clang diagnoses it, so it looks like it's only GCC that uses the presence of the qualifier for disambiguation.
Comment 3 Sergei Trofimovich 2020-08-29 01:04:12 PDT
Oh, that's very non-intuitive. Thank you!